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

# 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. Flex打印功能 (2011-05-21 17:16:14)

    http://blog.sina.com.cn/s/blog_4f925fc30101824k.html

  2. hdu6314 容斥+数学

    题意 : n*m的矩阵 可以涂黑白两色 问至少A行B列为黑色的涂色方案种类数,答案对998244353取模,1<=n,m,A,B<=3000 题解:  ans=sum{A,..n}sum( ...

  3. .Net基础之5——复杂数据类型

    (1)复习 1.变量 int  double   string   char   bool    decimal 变量的使用规则:先声明再赋值最后使用 2.Camo      Pascal 3.运算符 ...

  4. MySql建库操作

    mysql创建数据库 create database db_namedefault character set utf8; db_name为数据库名 查看所有数据库 show databases; 查 ...

  5. vue生命周期函数2

    转载:http://blog.csdn.net/qq_15766181/article/details/73549933 钩子就好像是把人的出生到死亡分成一个个阶段,你肯定是在出生阶段起名字,而不会在 ...

  6. 通过adb调试Unity开发的安卓应用

    命令: 1. adb logcat -s Unity 2. adb | grep Unity

  7. KNIME快速入门指南

    一.介绍  KNIME Analytics Platform是用于创建数据科学应用程序和服务的开源软件.KNIME直观,开放,不断整合新的开发,使人们可以理解数据,设计数据科学工作流程和可重用组件. ...

  8. [PHP学习教程 - 文件]002.修改上传文件大小限制(File Upload Limit)

    引言:通常大家直装xampp之后,默认的文件上传大小应该被设定成2M左右,这个时候如果上传超过2M的东西,就会报错,让人非常尴尬.如何修改呢? 导航索引: 概念 FTP常用API FTP封装类 其他 ...

  9. angularjs 指令传参规则

    angularjs 指令传参规则 xx-,data- 驼峰

  10. STM32与匿名上位机通信——使用串口DMA实现

    背景:匿名上位机功能强大,这里想要采用匿名上位机输出一些调试信息,以波形的形式显示,方便观察和调试. 平台: 硬件:STM32F405RGT6 通信:2.4G zigbee无线串口收发模块 CC253 ...