PostgreSQL10版本的主從安裝配置在 https://www.cnblogs.com/virtulreal/p/11675841.html
一、下載安裝
1、創建PostgreSQL9.6的yum源文件
$ yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-centos96-9.6-3.noarch.rpm
2、安裝PostgreSQL客戶端
$ yum install postgresql96
3、安裝PostgreSQL服務端
$ yum install postgresql96-server
4、安裝PostgreSQL拓展包(可選)
$ yum install postgresql96-devel.x86_64
5、安裝PostgreSQL的附加模塊(可選)
$ yum install postgresql96-contrib.x86_64
二、配置初始化
初始化數據庫
$ /usr/pgsql-9.6/bin/postgresql96-setup initdb
啟動postgresql服務,並設置為開機自動啟動
$ systemctl enable postgresql-9.6
$ systemctl start postgresql-9.6
postgres用戶初始配置
安裝完成后,操作系統會自動創建一個postgres用戶用來管理數據庫,為其初始化密碼(輸入命令后連輸2次密碼):
$ passwd postgres
數據庫初始配置
使用數據庫自帶的postgres用戶登錄數據庫,並為其賦予密碼
$ su - postgres
$ psql -U postgres
alter user postgres with password '你的密碼';
配置遠程連接
可能在/var/lib/pgsql/9.6/data下,可以
1、使用find / -name 'pg_hba.conf'查找到pg_hba.conf,修改pg_hba.conf
在最后添加允許訪問IP段(全網段可訪問)
host all all 0.0.0.0/0 md5
2、使用find / -name 'postgresql.conf'找到 postgresql.conf
找到用戶參數listen_address(取消掉注釋),改成下面樣式:
listen_address = '*'
啟用密碼驗證
#password_encryption = on 修改為 password_encryption = on
3、重啟數據庫
$ systemctl restart postgresql-9.6
備注:使用Navicat For PostgreSql來連接