网上出现的比较多安装方法要么是源码安装,要么是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.gztar 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.runsudo 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 - postgresexport 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 0else exit 5fi
}# 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" ]
thenDAEMON_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 instart)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>&1echo "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>&1echo "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 helpecho "Usage: $0 {start|stop|restart|reload|status}" 1>&2exit 1;;
esacexit 0

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

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

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

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

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

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

转载于:https://www.cnblogs.com/fangyuan303687320/p/5452430.html

postgresql9.5 run 文件linux安装后配置成开机服务相关推荐

  1. linux改文件后run,linux下.run文件如何安装与卸载

    w 表示可写入,其中 u 表示该档案的拥有者,有个 uninstall 文件, r 表示可读取,利用 chmod 可以藉以控制档案如何被他人所调用. 执行./uninstall就ok了 下面是其他网友 ...

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

    转载地址:http://www.2cto.com/os/201205/130236.html linux下.run文件的安装与卸载 .run文件的安装很简单,只需要为该文件增加可执行属性,即可执行安装 ...

  3. Manjaro KDE 21.2.5安装后配置、yay常用命令、常用软件安装及主题美化(2022.04.18)

    Manjaro KDE 21.2.5安装后配置.yay常用命令.常用软件安装及主题美化(2022.01.23) 结果展示 基本配置 关于 manjaro 的安装这里不再赘述了,安装的时候选择闭源驱动无 ...

  4. RedHat 系列 Linux 安装后,建立嵌入式开发环境

    RedHat 系列 Linux 安装后,建立嵌入式开发环境 from:https://segmentfault.com/a/1190000005881355 做开发的时候,经常为了某系列的项目,专门就 ...

  5. Oracle Grid Control 11g for linux安装和配置指南

    2019独角兽企业重金招聘Python工程师标准>>> Oracle Grid Control 11g for linux安装和配置指南 原创 candon123 2010-07-1 ...

  6. 云服务器Linux安装,配置,使用nginx

    云服务器Linux安装,配置,使用nginx linux安装nginx nginx的使用 linux安装nginx 检查是否安装了GCC(可在任何目录下输入) yum list installed | ...

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

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

  8. elementary OS 5 Juno (Pantheon) 安装后配置总结(干货很多)

    欢迎加入 Ubuntu 阵营!elementary OS 是 Ubuntu 阵营中兼具实用和美观的发行版,的确值得安装尝试.这是一篇长文,我精简了一些内容,但是干货越多说得越详细,篇幅就会越大.已经克 ...

  9. linux安装后连接不上网络

    linux安装后连接不上网络 linux最小版安装后 ping www.baidu.com 结果显示notknow 解决办法: 1.可能ip地址和网关dns没配置 2.可能windows系统有两个服务 ...

最新文章

  1. 浅析日常网站建设中运营与优化的工作重点
  2. HBase1.2.3 数据模型
  3. [CTSC2017]吉夫特(Lucas定理,DP)
  4. matlab中cuda编程中分配grid和block dimension的时候的注意事项
  5. 如何在EdrawMax中同时画有箭头和没箭头的直线
  6. A311D项目开发总结
  7. LeetCode 常用方法
  8. C语言题目:输出三角形面积和周长 (15 分)
  9. 在 Windows 下关闭135/139/445端口的图文方法
  10. [JavaScript] 模拟京东快递单号查询案例
  11. 网页视频下载:怎么批量下载网页上的视频
  12. iOS打开应用提示未受信任的企业级开发者
  13. 沈阳打铁记录+暑假训练开始分界线
  14. download.php是什么文件,qmdownload是什么文件?
  15. obd协议 混动车_OBD协议
  16. oracle统计每日归档大小,归档大小日志计算
  17. 【Python篇】拟牛顿法面面俱到(一)--牛顿插值法
  18. WARNING:tensorflow:`add_update` `inputs` kwarg has been deprecated.
  19. 计算机(了解)\注释\变量\数据类型\格式化输出\debug
  20. python3-excel数据填充

热门文章

  1. keil3如何放大字体_国潮海报不会做?送你国风字体+图案笔刷+PSD素材+包装样机...
  2. 剑指offer:39-42记录
  3. 学点数学(2)-特征函数
  4. 剑指offer_04
  5. python求小于n的所有素数_用python求出2000000内所有素数的和?不知怎么写?
  6. Java命令:jstat — 查看JVM的GC信息
  7. 移动流媒体业务的技术与标准
  8. windows平台下vlc编译
  9. 视频中场的问题2009-04-03 19:38(一)
  10. MPEG-2TS码流编辑的原理及其应用(转载