网上出现的比较多安装方法要么是源码安装,要么是yum安装,我发觉都要配置很多属性,比较麻烦,所以现在我在centos7长用 run文件来安装

http://get.enterprisedb.com/postgresql/postgresql-9.5.1-1-linux-x64.run

这里的安装shell整理的很零乱,后面会整理一个完整版本的出来

wget https://pgbouncer.github.io/downloads/files/1.7.2/pgbouncer-1.7.2.tar.gz
wget http://get.enterprisedb.com/postgresql/postgresql-9.5.1-1-linux-x64.run
wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz tar zxvf libevent-2.0.22-stable.tar.gz
cd libevent-2.0.22-stable
./configure --prefix=/usr/local/libevent
make
make install
cd .. tar zxvf pgbouncer-1.7.2.tar.gz
cd pgbouncer-1.7.2
./configure --prefix=/usr/local/pgbouncer/ --with-libevent=/usr/local/libevent/
make
make install
cd .. chmod 777 postgresql-9.5.1-1-linux-x64.run
./postgresql-9.5.1-1-linux-x64.run sudo chown -R postgres.postgres /alidata/pgsql
sudo chown -R postgres.postgres /usr/local/pgbouncer #以下为配置环境变量部分,这里还没写好,你可以参考
su - postgres
cp .bash_profile /alidata/pgsql
cp .bashrc /alidata/pgsql
su - postgres export PGHOME=/alidata/pgsql
export PATH=$PGHOME/bin:$PATH
export PGDATA=$PGHOME/data
export LD_LIBRARY_PATH=$PGHOME/lib
export LD_LIBRARY_PATH=/usr/local/libevent/lib:$LD_LIBRARY_PATH

  

用run文件安装就比较简单,但是安装完成后,它会默认安装成linux的系统服务,所以这里需要从源码里面去拷贝

PostgreSQL的开机自启动脚本位于PostgreSQL源码目录的contrib/start-scripts路径下

linux文件即为linux系统上的启动脚本

#chmod a+x linux

#cp linux /etc/init.d/postgresql

#修改/etc/init.d/postgresql文件的两个变量

prefix设置为postgresql的安装路径:/alidata/pgsql

附此文件,如果你没下载源码,可以直接通过在

vi postgresql新建一个文件

把下面这段拷贝进去保存

拷贝进去放到 /etc/init.d/下

然后service postgresql status 可以查询对应的操作

#! /bin/sh

# chkconfig: 2345 98 02
# description: PostgreSQL RDBMS # This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
# /etc/rc.d/rc0.d/K02postgresql
# /etc/rc.d/rc1.d/K02postgresql
# /etc/rc.d/rc2.d/K02postgresql
# /etc/rc.d/rc3.d/S98postgresql
# /etc/rc.d/rc4.d/S98postgresql
# /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care. # Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net> # contrib/start-scripts/linux ## EDIT FROM HERE # Installation prefix
prefix=/alidata/pgsql # Data directory
PGDATA="/alidata/data" # Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER=postgres # Where to keep a log file
PGLOG="$PGDATA/serverlog" # It's often a good idea to protect the postmaster from being killed by the
# OOM killer (which will tend to preferentially kill the postmaster because
# of the way it accounts for shared memory). To do that, uncomment these
# three lines:
#PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
#PG_MASTER_OOM_SCORE_ADJ=-1000
#PG_CHILD_OOM_SCORE_ADJ=0
# Older Linux kernels may not have /proc/self/oom_score_adj, but instead
# /proc/self/oom_adj, which works similarly except for having a different
# range of scores. For such a system, uncomment these three lines instead:
#PG_OOM_ADJUST_FILE=/proc/self/oom_adj
#PG_MASTER_OOM_SCORE_ADJ=-17
#PG_CHILD_OOM_SCORE_ADJ=0 ## STOP EDITING HERE # The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin # What to use to start up the postmaster. (If you want the script to wait
# until the server has started, you could use "pg_ctl start -w" here.
# But without -w, pg_ctl adds no value.)
DAEMON="$prefix/bin/postmaster" # What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl" set -e # Only start if we can find the postmaster.
test -x $DAEMON ||
{
echo "$DAEMON not found"
if [ "$1" = "stop" ]
then exit 0
else exit 5
fi
} # If we want to tell child processes to adjust their OOM scores, set up the
# necessary environment variables. Can't just export them through the "su".
if [ -e "$PG_OOM_ADJUST_FILE" -a -n "$PG_CHILD_OOM_SCORE_ADJ" ]
then
DAEMON_ENV="PG_OOM_ADJUST_FILE=$PG_OOM_ADJUST_FILE PG_OOM_ADJUST_VALUE=$PG_CHILD_OOM_SCORE_ADJ"
fi # Parse command line parameters.
case $1 in
start)
echo -n "Starting PostgreSQL: "
test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok"
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
test -e "$PG_OOM_ADJUST_FILE" && echo "$PG_MASTER_OOM_SCORE_ADJ" > "$PG_OOM_ADJUST_FILE"
su - $PGUSER -c "$DAEMON_ENV $DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo "ok"
;;
status)
su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
;;
*)
# Print help
echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac exit 0

chkconfig --add 服务名称          (首先,添加为系统服务,注意add前面有两个横杠)

chkconfig --leve 启动级别 服务名 on         

