编写开机自动启动服务脚本:

# cat >> /usr/lib/systemd/system/postgresql.service >> EOF

[Unit]
Description=PostgreSQL database server
After=network.target [Service]
Type=forking User=postgres
Group=postgres # Port number for server to listen on
Environment=PGPORT=5432 # Location of database directory
Environment=PGDATA=/usr/local/pgsql9.4/data # Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog # Disable OOM kill on the postmaster
OOMScoreAdjust=-1000 #ExecStartPre=/usr/local/pgsql9.4/bin/postgresql-check-db-dir ${PGDATA}
ExecStart=/usr/local/pgsql9.4/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
ExecStop=/usr/local/pgsql9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/local/pgsql9.4/bin/pg_ctl reload -D ${PGDATA} -s # Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300 [Install]
WantedBy=multi-user.target

EOF

添加可执行权限:

chmod 754 /usr/lib/systemd/system/postgresql.service

设置为开机自启动:

systemctl enable postgresql.service

常用指令(以postgresql服务为例):

启动某服务:

systemctl  start  postgresql.service

停止某服务:

systemctl stop postgresql.service

重启某服务:

systemctl restart postgresql.service
service postgresql restart

使某服务自动启动(如tomcat服务):

systemctl enable postgresql.service

使某服务不自动启动:

systemctl disable postgresql.service

检查服务状态:

systemctl   status  postgresql.service (服务详细信息)
systemctl is-active postgresql.service(仅显示是否Active)

显示所有已启动的服务:

systemctl   list-units --type=service

Centos7下源编译安装Postgresql 并设置开机自动启动postgresql.serivce 服务相关研究的更多相关文章

  1. CentOS7 下源码安装 python3

    CentOS 7 下源码安装 python3   在CentOS7下,默认安装的是python2.7:为满足项目要求,安装python3 的方法如下:   1. 首先安装python3.6可能使用的依 ...

  2. centos下安装memcached并设置开机自动启动-两种方法

    方法一: 安装memcachedyum install memcached 启动服务并初始化service memcached start -p 11211 -l 127.0.0.1 -d 设置mem ...

  3. CentOS7下源码安装mysql5.6

    目录 准备工作 运行环境 确认你的安装版本 下载mysql 安装mysql 准备安装环境 编译和安装 配置mysql 单实例配置      单实例配置方法          添加防火墙         ...

  4. 源码编译安装nginx及设置开机启动项

    1.上传nginx文档:解压到/data目录下,并安装依赖包tar xf nginx-1.20.1.tar.gz -C /data/cd /data/nginx-1.20.1/ && ...

  5. centos7下源码安装mysql5.7.16

    一.下载源码包下载mysql源码包 http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz 二.安装约定: 用户名:mysql 安装目录 ...

  6. CentOS7下源码安装5.6.23

    清理CentOS7下的MariaDB. [root@localhost ~]#rpm -qa | gremp mariadb     [root@localhost ~]# rpm -e --node ...

  7. centos7下源码安装多个nginx步骤完整版

    1.下载:wget http://nginx.org/download/nginx-1.10.0.tar.gz     解压:tar -zxvf nginx-1.10.0.tar.gz 2. 执行下面 ...

  8. Windows 下安装redis 并且设置开机自动启动的过程.

    1. 下载redis 的 windows下的安装文件 https://github.com/MicrosoftArchive/redis/releasesmsi文件下载地址https://github ...

  9. Linux下源码安装MySQL-5.6.25

    从mysql-5.5起,mysql源码安装开始使用cmake了,因此我们得先安装cmake,配置安装目录./configure --perfix=/.....的时候和以前的会有些区别. 一.安装cma ...

随机推荐

  1. flask之Flask特殊装饰器

    flask_decorators.py ''' Flask中的特殊装饰器: (1)@app.before_request 请求到达视图函数之前,进行自定义操作,类似django中间件中的process ...

  2. day03: copy的总结(20170215)

    import copynames = ["88xiaoming","liuhai","杨东","liuhai",&quo ...

  3. (上)python3 selenium3 从框架实现学习selenium让你事半功倍

    本文感谢以下文档或说明提供的参考. Selenium-Python中文文档 Selenium Documentation Webdriver 参考 如有错误欢迎在评论区指出,作者将即时更改.文章从我的 ...

  4. JAVA定义变量和基础的数据类型和关键字

      标识符语法 1)java中定义标识符格式以字母,数字,下划线,$符合组成,不能以数字开头,且不能为  java中的关键字.         2)标识符意义要明确,不要乱起         3)标识 ...

  5. Unity自定义Log

    有如下两种方式,第一种借助了Unity自身的LogType枚举型:第二种则是纯粹地自己定义: public class Log { public Log(string message, UnityEn ...

  6. go模板-代码生成器

    能用程序去做的事,就不要用手,编写自己的代码生成器就是用来解放你的双手,替你做一些重复性的工作. 上篇帖子写了模板的基础 go模板详说 ,有了基础就要做点什么东西,把所学到的东西应用起来才能更好的进步 ...

  7. vue-cli2 使用cdn资源

    vue-cli2 引入固定cdn资源操作记录 vue引入cdn也不是什么神奇的操作,但是自己之前一直没有尝试过,这次正好项目优化需要,所以,实操一波,特此记录 本次cnd引入了如下资源 vue vue ...

  8. java方式实现插入排序

    一.基本思想 通过构建有序序列,从前往后扫描未排序序列,依此取出未排序序列元素,然后从后往前扫描有序序列,找到相应位置并插入.该算法一个进行n-1趟插入,每一趟插入要进行n-k(k为第k趟插入)次比较 ...

  9. Linux光盘yum源软件安装

    关于Linux中的软件安装,有三种方法,个人认为比较方便的就是yum安装,有网的话比较简单,暂且不提.本文主要记录在没有外网的情况下,如何以本地光盘搭建yum源来实现yum安装. 主要包括以下几步: ...

  10. Postman学习笔记(一)

    一.简介 Postman是一种网页调试与发送网页 http 请求的 chrome 插件.我们可以用来很方便的 模拟 get 或者 post 或者其他方式的请求来调试接口. 二.安装 1.chrome浏 ...