暂无图片
启动 PostgreSQL 服务器,怎么加入自启动服务
我来答
分享
redgame
2023-06-18
启动 PostgreSQL 服务器,怎么加入自启动服务
如题
我来答
添加附件
收藏
分享
问题补充
1条回答
默认
最新
Zixin Huo

1、查找自启动服务文件路径;
[root@localhost]# find / -name start-scripts
/opt/postgresql/postgresql-9.6.0/contrib/start-scripts

2、将linux文件拷贝到/etc/init.d/目录下,并命名为postgresql;(服务名为postgresql)

[root@localhost ]# cp
/opt/postgresql/postgresql-9.6.0/contrib/start-scripts/linux /etc/init.d/postgresql

3、修改服务文件 /etc/init.d/postgresql

#Installation prefix
#prefix=/usr/local/pgsql
#安装路径
prefix=/home/postgres
#echo “-----$prefix-----”
#Data directory
#PGDATA="/usr/local/pgsql/data"
#数据存放路径
PGDATA="/home/postgres/pgdata"

4、修改文件执行权限

[root@localhost ]#chmod a+x postgresql

[root@localhost]# ll /etc/init.d/
total 40
-rw-r–r–. 1 root root 18281 Aug 24 2018 functions
-rwxr-xr-x. 1 root root 3657 Aug 24 2018 postgresql
-rw-r–r–. 1 root root 1160 Oct 31 2018 README

5、启动服务

[root@localhost]# service postgresql restart
Restarting PostgreSQL: ok
[root@localhost]# service postgresql stop
Stopping PostgreSQL: ok
[root@localhost]# service postgresql start
Starting PostgreSQL: ok

6、设置开机自启动

[root@localhost]# chkconfig --add postgresql
[root@localhost]# chkconfig --list postgresql

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]'.


复制

postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

暂无图片 评论
暂无图片 有用 4
打赏 0
暂无图片
回答交流
Markdown


请输入正文
提交
相关推荐
请指教,PG12遇到报错 ERROR: could not find tuple for attrdef 37(Drop sequence seq1报错)
回答 5
建议先在测试环境测试一下上述操作,在生产环境先备份后操作。
pg中allow_system_table_mods没有开启,怎么还能修改系统表?
回答 2
在opengauss5.0中,为什么设置了allowsystemtablemods为on后,使用超级用户执行altertablepgclassxxx语句仍然会报error: 'pgclass
PostgreSQL数据库的文件存储在哪里?
回答 1
已采纳
initdb的时候会指定一个PGDATA目录,这就是PostgresQL存储数据的地方。典型的位置是在/postgres/dataa。PGDATA下面各项存储的内容大概是:文件或目录名存储内容PGVE
postgreSQL 中想实现日志按小时记录,保留最近3天的日志怎么设置?
回答 1
修改$PGDATA/postgressql.conflogfilename&x27;postgresql%Y%m%d%H.log&x27;PostgreSQL每小时创建一个新的日志文件,文件名显示当前
postgreSQL 库分页后面那个页码和每页条数怎么计算?
回答 1
SELECT,ROWNUMBER()OVER()ASrownum,CEILING(ROWNUMBER()OVER()/10.0)ASpagenumFROMtablename;假设每页包含10条数据
postgreSQL pg_cron对数据库有没有影响?
回答 1
没有
pg如何在线修改表结构
回答 2
mysql的ptosc在线修改的工具,在pg中有啥工具来对应?
pg_rewind报错
回答 1
检查或重装pgaudit,重启源库,再运行pgrewind。
PostgreSQL 中IN的参数长度有限制吗?
回答 2
已采纳
IN后面的参数数量没有限制,但是如果IN后面的参数真的很多,那你还是梳理一下需求,看是否能以一种更合适的方式来处理该查询,否则即使没有限制,也可能会撞见一些性能问题
postgreSQL 有没有数据脱敏插件?
回答 2
可以参考我的这篇文章:PostgreSQL数据脱敏插件介绍