中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Centos 7.x 配置PostgreSQL自啟動

發布時間:2020-07-15 22:44:46 來源:網絡 閱讀:3984 作者:Darren_Chen 欄目:數據庫

PostgreSQL starts with the system

The document describe how to configure automatic start PostgreSQL when the system starts.

The ways suitable for  systemd  on CentOS 7.0 or latest release.


1.  Create and configure postgresql.service

# vim /usr/lib/systemd/system/postgresql.service

[Unit]  

    Description=PostgreSQL database server

    After=remote-fs.target nss-lookup.target  

    After=network.target sshd.service

    After=proc-fs-nfsd.mount

    After=network.target local-fs.target

    After=nfs-config.service

    After=nfs-mountd.service

    After=nfs-blkmap.service

    After=nfs-client.target

    After=nfs-config.service

    After=nfs-idmapd.service

    After=nfs-idmap.service

    After=nfs-lock.service

    After=nfslock.service

    After=nfs-mountd.service

    After=nfs-secure-server.service

    After=nfs-secure.service

    After=nfs.service

    After=nfs-utils.service

[Service]  

    Type=forking  

    User=postgres

    Group=appuser

    Environment=PGPORT=5432  

    Environment=PGDATA=/data/01/local/pgsql/data  

    ExecStart=/data/01/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300  

    ExecStop=/data/01/local/pqsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast  

    ExecReload=/data/01/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s  

    TimeoutSec=300  

[Install]  

    WantedBy=remote-fs.target

#chmod 644 /usr/lib/systemd/system/postgresql.service


2.  Reload systemd  and enable postgresql.service

#systemctl daemon-reload


#systemctl enable postgresql.service

Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql.service to /usr/lib/systemd/system/postgresql.service.


#systemctl is-enabled postgresql.service

Enabled


#systemctl start postgresql.service


#systemctl status postgresql.service

● postgresql.service - PostgreSQL database server

   Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; vendor preset: disabled)

   Active: active (running) since Fri 2018-02-23 22:48:49 KST; 28min ago

Main PID: 2506 (postgres)

   CGroup: /system.slice/postgresql.service

           ├─2506 /data/01/local/pgsql/bin/postgres -D /data/01/local/pgsql/data -p 5432

           ├─2508 postgres: logger process   

           ├─2510 postgres: checkpointer process   

           ├─2511 postgres: writer process   

           ├─2512 postgres: wal writer process   

           ├─2513 postgres: autovacuum launcher process   

           └─2514 postgres: stats collector process   

Feb 23 22:48:47 ec5d-pbfcompilation-02 systemd[1]: Starting PostgreSQL database server...

Feb 23 22:48:48 ec5d-pbfcompilation-02 pg_ctl[1414]: < 2018-02-23 22:48:48.671 KST >LOG:  redirecting log output to logging collector process

Feb 23 22:48:48 ec5d-pbfcompilation-02 pg_ctl[1414]: < 2018-02-23 22:48:48.671 KST >HINT:  Future log output will appear in directory "pg_log".

Feb 23 22:48:49 ec5d-pbfcompilation-02 systemd[1]: Started PostgreSQL database server.


Note: CentOS7.x not support /etc/rc.local script file, Detailed description as following:

#cat /etc/rc.local

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#這是明智的在系統重啟的時候,去創建一個systemd 服務或者udev規則去運行腳本,而不是用/etc/rc.local

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#與先前的系統版本相比較,在系統啟動的時候,由于服務是并行運行的,所以在其他服務啟動之后,/etc/rc.local不會運行

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

雖然這里說可以使用chmod  +x /etc/rc.local 去執行這個腳本,但是筆者在這個文件中添加一行:su - postgres -c ‘pg_ctl start -D /usr/local/pgsql/data’

然后reboot測試了多次,postgres最后都沒有隨系統啟動成功,所以不再推薦(官方也不推薦了)使用/etc/rc.local文件的方式啟動postgres,啟動其他服務也一樣,最好配置一個systemd服務。




向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

新和县| 长葛市| 柏乡县| 那曲县| 临朐县| 常宁市| 航空| 徐闻县| 肥东县| 太原市| 通城县| 桂阳县| 沙田区| 南平市| 陇西县| 抚松县| 武陟县| 丰都县| 广河县| 固阳县| 东乌珠穆沁旗| 定边县| 彭水| 陈巴尔虎旗| 当涂县| 闽侯县| 洮南市| 永吉县| 夏河县| 桐柏县| 青铜峡市| 哈巴河县| 马关县| 肥城市| 台南市| 通海县| 罗山县| 文化| 文登市| 耒阳市| 玉屏|