PostgreSQL Linux自启
1、系统启动,自启数据库
系统初始化时启动数据库
编辑系统启动文件:vi /etc/rc.local
添加权限:chmod +x /etc/rc.d/rc.local
问题:
测试环境:centos7
重启系统,数据库无法启动
2、服务自启
1)服务文件:
vi /usr/lib/systemd/system/postgresql.service
编辑内容:
[Unit]
Description=PostgreSQL database server
After=network.target sshd.service
[Service]
Type=forking
User=postgres
Environment=PGPORT=5432
Environment=PGDATA=/opt/pgsql/data
ExecStart=/opt/pgsql/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
ExecStop=/opt/pqsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/opt/pgsql/bin/pg_ctl reload -D ${PGDATA} -s
TimeoutSec=300
[Install]
WantedBy=remote-fs.target
2)服务启动:
#重新加载配置文件
systemctl daemon-reload
#开启自启
systemctl enable postgresql.service
#是否开启自启
systemctl is-enabled postgresql.service
#启动数据库
systemctl start postgresql.service
#查看启动状态
systemctl status postgresql.service
参考文献:
1、https://www.manniwood.com/postgresql_94_compile_install_howto/index.html
声明
1)文章来源项目实践,文章存在任何疑惑或者错误请留言,感谢您的阅读!
2)转载请标准来源,感谢!