公司动态
将postgresql配置为Linux服务管理 systemctl service
发行版安装的数据库在装完后会自动添加数据库服务但编译安装的不会需要手动添加。cd postgresql-14.0/contrib/start-scripts/cp linux /etc/init.d/postgresqlcd /etc/init.d/vipostgresql修改以下部分## EDIT FROM HERE# Installation prefixprefix/data/postgres/base/14.0# Data directoryPGDATA/data/postgres/pg5432/data# Who to run the postmaster as, usually postgres. (NOT root)PGUSERpostgres# Where to keep a log filePGLOG$PGDATA/log再改下启动命令case $1 instart)echo -n Starting PostgreSQL: test -e $PG_OOM_ADJUST_FILE echo $PG_MASTER_OOM_SCORE_ADJ $PG_OOM_ADJUST_FILEsu - $PGUSER -c $PGCTL start -D $PGDATA -secho ok;;加执行权限chmod x postgresql通过下面的命令添加到服务中chkconfig --add postgresql否则会报错[rootlocalhost init.d]# systemctl stop postgresqlFailed to stop postgresql.service: Unit postgresql.service not loaded.相应的可通过下述命令删除chkconfig --del postgresql如果后面修改了postgresql文件需要reloadsystemctl daemon-reload启动测试systemctl start postgresqlsystemctl status postgresqlps -ef|grep postgres关闭测试systemctl stop postgresqlps -ef|grep postgres参考PGCE课程《服务管理》