KingbaseES数据库部署及双机热备配置
-
Dataguard双机热备部署
注:配置期间使用数据库的属主用户进行操作
1.1 数据一致性准备
(1)修改数据库的配置文件参数:(2阶段初始化的数据库实例)
创建在归档日志存放目录(需要根据机器的存储空间进行创建,空间大于100GB):
1
2
3
4
5
6
7
8
|
mkdir
/datas_local/archive
vim
/DBDATA/data/kingbase.conf
打开归档:
log_archive_start
= on
log_archive_dest =
'/datas_local/archive'
--目录根据操作系统服务器存储设置
|
备机只读设置:
1
2
|
hot_standby=on
wal_level=
'hot_standby'
|
使用kingbase用户操作
1
2
3
4
5
6
7
8
9
|
1、将从机指定数据目录下的(/DBDATA)data目录删除;
2、将主机指定数据目录下的(/DBDATA)data目录打包压缩:tar –czvf data.tbz data
3、将主机指定数据目录下的(/home/kingbase/KingbaseES)的data.tbz复制到从机指定路径下(/DBDATA)。
主机IP:10.150.73.182 从机IP:10.150.73.187
4、 在从机上指定目录(/DBDATA)解压数据文件data.tbz,生成本地数据目录:tar
-xzvf data.tbz;
(2) 增加ifconfig文件的SUID和SGID,使普通用户运行ifconfig时暂时具备root权限。
chmod u+s /sbin/ifconfig
chmod g+s /sbin/ifconfig
|
1.2 Dataguard配置文件准备
1、先配置主机,再配置从机;
1
2
3
4
5
6
|
将/home/kingbase/KingbaseES/bin/
template
/standby.conf分别拷贝到主备数据库安装目录的config下,并进行修改;
A机外网IP:10.150.73.182
A机私网IP:10.10.10.1
B机外网IP:10.150.73.187
B机私网IP:10.10.10.2
浮动ip:10.150.73.189
|
主机OS配置:
Dataguard和kingbase运行在普通用户模式下,普通用户没有设置和删除IP的权限,IP浮动过程中,需要设置和删除IP,因此,如果需要浮动IP功能,需要增加普通用户设置和删除IP的权限。方法示例:
增加ifconfig文件的SUID和SGID,使普通用户运行ifconfig时暂时具备root权限,使用root用户执行:
1
2
|
chmod u+s /sbin/ifconfig
chmod g+s /sbin/ifconfig
|
注:IP地址随环境准备配置
-
主机
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
|
[standby]
managed =
false
is_debug =
false
log_timestamp =
true
local_server_port = 54322
remote_server_ip = 10.10.10.2
remote_server_port =
54322
log_dir =
'/home/kingbase/KingbaseES/log'
standby_log =
"standby-%w.log"
server_mode =
'primary'
kingbase_fault_num =
0
enable_float_ip =
true
floatip_readonly_addcmd
= '/sbin/ifconfig
eth0:0 10.150.73.188/24'
floatip_readonly_delcmd
= '/sbin/ifconfig
eth0:0 down'
floatip_readwrite_addcmd
= '/sbin/ifconfig
eth0:0 10.150.73.189/24'
floatip_readwrite_delcmd
= '/sbin/ifconfig
eth0:0 down'
[kingbase]
managed =
false
lifecheck_interval =
2
kingbase_log =
"kingbase-%w.log"
bin_dir =
'/home/kingbase/KingbaseES/bin'
data_dir =
'/DBDATA/data'
log_archive_dest =
'/datas_local/archive'
primary_conninfo =
'host=10.10.10.2 port=54321'
parallel_recover_threads =
1
local_kingbase_cmdport =
54323
protection_mode
= maxprotection --同步模式(maxperformance异步模式)
send_taillog =
true
retrytimes = 0
[network]
managed =
true
startlevel = 99
stoplevel = 0
checkalive = 'touch
/DBDATA/kingbase/kingbase.txt && ping -c 1 -w 1 10.150.73.190
1>/dev/null 2>/dev/null'
checkinterval = 5
checkfails = 3
hotstandby =
false
startcmd =
""
stopcmd =
""
needswitch =
true
retrytimes = 0
retrycmd =
""
[klogminer]
managed =
false
startlevel = 99
stoplevel = 0
checkalive = "kdb_logminerd
status"
checkinterval = 3
checkfails = 1
hotstandby =
false
startcmd = "kdb_logminerd
start $MODE$"
stopcmd = "kdb_logminerd
stop $PID$"
needswitch =
true
retrytimes = 0
retrycmd = "kdb_logminerd
restart $FAILEDTIMES$"
|
-
备机
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
|
[standby]
managed =
false
is_debug =
false
log_timestamp =
true
local_server_port = 54322
remote_server_ip = 10.10.10.1
remote_server_port =
54322
log_dir =
'/home/kingbase/KingbaseES/log'
standby_log =
"standby-%w.log"
server_mode =
'standby'
kingbase_fault_num =
0
enable_float_ip =
true
floatip_readonly_addcmd
= '/sbin/ifconfig
eth0:0 10.150.73.188/24'
floatip_readonly_delcmd
= '/sbin/ifconfig
eth0:0 down'
floatip_readwrite_addcmd
= '/sbin/ifconfig
eth0:0 10.150.73.189/24'
floatip_readwrite_delcmd
= '/sbin/ifconfig
eth0:0 down'
[kingbase]
managed =
false
lifecheck_interval =
2
kingbase_log =
"kingbase-%w.log"
bin_dir =
'/home/kingbase/KingbaseES/bin'
data_dir =
'/DBDATA/data'
log_archive_dest =
'/datas_local/archive'
primary_conninfo =
'host=10.10.10.1 port=54321'
parallel_recover_threads =
1
local_kingbase_cmdport =
54323
protection_mode = maxprotection
send_taillog =
true
retrytimes = 0
[network]
managed =
true
startlevel = 99
stoplevel = 0
checkalive = ' touch
/DBDATA/kingbase/kingbase.txt && ping -c 1 -w 1 10.150.73.190
1>/dev/null 2>/dev/null '
checkinterval = 5
checkfails = 3
hotstandby =
false
startcmd =
""
stopcmd =
""
needswitch =
true
retrytimes = 0
retrycmd =
""
[klogminer]
managed =
false
startlevel = 99
stoplevel = 0
checkalive = "kdb_logminerd
status"
checkinterval = 3
checkfails = 1
hotstandby =
false
startcmd = "kdb_logminerd
start $MODE$"
stopcmd = "kdb_logminerd
stop $PID$"
needswitch =
true
retrytimes = 0
retrycmd = "kdb_logminerd
restart $FAILEDTIMES$"
|
Dataguard双机集群启动
上述配置工作完成之后,首次启动standby服务,需要先启动主机standby控制器,然后再启动从机standby控制器;
使用kingbase用户进入目录/home/kingbase/KingbaseES/bin设置双机管理用户名\密码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
./standby –UKLS –WKLS ——主备机都需要进行设置
使用root用户将/home/kingbase/KingbaseES/bin/standby7d文件拷贝到主备机的/etc/init.d文件夹下;
先启动主机:
使用root用户:/etc/init.d/standby7d start
启动备机:/etc/init.d/standby7d start
istandby登陆:
./istandby
–UKLS –WKLS
查看standby状态:get all status
停止控制器监听:stop listener
切换主从状态:swich over
如果配置正确,主从机网络正常。启动主从机standby后,主从机自动识别各自模式状态:主机为primary,从机为standby,通过客户端连接主机数据库,可以连接成功正常访问,
客户端连接从机数据库,不能正常访问,提示“处于standby模式的数据库系统不能接受连接”。
|
-
Dataguard观察器
观察器配置部署(主备机都需要配置并启动)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
cd /home/kingbase/KingbaseES/config
vim
observer.conf
[observer]
server_ip_1 =
'10.150.73.182'
----外网的IP地址
server_ip_2 =
'10.150.73.187'
server_port_1 = 54322
server_port_2 = 54322
server_timeout = 10
network_timeout = 10
log_directory =
'/home/kingbase/KingbaseES/observer.log'
query_interval = 1
TCP = 54324
启动观察器:
./observer &
|
本文转自 dbapower 51CTO博客,原文链接:http://blog.51cto.com/suifu/1618572,如需转载请自行联系原作者