您的位置:首页 > 运维架构 > Linux

postgresql在linux下的的开机自启动服务与环境变量的配置

2016-09-26 14:43 731 查看
设置PostgreSQL开机自启动

PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下

 

linux文件即为linux系统上的启动脚本

1)修改linux文件属性,添加X属性

#chmod a+x linux

2) 复制linux文件到/etc/init.d目录下,更名为postgresql

#cp linux /etc/init.d/postgresql

 

3)修改/etc/init.d/postgresql文件的两个变量

prefix设置为postgresql的安装路径:/opt/pgsql-9.4.4

PGDATA设置为postgresql的数据目录路径:/opt/pgsql/data

 

 

4) 执行service postgresql start,就可以启动PostgreSQL服务

#service postgresql start

 

5)设置postgresql服务开机自启动

#chkconfig --add postgresql

 

执行上面的命令,就可以实现postgresql服务的开机自启动。

另一种方式

PostgreSQL数据库Linux系统开机启动

chmod a+x /opt/postgresql-8.4.3/contrib/start-scripts/linux

cp /opt/postgresql-8.4.3/contrib/start-scripts/linux /etc/init.d/postgresql

chkconfig --add postgresql

vi /ect/init.d/postgresql

修改start部分代码

su - $PGUSER -c "$DAEMON -i -D '$PGDATA' &" >>$PGLOG 2>&1加上-i参数以支持JAVA程序调取的处理

reboot

环境变量的设置

可以把下面的内容添加到UNIX用户的~/.bash_profile或~/.profile文件中, 

[root@highgo postgresql-9.4.0]# su - postgres

[postgres@highgo ~]$ vi ~/.bash_profile

...#postgres

PGDATA=/usr/local/pgsql/data

PATH=/usr/local/pgsql/bin:$PATH

 export PGDATA PATH

 [postgres@highgo ~]$ . .bash_profile

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: