首页 > 数据库 >Centos7设置postgresql数据库开机自启动

Centos7设置postgresql数据库开机自启动

时间:2022-09-23 17:00:36浏览次数:50  
标签:postgresql admin Centos7 开机 init 自启动 off root

前言
PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下
如果不知道具体的路径,可以用find命令进行查找。

命令如下:

[root@admin ~]# find / -name start-scripts
/root/postgresql-14.4/contrib/start-scripts
linux文件即为linux系统上的启动脚本

 

 

 

操作步骤
1、将Linux文件复制到 /etc/init.d 目录下,并且将其重名为postgresql

[root@admin start-scripts]# cp linux /etc/init.d/postgresql
2、进入 /etc/init.d 目录下,修改postgresql文件

[root@admin start-scripts]# cd /etc/init.d/
[root@admin init.d]# vim postgresql
查看postgresql用户下的环境变量,然后做以下修改:

将prefix设置为postgresql的安装路径:/usr/local/postgresql

将PGDATA设置为postgresql的数据目录路径:/usr/local/postgresql/data

 

 


保存退出!

3、 添加到开机启动

修改文件属性并添加开机启动

[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
服务正常开启,重启机器测试:

重启之后,开机,服务正常开启:

 

 


————————————————
版权声明:本文为CSDN博主「auspicious航」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Auspicious_air/article/details/126537044

标签:postgresql,admin,Centos7,开机,init,自启动,off,root
From: https://www.cnblogs.com/telwanggs/p/16723328.html

相关文章

  • 第九章Centos7下Docker版本升级
    一、查找Docker的软件包[root@staging~]#rpm-qa|grepdockerdocker-client-1.13.1-203.git0be3e21.el7.centos.x86_64docker-common-1.13.1-203.git0be3e21.el7.ce......
  • centos7 解决libstdc++.so.6.0.19版本问题
    问题描述:ImportError:/usr/lib64/libstdc++.so.6:version`CXXABI_1.3.8’notfound查看:[root@localhostlib64]#find/-namelibstdc++.so.6/usr/lib64/libstdc......
  • centos6创建mysql开机自启动
    环境:OS:centos6db:5.6.40 1.修改/etc/init.d/mysqld文件,默认文件以及存在,该文件内容如下:#!/bin/sh#CopyrightAbandoned1996TCXDataKonsultAB&MontyPro......
  • 开机自启动热点
    开机自启动脚本https://blog.csdn.net/m0_52650517/article/details/119767308create_ap开启热点https://blog.csdn.net/memory01/article/details/114317155可能遇到......
  • Centos7.6安装中文字体
    Centos7.6安装中文字体转: https://blog.csdn.net/liuwenbiao1203/article/details/100096031题注: 最近做一个报表生成功能,在win10系统下测试正常,但部署到......
  • PostgreSQL与Greenplum之区别
    一、区别:(1)Greenplum是用于报告、分析、机器学习、人工智能和高并发SQL的大规模并行数据库的开源软件。Greenplum以PostgreSQL为基础,Greenplum数据库被描述为以MP......
  • centos6 和centos7 的区别
    内核:centos7是3.10centos6是2.6文件系统:centos6是ext4centos7是xfs硬盘默认调度算法6默认使用cfq7默认使用的是deadline算法防火墙6iptables7firealld......
  • centos7下使用yum安装mysql
    CentOS7的yum源中默认好像是没有mysql的。为了解决这个问题,我们要先下载mysql的repo源。1.下载mysql的repo源$wget http://repo.mysql.com/mysql-community-release-e......
  • CentOS 7.9 Nacos 设置开机自启动
    CentOS7.9 Nacos设置开机自启动 1、编写Nacos系统启动文件在下/lib/systemd/system创建nacos.service文件vi/lib/systemd/system/nacos.service编写内容......
  • PostgreSQL启用归档模式
    1、https://www.cnblogs.com/kreo/p/15304980.html1、事先检查命令#查看数据目录(找出conf文件位置)postgres=#SHOWdata_directory;#查看归档模式情况postgr......