赞
踩
服务器规划:
node1:192.168.137.90(主)
node2:192.168.137.91(备)
VIP:192.168.137.99
一.首先在node1和node2上安装好数据库
安装过程略。
二、node1配置(主)
1.首先在node1上创建归档目录
mkdir /home/kingbase/KingbaseES/archive
2.配置kingbase.conf ,打开归档以及备机只读
- #开启归档
-
- log_archive_start = on
-
- log_archive_dest = '/home/kingbase/KingbaseES/archive'
-
- #开启备机只读 hot_standby=on
-
- wal_level='hot_standby'
3. 将node1数据库data目录打包拷贝到node2
tar czvf data.tbz data scp data.tbz 192.168.137.91:/home/kingbase/KingbaseES/
注:在node2从机上删除data目录,解压data.tbz
4.增加ifconfig文件的SUID和SGID,使普通用户运行ifconfig时暂时具备root权限,使用root用户执行
chmod u+s /sbin/ifconfig chmod g+s /sbin/ifconfig
注:Dataguard和kingbase运行在普通用户模式下,普通用户没有设置和删除IP的权限,IP浮动过程中,需要设置和删除IP,因此,如果需要浮动IP功能,需要增加普通用户设置和删除IP的权限。
5.standby配置
将standby.conf拷贝到数据库安装目录的config下
cp /home/kingbase/KingbaseES/bin/template/standby.conf /home/kingbase/KingbaseES/config/
编辑standby.conf ,内容如下:
- [standby]
- managed = false
- is_debug = false
- log_timestamp = true
- local_server_port = 54322
- remote_server_ip = 192.168.137.91
- 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 = ""
- floatip_readonly_delcmd = ""
- floatip_readwrite_addcmd = "bash /home/kingbase/KingbaseES/addip.sh"
- floatip_readwrite_delcmd = "bash /home/kingbase/KingbaseES/delip.sh"
- [kingbase]
- managed = false
- lifecheck_interval = 2
- kingbase_log = "kingbase-%w.log"
- bin_dir = "/home/kingbase/KingbaseES/bin"
- data_dir = "/home/kingbase/KingbaseES/data"
- log_archive_dest = "/home/kingbase/KingbaseES/archive"
- primary_conninfo = "host=192.168.137.91 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 = "echo 1 >> /home/kingbase/KingbaseES/data/kingbase.txt && ping -c 1 -w 1 192.168.137.1 >/home/kingbase/KingbaseES/log/checkalive.log 2>&1"
- 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$"
6.设置双机管理用户名\密码
./standby -UKLS -WKLS
三、node2配置(备)
1.首先在node1上创建归档目录
mkdir /home/kingbase/KingbaseES/archive
2.解压从node1上拷贝过来的data.tbz
tar xvf data.tbz
3.增加ifconfig文件的SUID和SGID,使普通用户运行ifconfig时暂时具备root权限,使用root用户执行
chmod u+s /sbin/ifconfig chmod g+s /sbin/ifconfig
注:Dataguard和kingbase运行在普通用户模式下,普通用户没有设置和删除IP的权限,IP浮动过程中,需要设置和删除IP,因此,如果需要浮动IP功能,需要增加普通用户设置和删除IP的权限。
4.standby配置
将standby.conf拷贝到数据库安装目录的config下
cp /home/kingbase/KingbaseES/bin/template/standby.conf /home/kingbase/KingbaseES/config/
编辑standby.conf ,内容如下:
- [standby]
- managed = false
- is_debug = false
- log_timestamp = true
- local_server_port = 54322
- remote_server_ip = 192.168.137.90
- 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 = ""
- floatip_readonly_delcmd = ""
- floatip_readwrite_addcmd = "bash /home/kingbase/KingbaseES/addip.sh"
- floatip_readwrite_delcmd = "bash /home/kingbase/KingbaseES/delip.sh"
- [kingbase]
- managed = false
- lifecheck_interval = 2
- kingbase_log = "kingbase-%w.log"
- bin_dir = "/home/kingbase/KingbaseES/bin"
- data_dir = "/home/kingbase/KingbaseES/data"
- log_archive_dest = "/home/kingbase/KingbaseES/archive"
- primary_conninfo = "host=192.168.137.90 port=54321"
- parallel_recover_threads = 1
- local_kingbase_cmdport = 54323
- protection_mode = maxperformance
- send_taillog = true
- retrytimes = 0
- [network]
- managed = true
- startlevel = 99
- stoplevel = 0
- checkalive = "echo 1 >> /home/kingbase/KingbaseES/data/kingbase.txt && ping -c 1 -w 1 192.168.137.1 >/home/kingbase/KingbaseES/log/checkalive.log 2>&1"
- 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$"
5.设置双机管理用户名\密码
./standby -UKLS -WKLS
四、Standby双机集群启动
1.使用root用户将standby7d文件拷贝到主备机的/etc/init.d文件夹下
cp /home/kingbase/KingbaseES/bin/standby7d /etc/init.d/
2.主备机添加启动和关闭浮动IP的脚本
在路径/home/kingbase/KingbaseES/下,和standby.conf配置文件里面要一致,注意增加执行权限。
addip.sh
- #!/bin/bash
- c1=`/sbin/ifconfig | grep 192.168.137.99 | wc -l`
- if [ $c1 -gt 0 ];then
- echo "float ip is on"
- else
- /sbin/ifconfig ens33:0 192.168.137.99 netmask 255.255.255.0 up
- echo "float ip is on now"
- fi
delip.sh
- #!/bin/bash
- c1=`/sbin/ifconfig | grep 192.168.137.99 | wc -l `
- if [ $c1 -gt 0 ];then
- /sbin/ifconfig ens33:0 down
- echo "float ip is down"
- else
- echo "float ip is down now"
- fi
3.启动主备机
首次启动standby服务,需要先启动主机standby控制器,然后再启动从机standby控制器。
/etc/init.d/standby7d start
注:使用root用户
常用指令
首先./istandby -UKLS -WKLS登陆
get all status #查看standby状态
switch over # 手动切换主从
五、部署standby观察器
注:主备机都需要部署
1.编辑/home/kingbase/KingbaseES/config/observer.conf,内容如下
- [observer]
- server_ip_1 = '192.168.137.90'
- server_ip_2 = '192.168.137.91'
- server_port_1 = 54322
- server_port_2 = 54322
- server_timeout = 10
- network_timeout = 10
- log_directory = '/home/kingbase/KingbaseES/log/observer.log'
- query_interval = 1
- TCP = 54324
2.启动观察期
./observer &
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。