OS信息:
[root@rhel73 ~]# uname -a
Linux rhel73 3.10.0-514.el7.x86_64 #1 SMP Wed Oct 19 11:24:13 EDT 2016 x86_64 x86_64 x86_64 GNU/Linux
[root@rhel73 ~]# uname -r
3.10.0-514.el7.x86_64
[root@rhel73 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.3 (Maipo)
实施过程:
第一:root用户下,在/etc/rc.local中加入下面的一行:
su - postgres -c "/home/postgres/startpg.sh"
第二:root用户下,执行如下命令.请注意:如下命令一定要执行,否则在RHEL7中,os重启不会把PostgreSQL数据库Cluster 自动拉起来.
chmod +x /etc/rc.d/rc.local
第三:postgres用户下,建立/home/postgres/startpg.sh文件,该文件的内容如下:
/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data
第四:赋予权限.
chmod +x /home/postgres/startpg.sh
第五:
OS重启之后,验证PostgreSQL数据库Cluster 自动拉起来
[root@rhel73 ~]# su - postgres
Last login: Wed Mar  8 12:28:35 EST 2017
[postgres@rhel73 ~]$ psql -l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 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          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)


[postgres@rhel73 ~]$