centos 6.8安装postgresql9.6.9实战
admin
2023-05-20 22:22:56
0

centos 6.8安装postgresql9.6.9实战

一、安装前准备

系统:centos 6.8

服务器IP:192.168.1.211

修改SELINUX=disabled

vi /etc/selinux/config

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

关闭防火墙或者把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

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

保存退出

增加执行权限

chmod +x /etc/init.d/postgresql

启动postgresql

/etc/init.d/postgresql start

2.8测试postgresql

su - postgres

[postgres@post01 ~]$ 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

createdb  ybdb

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

2.9 修改postgresql.conf

vi pgsql/data/postgresql.conf

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

重启postgresql

/etc/init.d/postgresql restart

2.10 增加用户并赋权

create user ybdba WITH PASSWOD 'ybdba#2018';

GRANT ALL PRIVILEGES ON DATABASE ybdb TO ybdba;

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

远程登录postgresql

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

centos 6.8安装postgresql9.6.9实战

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

centos 6.8安装postgresql9.6.9实战

出现以上图错误 就修改ph_ha.conf

2.11 修改ph_ha.conf

注意:我的本地IP是192.168.1.79

vi  pgsql/data/pg_hba.conf

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

用户超级用户运行SELECT pg_reload_conf();

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战

远程登录成功

centos 6.8安装postgresql9.6.9实战centos 6.8安装postgresql9.6.9实战


相关内容

热门资讯

汇艺银河里首届微醺节圆满收官 ... 多元业态协同联动,探索郑东商圈夜间消费新场景首届汇艺银河里微醺节圆满收官。活动立足郑州高铁东站商圈核...
西班牙警方:约7.35万名移民... △8月3日,西班牙北非飞地休达,从摩洛哥入境的移民聚集在海滩上。当地时间8月3日,西班牙警方表示,约...
美军称继续海上封锁伊朗,已改变... 当地时间8月3日,美国中央司令部表示,美军继续严格执行对伊朗的海上封锁。截至当天,美军已改变44艘商...
“控制”格陵兰岛,特朗普罕见列... 据美国《新闻周刊》和英国《独立报》8月2日报道,美国总统特朗普日前在接受采访时声称,格陵兰岛将在他本...
脑机接口,新突破,深度布局的1... (来源:逍遥财情) 8月1日,两项关于脑机接口行业的新国家标准开始实施,这两项标准相当于为整个行业制...
特朗普:与伊朗的谈判已开始,计... 当地时间8月3日,美国总统特朗普在社交平台“真实社交”(Truth Social)发文称,与伊朗的谈...
唐山电缆测绘现场案例 唐山电缆测绘现场案例 探测背景: 本次服务对象为唐山某测绘公司,因后期甲方需开展开挖作业,需提前明确...
聚焦能源与前沿科技!山西启动重... 为持续完善全省科技创新平台体系,夯实基础研究根基、打通科技成果产业化链条,加快培育新质生产力,赋能全...
四川:到2026年底推动阿里云... 《四川省推进算力设施优化布局提质建设和算电融合发展实施方案(2026—2028年)》近日印发。其中提...
瑙鲁正式更改国名 △瑙鲁(资料图)瑙鲁共和国政府日前在社交媒体上发布公告说,该国国名已由“Nauru”正式更改为“Na...