天天看点

postgresql设置开机自启动

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

[[email protected] start-scripts]# pwd
/opt/unisinsight/postgresql-10.5/contrib/start-scripts
[[email protected] start-scripts]# vim linux 
[[email protected] start-scripts]# cp linux /etc/init.d/postgresql
           

3、修改文件执行权限

[[email protected] start-scripts]# cd /etc/init.d/
[[email protected] init.d]# ls
functions  mysqld  netconsole  network  postgresql  README
[[email protected] init.d]# chmod a+x postgresql 
[[email protected] 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、启动服务

[[email protected] init.d]# service postgresql restart
Restarting PostgreSQL: ok
[[email protected] init.d]# service postgresql stop
Stopping PostgreSQL: ok
[[email protected] init.d]# service postgresql start
Starting PostgreSQL: ok
           

5、设置开机自启动

[[email protected] init.d]# chkconfig --add postgresql
[[email protected] 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
           

继续阅读