HA 实现方式:
热备份、冷备份
冷备份:物理备份,也就是文件复制。主机写完一个WAL日志文件后,才复制到standby服务器上去应用。
热备份:流复制,也就是同步复制或异步复制。主备机实时同步。
一主两从操作步骤:
在三台机器分别按照步骤1-4安装pg数据包
1、 安装
./configure –prefix=/usr/pgsql9.3.4 –with-perl –with-openssl –with-pam –without-ldap –with-libxml –with-libxslt –enable-thread-safety –with-wal-blocksize=16 –with-blocksize=16
make world
make install-world
2、添加用户
groupadd postgres
useradd -g postgres postgres
passwd postgres
3、修改内核参数
vim /etc/sysctl.conf
#Kernel paramaters required by Postgresql
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144
sysctl -p
vim /etc/security/limits.conf
postgres soft nproc 16384
postgres hard nproc 16384
postgres soft nofile 65536
postgres hard nofile 65536
4、增加.bash_profile环境变量
export PGHOME=/usr/pgsql9.3.4
export PATH=PGHOME/bin:PATH:.
export MANPATH=PGHOM@H_404_121@E/share/man:
MANPATH
5、主:172.18.18.99
su - postgres
123
1》mkdir /data/pgdata/pg_primary
2》mkdir /data/pgdata/pg_primary_data
3》/usr/pgsql9.3.4/bin/initdb -D /data/pgdata/pg_primary/ -E UTF8 –locale=C -U postgres -W
4》数据库参数
postgresql.conf//修改port等等(直接拿99开发机配置库配置文件替换)
pg_hba.conf //修改如下
修改pg_hba.conf:(METHOD 和 最后一项ADDRESS)
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 l