说明,3级别代表在命令行模式启动,5级别代表在图形界面启动,on表示开启)

 chkconfig --leve 启动级别 服务名 off              

(说明,off表示关闭自启动)

 例如:chkconfig --level 3 postgresql on                     (说明:让postgresql 服务在命令行模式,随系统启动)

postgresql9.5 run 文件linux安装后配置成开机服务的更多相关文章

  1. linux安装后配置

    1.1 系统设置(自测用,公司不需要) 1.1.1 Selinux系统安全保护 Security-Enhanced Linux – 美国NSA国家安全局主导开发,一套增强Linux系统安 全的强制访问 ...

  2. linux下.run文件的安装与卸载

    linux下.run文件的安装与卸载   .run文件的安装很简单,只需要为该文件增加可执行属性,即可执行安装 以 virtualbox 的安装文件 virtualbox-3.1.6-59338-Li ...

  3. FreeBSD从零开始---安装后配置(一)

    一.安装后配置   上次我们说到FreeBSD的安装,这次我们说FreeBSD安装后的配置和简单优化方法.   安装完BSD只是服务器提供服务这条万里长征路的开始,还需要一些基本的设定和优化.不过实际 ...

  4. linux安装及配置c++的opencv库

    linux安装及配置c++的opencv库 前言: 最近想搞个机器视觉的比赛,要求是linux+opencv环境,没有做过opencv开发的我配置环境就配了两天,看来很多乱七八糟的博客,终于装好了.网 ...

  5. Windows Server 2008R2配置MySQL Cluster并将管理节点和数据节点配置成windows服务

    说明:将mysql的管理节点和数据节点配置成windows服务是为了防止有人手误关闭管理节点或数据节点的dos命令窗口,管理节点或数据节点的命令窗口误关闭可能会造成mysql某台或某几台mysql不能 ...

  6. 创建一个MongoDB数据库再到配置成Window服务再设置用户名密码

    1.安装MongoDB数据在官网下载安装 然后在C盘找到C:\Program Files\MongoDB\Server\4.0\bin这个可执行目录 使用cmd进入到这: 2.在C盘根目录创建一个名为 ...

  7. centos7如何将docker容器配置成开机自启动

    docker 服务器开机自启动: 1.systemctl is-enabled docker.service  检查服务是否开机启动 2.systemctl enable docker.service ...

  8. 安装Linux系统后配置的一般步骤

    安装linux后配置的一般步骤 最近在尝试不同的linux系统,记录一下安装完linux之后常用的软件的安装方法 1.源的更新 ubuntu 源的更新方法 参考(没有测试过,但是都大同小异,不行就换一 ...

  9. zabbix系列之六——安装后配置二Items

    https://www.zabbix.com/documentation/3.4/manual/config/items/itemtypes/snmp 1Items 1.1creating items ...

随机推荐

  1. 【python】python的二元表达式和三元表达式

    二元表达式 x,y=4,3if x>y: s = yelse: s= x print s   x if x<y else y 三元表达式: >>> def f(x,y): ...

  2. C语言学习总结(二) 运算流程

    第三章.基本运算 (运算符.算数运算符.关系运算符.逻辑运算符.三目运算符.ASXLL码) 一.什么是运算符? 概念:是编译程序执行特定的算术或逻辑操作的符号: 分类:算术运算符. 关系运算符.逻辑运 ...

  3. ubuntu杂记

    安装ssh: sudo apt-get install openssh-server sudo /etc/init.d/ssh start 将主机中vmware8的网络改为自动获取ip,就可以ping ...

  4. STM32之外部中断控制

    一.STM32外部中断 1.STM32外部中断结构图 如上图所示:主要包括四个环节,GPIO.AFIO.EXTI.NVIC.以STM32F103VE(100脚)为例说明硬件模块的数量: GPIO:   ...

  5. 程序在nor flash中真的可以运行吗?

    程序在nor flash中可以运行,但是是有限制的,它不能像RAM那样随意的写(尽管它可以随意的读).在norflash上,不能运行写存储器的指令,不过排除写的地方是RAM类.实验中的三个文件如下所示 ...

  6. SQL效率低下原因主要有

    类别 子类 表达式或描述 原因 索引 未建索引   产生全表扫描   未利用索引 substring(card_no,1,4)=′5378′ 产生全表扫描     amount/30< 1000 ...

  7. Jar包可执行??

    第一次听说,jvm加载包,必须rwx么?

  8. 【POJ 2987】Firing (最小割-最大权闭合子图)

    裁员 [问题描述] 在一个公司里,老板发现,手下的员工很多都不务正业,真正干事员工的没几个,于是老板决定大裁员,每开除一个人,同时要将其下属一并开除,如果该下属还有下属,照斩不误.给出每个人的贡献值和 ...

  9. webkit中DOM 事件有多少

    webkit中DOM 事件有多少 目前客户端javascript中大量的工作就是处理浏览器,用户触发的各种事件,下面是webkit中这些事件的集合,有一些时常见的,标准规定的,而另一些则是webkit ...

  10. Qt无边框MainWindow如何拖动四周改变大小

    原来还有winEvent(), x11Event() and macEvent() 这些东西...不过貌似还需要找更好的办法,否则就无法跨平台了. 你需要重新处理部分窗体事件,以下代码适用于Windo ...