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

# 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. env虚拟环境配置(两种)

    virtualenv(依赖关系难以解决) windows项目虚拟环境创建 # WINDOWS 环境使用虚拟环境# 在当前项目下# 安装 pip3 install virtualenv# 创建虚拟环境 ...

  2. Spring IOC 容器 简介

    Spring 容器是 Spring 框架的核心.容器将创建对象,把它们连接在一起,配置它们,并管理他们的整个生命周期从创建到销毁. Spring 容器使用依赖注入(DI)来管理组成一个应用程序的组件. ...

  3. HDU6440 Dream

    题目链接:https://vjudge.net/problem/HDU-6440 知识点: 构造.费马小定理 题目大意: 给定一个素数 $p$,要求定义一个加法运算表和一个乘法运算表,尺寸都为 $p ...

  4. 带你学够浪:Go语言基础系列 - 8分钟学基础语法

    对于一般的语言使用者来说 ,20% 的语言特性就能够满足 80% 的使用需求,剩下在使用中掌握. 基于这一理论,Go 基础系列的文章不会刻意追求面面俱到,但该有知识点都会覆盖,目的是带你快跑赶上 Go ...

  5. 实验四:Linux系统C语言开发环境学习

    项目 内容 这个作业属于哪个课程 班级课程主页链接 这个作业的要求在哪里 作业要求 学号-姓名 17043133-木腾飞 作业学习要求 1.学习Linux系统中如何查看帮助文档:2.在Linux系统中 ...

  6. 0512String类

    String类 2. String类 2.1 字符串类型概述 又爱又恨!!! 爱: 字符串基本上就是数据的保存,传输,处理非常重要的一种手段. 恨: 解析过程非常烦人,需要掌握熟记很多方法,同时需要有 ...

  7. RabbitMQ(1)---基本概念

    一.安装RabbitMQ 安装直接用docker安装,如果手动安装的话比较繁琐,还要安装erlang语言的环境.在安装有docker机器上执行官网提供的指令(https://www.rabbitmq. ...

  8. mybatis是怎样炼成的

    前言 一些个人感受:不管分析什么源码,如果我们能摸索出作者的心路历程,跟着他的脚步一步一步往前走,这样才能接近事实的真相,也能更平滑更有趣的学习到知识.跟福尔摩斯探案一样,作者都经历了些什么,为什么他 ...

  9. 《HelloGitHub》第 50 期

    兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程.对开源社区感兴趣 人群的月刊,月刊的内容包括:各种编 ...

  10. element-ui上传组件,通过自定义请求上传文件

    记录使用element-ui上传组件,通过自定义请求上传文件需要注意的地方. <el-upload ref="uploadMutiple" :auto-upload=&quo ...