Centos7設(shè)置postgresql數(shù)據(jù)庫開機(jī)自啟動(dòng)方式
前言
PostgreSQL的開機(jī)自啟動(dòng)腳本位于PostgreSQL源碼目錄的contrib/start-scripts路徑下
如果不知道具體的路徑,可以用find命令進(jìn)行查找。
命令如下:
[root@admin ~]# find / -name start-scripts /root/postgresql-14.4/contrib/start-scripts
linux文件即為linux系統(tǒng)上的啟動(dòng)腳本

操作步驟
1、將Linux文件復(fù)制到 /etc/init.d 目錄下,并且將其重名為postgresql
[root@admin start-scripts]# cp linux /etc/init.d/postgresql
2、進(jìn)入 /etc/init.d 目錄下,修改postgresql文件
[root@admin start-scripts]# cd /etc/init.d/ [root@admin init.d]# vim postgresql
查看postgresql用戶下的環(huán)境變量,然后做以下修改:
將prefix設(shè)置為postgresql的安裝路徑:/usr/local/postgresql
將PGDATA設(shè)置為postgresql的數(shù)據(jù)目錄路徑:/usr/local/postgresql/data

保存退出!
3、添加到開機(jī)啟動(dòng)
修改文件屬性并添加開機(jī)啟動(dòng)
[root@admin init.d]# chmod a+x postgresql
[root@admin init.d]# chkconfig --add postgresql
[root@admin init.d]# ll
total 44
-rw-r--r--. 1 root root 18281 Aug 24 2018 functions
-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 3569 Aug 26 09:54 postgresql
-rw-r--r--. 1 root root 1160 Oct 31 2018 README
[root@admin init.d]# chkconfig --list
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]'.
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off服務(wù)正常開啟,重啟機(jī)器測試:
重啟之后,開機(jī),服務(wù)正常開啟:

總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
嵌入式Linux驅(qū)動(dòng)中的異步通知機(jī)制詳解
這篇文章主要介紹了嵌入式Linux驅(qū)動(dòng)中的異步通知機(jī)制,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2025-05-05
linux控制臺(tái)下實(shí)現(xiàn)2048小游戲
2048小游戲已經(jīng)火了很久了,各種程序版本的都有,今天我們就來給大家分享一個(gè)在Linux控制臺(tái)中實(shí)現(xiàn)2048小游戲的代碼,希望大家能夠喜歡。2015-03-03
深度解析Linux中文件復(fù)制cp命令的底層原理與高級(jí)技巧
cp?是?Linux?中最基礎(chǔ)的文件操作命令之一,名字來自?copy(復(fù)制),本文將深入詳解Linux?cp?命令的核心原理,關(guān)鍵選項(xiàng)及其應(yīng)用場景,希望對(duì)大家有所幫助2026-05-05

