xa_rdmp 主数据库安装
初始化数据库
su postgres
/xa-rdmp/program/pgsql/bin/initdb -E utf8 -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data
启动数据库
/xa-rdmp/program/pgsql/bin/pg_ctl -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data -l /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/log/postgres.log start
停止数据库
/xa-rdmp/program/pgsql/bin/pg_ctl -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data -l /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/log/postgres.log stop
重启数据库
/xa-rdmp/program/pgsql/bin/pg_ctl -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data -l /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/log/postgres.log restart
创建库及用户
su postgres
/xa-rdmp/program/pgsql/bin/psql
create user pgsql superuser password 'ssrdmp88';
create database "xa-rdmp" with encoding='utf8' owner=pgsql;
create database "xa-1.0" with encoding='utf8' owner=pgsql;
create user repl superuser password 'ssrdmp88_repl';
\q
配置修改为支持流复制(主从)
vi /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data/pg_hba.conf
修改内容为
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 0.0.0.0/0 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host replication all 127.0.0.1/32 md5
host replication repl 127.0.0.1/32 md5
host replication all ::1/128 md5
host replication repl ::1/128 md5
vi /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data/postgresql.conf
修改以下几项,并把配置项前面的 # 号去掉
listen_addresses = '*'
wal_level = hot_standby
max_wal_senders = 4
wal_keep_segments = 64
hot_standby = on
constraint_exclusion = partition
重启数据库后,就能远程连接了
/xa-rdmp/program/pgsql/bin/pg_ctl -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data -l /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/log/postgres.log restart
添加为自启动
vi /etc/rc.local
增加一行
su - postgres -c '/xa-rdmp/program/pgsql/bin/pg_ctl -D /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/data -l /xa-rdmp/user/data/pgsql/xa-rdmp-master-1/log/postgres.log start'
设置执行权限
chmod 755 /etc/rc.local