(篇幅原因,有省略……)
Complete!
[root@TEST-DB uploads]# yum install postgresql95-9.5.0-2PGDG.rhel6.x86_64.rpm
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use
(篇幅原因,有省略……)
Installed:
postgresql95.x86_64 0:9.5.0-2PGDG.rhel6
Complete!
[root@TEST-DB uploads]# rpm -ivh postgresql95-server-9.5.0-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-server-9.5.0-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95-server ########################################### [100%]
[root@TEST-DB uploads]# rpm -ivh postgresql95-contrib-9.5.0-2PGDG.rhel6.x86_64.rpm
warning: postgresql95-contrib-9.5.0-2PGDG.rhel6.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing... ########################################### [100%]
1:postgresql95-contrib ########################################### [100%]
注意:选择使用rpm包进行安装之后,会自动创建操作系统用户postgres,可以使用passwd命令进行密码设置。
[root@TEST-DB uploads]# id postgres
uid=26(postgres) gid=26(postgres) groups=26(postgres)
[root@TEST-DB uploads]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.
3、本地服务配置和本地连接测试
使用RPM包安装之后,系统中会自动添加一个postgresql-<vxxx>的服务。我们可以通过这个服务启动数据库。
--默认状态是关闭
[root@TEST-DB uploads]# service --status-all | grep postgres
postgresql-9.5 is stopped
--强制启动失效
[root@TEST-DB uploads]# service postgresql-9.5 start
/var/lib/pgsql/9.5/data is missing. Use "service postgresql-9.5 initdb" to initialize the cluster first.
[FAILED]
第一次启动失败,主要是由于最开始数据库中没有主库存在。可以先用initdb来进行初始化动作。
[root@TEST-DB uploads]# service postgresql-9.5 initdb
Initializing database: [ OK ]
[root@TEST-DB uploads]# service --status-all | grep postgres
postgresql-9.5 is stopped
[root@TEST-DB uploads]# service postgresql-9.5 start
Starting postgresql-9.5 service: [ OK ]
查看后台postgres进程运行情况。
[root@TEST-DB uploads]# ps -ef | grep postgres
postgres 28417 1 0 09:53 ? 00:00:00 /usr/pgsql-9.5/bin/postmaster -D /var/lib/pgsql/9.5/data
postgres 28419 28417 0 09:53 ? 00:00:00 postgres: logger process
postgres 28421 28417 0 09:53 ? 00:00:00 postgres: checkpointer process
postgres 28422 28417 0 09:53 ? 00:00:00 postgres: writer process
postgres 28423 28417 0 09:53 ? 00:00:00 postgres: wal writer process
postgres 28424 28417 0 09:53 ? 00:00:00 postgres: autovacuum launcher process
postgres 28425 28417 0 09:53 ? 00:00:00 postgres: stats collector process
root 28431 27089 0 09:53 pts/0 00:00:00 grep postgres