网上出现的比较多安装方法要么是源码安装,要么是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. Django web 开发指南 no such table:

    在学习django web开发指南时,发布新博客点击save后会有error提示:no such table balabalabala... 百度了一下说重新运行manage.py syncdb 就可 ...

  2. iOS分类中通过runtime添加动态属性

    这个的话并不是说  可以  在程序运行的时候   来几个 未知的东西  就添加什么  1 2 3 4 5的属性.而是可以在系统原有类的基础上  给那个类 集合实际的工程来添加你方便实用的东西.比如   ...

  3. AD RMS Bulk Protection Tool 批量加密解密office文档

    1.Active Directory Rights Management Services Bulk Protection Tool  http://www.microsoft.com/zh-cn/d ...

  4. keychain 多应用共享数据

    地址:http://blog.csdn.net/jerryvon/article/details/16843065 补充: 若plist跟项目不在同一级目录下,可通过XXX/xxx.plist的方式设 ...

  5. 启用EXCHANGE反垃圾邮件功能和重建EXCHANGE邮件系统帐号

    How to recreate System Mailbox , FederatedEmail & DiscoverySearchMailbox in Exchange 2010 http:/ ...

  6. Android 通过代码设置radiobutton不同方位图标的两种方法

    更换radiobutton中的图片在xml中很好设置,但对于初学者如何在代码中设置还是不容易找的.没法子,通过看原版api找到两个方法,setCompoundDrawables和setCompound ...

  7. 用JAVA 查询 Active Directory(AD)

    Required Details LDAP address (For e.g.: myjeeva.com or IP of the Domain Controller/Global Catalog[G ...

  8. ASP.NET MVC 解决LINQ表达式中的SqlMethods 未找到命名空间问题

    右键项目属性下的引用: 添加引用: 搜索寻找——System.Data.Linq,然后添加成功,即可解决LINQ表达式中的SqlMethods 未找到命名空间问题

  9. 转: 二十八、Java图形化界面设计——中间容器(Jpanel)

    http://blog.csdn.net/liujun13579/article/details/7762835 上一篇讲解了Jframe顶层容器,例子中生成了一个空的窗体,在实际编程过程中,一般很少 ...

  10. Vijos_1218_数字游戏_(划分型动态规划+环状动态规划)

    描述 https://vijos.org/p/1218 给出n个数围成一个环,将其划分成k个部分,每个部分求和再对10取模,最后将每个部分的值相乘,求其最大值与最小值. 描述 丁丁最近沉迷于一个数字游 ...