PostgreSQL9.6源码安装
官方网站:
https://www.postgresql.org
环境:
CentOS7.2
postgresql-9.6.1
一.安装编译依赖库
yum -y install gcc gcc-c++ make readline-devel zlib-devel
二.编译安装
tar -xvf postgresql-9.6.1.tar.bz2 -C /usr/local/src/
cd /usr/local/src/postgresql-9.6.1/
./configure && make -j4 && make install
三.创建用户 和数据库data目录
useradd -r -m postgres
mkdir /usr/local/pgsql/data
chown -R postgres: /usr/local/pgsql/data/
四.初始化数据库
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
五.配置sysV管控脚本
cp /usr/local/src/postgresql-9.4.0/contrib/start-scripts/linux /etc/init.d/postgresql
chmod +x /etc/init.d/postgresql
chkconfig postgresql on
六.启动数据库
[root@node6 ~]# service postgresql start
Starting PostgreSQL: ok
[root@node6 ~]# netstat -tunlp|grep post
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 9303/postmaster
七.测试
http://www.postgres.cn/docs/9.4/manage-ag-createdb.html
http://www.postgres.cn/docs/9.4/role-attributes.html
http://www.postgres.cn/docs/9.4/sql-alterrole.html
[root@node6 ~]# echo 'PATH=$PATH:/usr/local/pgsql/bin/' >>/etc/profile
[root@node6 ~]# source /etc/profile
[root@node6 ~]# su - postgres
CREATE ROLE
postgres=# CREATE DATABASE test OWNER testadmin;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-----------+----------+-------------+-------------+-----------------------
awx | awx | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | |
一.安装编译依赖库
yum -y install gcc gcc-c++ make readline-devel zlib-devel
二.编译安装
tar -xvf postgresql-9.6.1.tar.bz2 -C /usr/local/src/
cd /usr/local/src/postgresql-9.6.1/
./configure && make -j4 && make install
三.创建用户 和数据库data目录
useradd -r -m postgres
mkdir /usr/local/pgsql/data
chown -R postgres: /usr/local/pgsql/data/
四.初始化数据库
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
五.配置sysV管控脚本
cp /usr/local/src/postgresql-9.4.0/contrib/start-scripts/linux /etc/init.d/postgresql
chmod +x /etc/init.d/postgresql
chkconfig postgresql on
六.启动数据库
[root@node6 ~]# service postgresql start
Starting PostgreSQL: ok
[root@node6 ~]# netstat -tunlp|grep post
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 9303/postmaster
七.测试
http://www.postgres.cn/docs/9.4/manage-ag-createdb.html
http://www.postgres.cn/docs/9.4/role-attributes.html
http://www.postgres.cn/docs/9.4/sql-alterrole.html
[root@node6 ~]# echo 'PATH=$PATH:/usr/local/pgsql/bin/' >>/etc/profile
[root@node6 ~]# source /etc/profile
[root@node6 ~]# su - postgres
[postgres@node6 ~]$ psql
psql (9.6.1)
Type "help" for help.
CREATE ROLE
postgres=# CREATE DATABASE test OWNER testadmin;
CREATE DATABASE
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-----------+----------+-------------+-------------+-----------------------
awx | awx | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | |