1、修改$GP_HOME/contrib/start-scripts/linux 文件
# Installation prefix
#prefix=/usr/local/pgsql
#安装路径
prefix=/home/postgres
#echo "-----$prefix-----"
# Data directory
#PGDATA="/usr/local/pgsql/data"
#数据存放路径
PGDATA="/opt/unisinsight/database/pgdata"
2、将linux文件拷贝到/etc/init.d/目录下,并命名为postgresql
[root@console start-scripts]# pwd
/opt/unisinsight/postgresql-10.5/contrib/start-scripts
[root@console start-scripts]# vim linux
[root@console start-scripts]# cp linux /etc/init.d/postgresql
3、修改文件执行权限
[root@console start-scripts]# cd /etc/init.d/
[root@console init.d]# ls
functions mysqld netconsole network postgresql README
[root@console init.d]# chmod a+x postgresql
[root@console init.d]# ll
total 56
-rw-r--r--. 1 root root 18281 Aug 24 2018 functions
-rwxr-xr-x. 1 mysql mysql 10975 Feb 2 2016 mysqld
-rwxr-xr-x. 1 root root 4569 Aug 24 2018 netconsole
-rwxr-xr-x. 1 root root 7923 Aug 24 2018 network
-rwxr-xr-x. 1 root root 3583 May 7 06:25 postgresql
-rw-r--r--. 1 root root 1160 Jan 14 23:10 README
4、启动服务
[root@console init.d]# service postgresql restart
Restarting PostgreSQL: ok
[root@console init.d]# service postgresql stop
Stopping PostgreSQL: ok
[root@console init.d]# service postgresql start
Starting PostgreSQL: ok
5、设置开机自启动
[root@console init.d]# chkconfig --add postgresql
[root@console init.d]# chkconfig --list postgresql
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off