From Disk partition to PostgreSQL installation
From Disk partition to PostgreSQLinstallation
[root@compute mnt]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
Partition number (1-4, default 1):
First sector (2048-1953525167, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1953525167, default 1953525167): +100G
Partition 1 of type Linux and of size 100 GiB is set
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@compute mnt]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005e2b3
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209717247 104857600 83 Linux
Command (m for help): q
[root@compute mnt]# fdisk -l /dev/sdb
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005e2b3
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209717247 104857600 83 Linux
[root@compute mnt]# mkfs.ext4 -b 4096 -E stride=2,stripe-width=6 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=2 blocks, Stripe width=6 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@compute mnt]# mount -o defaults,noatime,nodiratime,discard,nodelalloc,nobarrier /dev/sdb1 /mnt
[root@compute ~]# vim /etc/fstab
/dev/sdb1 /mnt ext4 defaults,noatime,nodiratime,discard,nodelalloc,nobarrier 0 0
[root@compute ~]# cd /mnt/
[root@compute mnt]# ls
lost+found
[root@compute mnt]# mkdir pg945
[root@compute mnt]# ls
lost+found pg945
[root@compute mnt]# useradd -U postgres -p 123456
[root@compute mnt]# chown -R postgres:postgres /mnt/
[root@compute mnt]# yum -y install readline-devel zlib zlib-devel openssl openssl-devel gcc make flex bison
[root@compute mnt]# chown -R postgres:postgres /opt/soft_bak/
[root@compute mnt]# su - postgres
Last login: Tue Jan 19 17:24:08 CST 2016 on pts/1
[postgres@compute ~]$ cd /opt/soft_bak/
[postgres@compute soft_bak]$ tar jxvf postgresql-9.4.5.tar.bz2
[postgres@compute soft_bak]$ cd postgresql-9.4.5
[postgres@compute postgresql-9.4.5]$ ./configure --prefix=/mnt/pg945/
[postgres@compute postgresql-9.4.5]$ gmake world
[postgres@compute postgresql-9.4.5]$ gmake install-world
[postgres@compute postgresql-9.4.5]$ mkdir -p /mnt/pg945/data
[postgres@compute pg945]$ ls
bin data include lib share
[postgres@compute pg945]$ cd bin/
[postgres@compute bin]$ ./initdb -D ../data/ -E UTF8 --locale=C -U postgres -W
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "C".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory ../data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in ../data/base/1 ... ok
initializing pg_authid ... ok
Enter new superuser password:
Enter it again:
setting password ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating collations ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
./postgres -D ../data/
or
./pg_ctl -D ../data/ -l logfile start
[postgres@compute bin]$ vim ../data/postgresql.conf
listen_addresses = '*'
port = 5432
unix_socket_directories = '.'
log_destination = 'csvlog'
logging_collector = on
log_directory = 'pg_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_file_mode = 0600
log_truncate_on_rotation = on
[postgres@compute bin]$ ./pg_ctl -D ../data/ start
server starting
[postgres@compute bin]$ LOG: redirecting log output to logging collector process
HINT: Future log output will appear in directory "pg_log".
[postgres@compute bin]$ ./psql -h localhost -p 5432 -U postgres -W
Password for user postgres:
psql (9.4.5)
Type "help" for help.
postgres=# create database test;
CREATE DATABASE
postgres=# \c test
Password for user postgres:
You are now connected to database "test" as user "postgres".
test=# create table test_db(id int);
CREATE TABLE
test=# insert into test_db values (1),(2),(3);
INSERT 0 3
test=# select * from test_db ;
id
----
1
2
3
(3 rows)
test=# \q
[postgres@compute bin]$ ./pg_ctl -D ../data/ stop -m fast
waiting for server to shut down.... done
server stopped
From Disk partition to PostgreSQL installation的更多相关文章
- An existing PostgreSql installation has been found... 的解决
PostgreSql卸载之后,重新安装时跳出如下信息: Anexisting PostgreSql installation has been found atC:\ProgramFiles\Post ...
- Linux mount BSD disk partition
Linux mount BSD disk partition 来源 https://www.cnblogs.com/jhcelue/p/6858159.html 假设须要从第二块硬盘复制文件.该硬盘格 ...
- The PostgreSQL installation in windows
Summary: in this tutorial, we will show you how to install PostgreSQL on your local system for learn ...
- How to get the free disk space in PostgreSQL (PostgreSQL获取磁盘空间)
Get the current free disk space in PostgreSQL PostgreSQL获取磁盘空间 from eshizhan Here has a simple way t ...
- 磁盘、分区及Linux文件系统 [Disk, Partition, Linux File System]
1.磁盘基础知识 1.1 物理结构 硬盘的物理结构一般由磁头与碟片.电动机.主控芯片与排线等部件组成:当主电动机带动碟片旋转时,副电动机带动一组(磁头)到相对应的碟片上并确定读取正面还是反面的碟面,磁 ...
- linux下安装postgresql
环境:Linux localhost.localdomain 2.6.32-431 GNU/Linux x86_64 Postgresql版本:postgresql.9.5.3 添加开启自启设置:ht ...
- P6 EPPM Installation and Configuration Guide 16 R1 April 2016
P6 EPPM Installation and Configuration Guide 16 R1 April 2016 Contents About Installing and ...
- PostgreSQL Partitions
why we need partitions The first and most demanding reason to use partitions in a database is to inc ...
- PostgreSQL源码安装文档
This document describes the installation of PostgreSQL using the source code distribution. (If yo ...
随机推荐
- Bootstrap页面布局17 - BS选项卡
代码结构: <div class='container-fluid'> <h2 class='page-header'>Bootstrap 选项卡</h2> < ...
- cPanel设置自定义404错误页
利用这个cpanel的错误页工具,你就可以定制错误页面了.设置自定义404错误页,有两种简单的方法. 一,利用cpanel后台控制面板添加设置404自定义错误页的方法 步骤 1.登录cPa ...
- 理解OAuth 2.0[摘]
原文地址:http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到 ...
- Andrew Ng机器学习公开课笔记–Independent Components Analysis
网易公开课,第15课 notes,11 参考, PCA本质是旋转找到新的基(basis),即坐标轴,并且新的基的维数大大降低 ICA也是找到新的基,但是目的是完全不一样的,而且ICA是不会降维的 对于 ...
- vbox共享文件 挂载
环境:主机操作系统是Windows 7,虚拟机是open suse 12.0,虚拟机是VirtualBox 4.2.1. 1. 安装增强功能包(Guest Additions) 安装好open sus ...
- vim编辑器配置修改
刚上手的vim,黑底白字,看起来笨死了,于是一顿狂找,终于找到了配置方法. 配置当然要去etc目录下. cd /etc/vim ls -l //找到vim ...
- 20145211 《Java程序设计》第3周学习总结——绝知此事要躬行
教材学习内容总结 4.1何为面向对象 面向对象,面向过程都是一种思想,没有高低之分.面向对象,就像是对冰箱操作,冰箱是一个介质,用法就像是c语言中的结构体,功能定义在对象上.面向对象,角色转变,让我们 ...
- Objdump-查看汇编指令
作用 Objdump可以用来看汇编指令 查看汇编指令 测试文件 编译指令 gcc -g -o objtest 1.8.c objdump -S objtest |more /main 查看结果
- 面向对象分析方法(II)
什么是真正的对象? 什么是面向对象分析阶段时的对象? 什么是面向对象设计阶段时的对象? 什么是面向对象实现阶段时的对象? 真正的对象 我所理解的真正的对象就是现实生活中客观存在或不存在的真正的对象.这 ...
- JMeter学习-013-JMeter 逻辑控制器之-如果(If)控制器
前文简述了 JMeter 如何通过 HTTP Cookie管理器,实现了在不执行登录操作的情况下,通过 Cookie 实现登录态的操作,具体请参阅:JMeter学习-012-JMeter 配置元件之- ...