1.添加RPM
yum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-redhat94-9.4-3.noarch.rpm
2.安装
sudo yum install postgresql94
sudo yum install postgresql94-server
3.初始化数据库
rpm -qa|grep postgresql
rpm -qal|grep postgresql
postgresql94-setup initdb
4.设置开机自启动
/usr/lib/systemd/system/
systemctl enable postgresql-9.4.service
5.启动服务
systemctl start postgresql-9.4.service
psql --version
6.登录操作
/var/lib/pgsql/9.4/data
cat postgresql.conf | grep -n listen_addresses
vim postgresql.conf- >listen_adreess
systemctl restrat postgresql-9.4.service
su - postgres
$1$jZUV5ccl$FLIBMZnCZzBKWDPxDz5y.0
psql -U postgres
passwd postgres(可以不操作)
select * from pg_roles;
select * from pg_user;
yum install https://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/repmgr94-4.1.1-1.rhel7.1.x86_64.rpm
yum install repmgr*
cd /usr/pgsql-9.4/share/
pg 安装小笔记:
ps -ef|grep postgres--找到配置文件\data
vim pg_hba.conf--local all all peer-->trust
systemctl restart postgresql-9.4.service
#su - postgres
psql -d postgres -U postgres -p 1523
#create a new superuser
create user pgdba superuser password 'pgdba';
#change user postgres passwd
alter role postgres password 'postgres';
#Create dispatcher user and grant dispatcher_db permissions to it
CREATE user dispatcher with password 'dispatcher';
#name: Create dispatcher database
CREATE DATABASE dispatcher owner dispatcher;
#Alter configure file
vim pg_hba.conf-->host {{ item.name }} {{ item.user }} 0.0.0.0/0 md5"
vim pg_hba.conf-->host dispatcher dispatcher 0.0.0.0/0 md5"
#Add db new_superuser client control policy
vim pg_hba.conf-->host all {{ new_superuser }} 0.0.0.0/0 md5
vim pg_hba.conf-->host all pgdba 0.0.0.0/0 md5'
name: Add db old_superuser client control policy
vim pg_hba.conf-->host all postgres 0.0.0.0/0 md5'
Change ansible config replace
vim pg_hba.conf-->trust -->md5
systemctl restart postgresql-9.4.service
/var/lib/pgsql/9.4/data
/usr/pgsql-9.4/bin
psql -d postgres -U postgres -p 1523
select * from pg_roles;
select * from pg_user;