forked from digoal/PostgreSQL_HA_with_primary_standby_2vip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbase_config.txt
85 lines (63 loc) · 2.49 KB
/
base_config.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
基础配置 :
# 注意配置归档, keep, recovery.conf(restore_command), nfs, mount
# visudo -f /etc/sudoers
# postgres ALL=(ALL) NOPASSWD: /sbin/ifup
# postgres ALL=(ALL) NOPASSWD: /sbin/ifdown
# postgres ALL=(ALL) NOPASSWD: /sbin/arping
# postgres ALL=(ALL) NOPASSWD: /bin/mount
# postgres ALL=(ALL) NOPASSWD: /bin/umount
# 注释 #Defaults requiretty
# 脚本中用sudo调的命令请使用绝对路径
# fence脚本大部分在cman包中
# yum install -y cman
配置postgres用户的ssh无密钥认证 (HOST1, HOST2)
# vi /etc/ssh/sshd_config
PubkeyAuthentication yes
# service sshd restart
# su - postgres
$ ssh-keygen -t rsa
不要输入passphrase
$ cd ~/.ssh
$ 将 id_rsa.pub 内容拷贝到对方主机的postgres用户下的 ~/.ssh/authorized_keys
$ chmod 600 ~/.ssh/authorized_keys
# 验证无密码配置是否正确
ssh 192.168.111.42 date
Sun Jan 4 15:54:26 CST 2015
ssh 192.168.111.37 date
Sun Jan 4 15:54:26 CST 2015
# 可能的话, 请使用固定的nfs端口
nfs :
# vi /etc/exports
/opt/arch 192.168.111.42/24(ro,no_root_squash,sync)
/opt/arch 192.168.111.37/24(ro,no_root_squash,sync)
# chkconfig nfs on
# service nfs start
peer 归档DIR :
# mkdir /opt/peer_arch
postgresql.conf
数据库归档命令 :
archive_command = 'DIR=/opt/arch/`date +%F`; test ! -d $DIR && mkdir -p $DIR && chmod 755 $DIR; test ! -f $DIR/%f && cp %p $DIR/%f; chmod 755 $DIR/%f'
recovery.conf
恢复命令 :
restore_command = 'PEER_DIR=/opt/peer_arch; cp $PEER_DIR/*/%f %p'
recovery_target_timeline = 'latest'
standby_mode = on
primary_conninfo = 'host=192.168.111.130 port=1921 user=replica keepalives_idle=60'
密码文件 :
# su - postgres
$ vi ~/.pgpass
192.168.111.130:1921:replication:replica:replica
192.168.111.130:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
192.168.111.131:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
192.168.111.37:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
192.168.111.42:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
127.0.0.1:1921:sky_pg_cluster:sky_pg_cluster:SKY_PG_cluster_321
$ chmod 400 ~/.pgpass
# fence命令在sky_pg_cluster.sh fence函数中, 不同的主机, fence需要修改sky_pg_cluster.sh进行定制
# 无限fence, 加参数 force, 加其他参数不强制fence
# ipmitool -I lanplus -L OPERATOR -H $IP -U $USER -P $PWD power reset
# fence_rsa -a $IP -l $USER -p $PWD -o reboot
# fence_ilo -a $IP -l $USER -p $PWD -o reboot
# Author : Digoal zhou
# Email : [email protected]
# Blog : http://blog.163.com/digoal@126/