新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

centos6.8安装postgresql9.6.9实战-创新互联

centos 6.8安装postgresql9.6.9实战

成都创新互联公司是一家以网站建设、网页设计、品牌设计、软件运维、网站推广、小程序App开发等移动开发为一体互联网公司。已累计为石凉亭等众行业中小客户提供优质的互联网建站和软件开发服务。

一、安装前准备

系统: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安装

wgethttps://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实战

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网页标题:centos6.8安装postgresql9.6.9实战-创新互联
本文链接:http://www.wjwzjz.com/article/dggdhi.html
在线咨询
服务热线
服务热线:028-86922220
TOP