一、环境介绍
系统平台:CentOS 6.6版本(最终)
Postgresql: postgresql-9.6.6
禁用SELINUX=
Iptables关闭
二、安装过程
1。安装依赖包
yum -y install gcc * yum -y  install readline-devel
2。源码包获取
wget http://ftp.postgresql.org/pub/source/v9.6.6/postgresql-9.6.6.tar.gz
3。解压
tar zxf postgresql-9.6.6.tar.gz
5。创建用户,设置密码
adduser postgres passwd postgres
6。编译安装
cd postgresql-9.6.6 。/configure ——prefix=/home/postgres/pgsql gmake gmake 安装
7。设置环境变量
vim /etc/profile
添加一行
=$ PATH: $ HOME/bin:/HOME/postgres/pgsql/bin source /etc/profile
8。创建数据库目录
mkdir /home/postgres/pgsql/数据
创建数据库操作历史记录文件
touch /home/postgres/pgsql/gsql_history
更改所属组
chown -R postgres: postgres /home/postgres/pgsql/*
9。切换到postgre用户,初始化数据库
su 作用;postgres/home/postgres/pgsql/bin/initdb -D /home/postgres/pgsql/数据 退出
10。编译启动命令
从postgres解压后的文件夹里拷贝linux到/etc/init。d/
cp /根/postgresql-9.6.6/contrib/启动脚本/linux /etc/摆在postgresql vim /etc/init。d/postgresql
修改下面两行:
prefix=/home/postgres/pgsql PGDATA=https://www.yisu.com/zixun/?home/postgres/pgsql/数据”
保存退出
添加可执行权限
chmod + x /etc/摆在postgresql
11。启动postgres数据库
/etc/摆在/postgresql 开始
12。测试使用
[root@MidApp ~] # su 作用;postgres [postgres@MidApp ~]美元psql psql (9.6.6) 想Type “for 帮助。 postgres=# \ l ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,List of 数据库 ,,Name ,,, |,, Owner ,, |, Encoding |,,, Collate ,, |,,,, Ctype ,,, |,,, Access privileges ,, - - - - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ,postgres |, postgres |, UTF8 ,,,, |, en_US.utf-8 |, en_US.utf-8 |, |,template0 postgres |, UTF8 ,,,, |, en_US.utf-8 |, en_US.utf-8 |,=c/postgres ,,,,,,,,, + ,,,,,,,,,,|,,,,,,,,,,|,,,,,,,,,,|,,,,,,,,,,,,,|,,,,,,,,,,,,,|,postgres=CTc/postgres |,template1 postgres |, UTF8 ,,,, |, en_US.utf-8 |, en_US.utf-8 |,=c/postgres ,,,,,,,,, + ,,,,,,,,,,|,,,,,,,,,,|,,,,,,,,,,|,,,,,,,,,,,,,|,,,,,,,,,,,,,|,postgres=CTc/postgres (3,行) postgres=#, \ q