centos 6.8安装postgresql9.6.9实战
centos 6.8安装postgresql9.6.9实战一、安装前准备
系统:centos 6.8
服务器IP:192.168.1.211
修改SELINUX=disabled
vi /etc/selinux/config
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/2a94d0cf1a63464db1a686d7f7f409fc/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400365110261.png
关闭防火墙或者把5432端口允许开放
/etc/init.d/iptables stop
chkconfig iptables off
二、部署postgresql环境
2.1 安装依赖包
yum -y install gcc* readline-devel wget
2.2创建用户设置密码
adduser postgres
passwd postgres
2.3下载postgresql安装
wget https://ftp.postgresql.org/pub/source/v9.6.9/postgresql-9.6.9.tar.gz
tar zxvf postgresql-9.6.9.tar.gz
cd postgresql-9.6.9
./configure --prefix=/home/postgres/pgsql
gmake
gmake install
2.4 设置环境变量
vi /etc/profile
到最后行下面添加
###postgresql
PATH=$PATH:$HOME/bin:/home/postgres/pgsql/bin
环境生效
source /etc/profile
2.5创建数据目录赋权
mkdir /home/postgres/pgsql/data
touch /home/postgres/pgsql/.pgsql_history
chown -R postgres:postgres /home/postgres/pgsql
2.6初始化数据库
su - postgres
/home/postgres/pgsql/bin/initdb -D /home/postgres/pgsql/data
退出
exit
2.7修改启动脚本
cp /root/postgresql-9.6.9/contrib/start-scripts/linux /etc/init.d/postgresql
vi /etc/init.d/postgresql
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/11f368a3228f48b9aa144be41e460124/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400392557424.png
保存退出
增加执行权限
chmod +x /etc/init.d/postgresql
启动postgresql
/etc/init.d/postgresql start
2.8测试postgresql
su - postgres
$ psql
psql (9.6.9)
Type "help" for help.
postgres=# \l
List of databases
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 rows)
postgres=# \q
创建数据库名为ybdb
createdbybdb
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/7e4a3e93a64944638b2c384708d40567/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400413987358.png
2.9 修改postgresql.conf
vi pgsql/data/postgresql.conf
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/9d746d4b3f4d42c3a90cd7c51f857755/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400581853662.png
重启postgresql
/etc/init.d/postgresql restart
2.10 增加用户并赋权
create user ybdba WITH PASSWOD 'ybdba#2018';
GRANT ALL PRIVILEGES ON DATABASE ybdb TO ybdba;
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/30cf644a1aa340b18ccbefd1a4bc56ec/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400595114286.png
远程登录postgresql
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/f2499c94387e46b88902728982e5b45b/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400656458039.png
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/1c9e5a363df64b009b0cf0618d061e04/clipboard.png
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/2fae469942104a949676908074fc2400/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400668540783.png
http://s1.运维网.com/images/20180816/1534400678745104.png
出现以上图错误 就修改ph_ha.conf
2.11 修改ph_ha.conf
注意:我的本地IP是192.168.1.79
vipgsql/data/pg_hba.conf
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/68d669bfa2fb493681303fac39a43c0d/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400684795918.png
用户超级用户运行SELECT pg_reload_conf();
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/9be3d6258f7c4356b385d257fc2b3c26/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400693714386.png
远程登录成功
http://blog.运维网.com/jxzhfei/C:/Users/yibao-design/AppData/Local/YNote/data/zhf506700723@163.com/4ab411b5×××41fc88e43524ab55b526/clipboard.pnghttp://s1.运维网.com/images/20180816/1534400705789767.png
页:
[1]