postgresql在linux下的的開機自啟動服務與環境變量的配置
設置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
postgresql在linux下的的開機自啟動服務與環境變量的配置