当前位置:   article > 正文

Kingbase7.1.2 standby 集群部署_es7.1集群搭建

es7.1集群搭建

服务器规划:

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 ,打开归档以及备机只读
 

  1. #开启归档
  2. log_archive_start = on
  3. log_archive_dest = '/home/kingbase/KingbaseES/archive'
  4. #开启备机只读 hot_standby=on
  5. 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 ,内容如下:

  1. [standby]
  2. managed = false
  3. is_debug = false
  4. log_timestamp = true
  5. local_server_port = 54322
  6. remote_server_ip = 192.168.137.91
  7. remote_server_port = 54322
  8. log_dir = "/home/kingbase/KingbaseES/log"
  9. standby_log = "standby-%w.log"
  10. server_mode = 'primary'
  11. kingbase_fault_num = 0
  12. enable_float_ip = true
  13. floatip_readonly_addcmd = ""
  14. floatip_readonly_delcmd = ""
  15. floatip_readwrite_addcmd = "bash /home/kingbase/KingbaseES/addip.sh"
  16. floatip_readwrite_delcmd = "bash /home/kingbase/KingbaseES/delip.sh"
  17. [kingbase]
  18. managed = false
  19. lifecheck_interval = 2
  20. kingbase_log = "kingbase-%w.log"
  21. bin_dir = "/home/kingbase/KingbaseES/bin"
  22. data_dir = "/home/kingbase/KingbaseES/data"
  23. log_archive_dest = "/home/kingbase/KingbaseES/archive"
  24. primary_conninfo = "host=192.168.137.91 port=54321"
  25. parallel_recover_threads = 1
  26. local_kingbase_cmdport = 54323
  27. protection_mode = maxprotection
  28. send_taillog = true
  29. retrytimes = 0
  30. [network]
  31. managed = true
  32. startlevel = 99
  33. stoplevel = 0
  34. 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"
  35. checkinterval = 5
  36. checkfails = 3
  37. hotstandby = false
  38. startcmd = ""
  39. stopcmd = ""
  40. needswitch = true
  41. retrytimes = 0
  42. retrycmd = ""
  43. [klogminer]
  44. managed = false
  45. startlevel = 99
  46. stoplevel = 0
  47. checkalive = "kdb_logminerd status"
  48. checkinterval = 3
  49. checkfails = 1
  50. hotstandby = false
  51. startcmd = "kdb_logminerd start $MODE$"
  52. stopcmd = "kdb_logminerd stop $PID$"
  53. needswitch = true
  54. retrytimes = 0
  55. 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 ,内容如下:

  1. [standby]
  2. managed = false
  3. is_debug = false
  4. log_timestamp = true
  5. local_server_port = 54322
  6. remote_server_ip = 192.168.137.90
  7. remote_server_port = 54322
  8. log_dir = "/home/kingbase/KingbaseES/log"
  9. standby_log = "standby-%w.log"
  10. server_mode = 'standby'
  11. kingbase_fault_num = 0
  12. enable_float_ip = true
  13. floatip_readonly_addcmd = ""
  14. floatip_readonly_delcmd = ""
  15. floatip_readwrite_addcmd = "bash /home/kingbase/KingbaseES/addip.sh"
  16. floatip_readwrite_delcmd = "bash /home/kingbase/KingbaseES/delip.sh"
  17. [kingbase]
  18. managed = false
  19. lifecheck_interval = 2
  20. kingbase_log = "kingbase-%w.log"
  21. bin_dir = "/home/kingbase/KingbaseES/bin"
  22. data_dir = "/home/kingbase/KingbaseES/data"
  23. log_archive_dest = "/home/kingbase/KingbaseES/archive"
  24. primary_conninfo = "host=192.168.137.90 port=54321"
  25. parallel_recover_threads = 1
  26. local_kingbase_cmdport = 54323
  27. protection_mode = maxperformance
  28. send_taillog = true
  29. retrytimes = 0
  30. [network]
  31. managed = true
  32. startlevel = 99
  33. stoplevel = 0
  34. 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"
  35. checkinterval = 5
  36. checkfails = 3
  37. hotstandby = false
  38. startcmd = ""
  39. stopcmd = ""
  40. needswitch = true
  41. retrytimes = 0
  42. retrycmd = ""
  43. [klogminer]
  44. managed = false
  45. startlevel = 99
  46. stoplevel = 0
  47. checkalive = "kdb_logminerd status"
  48. checkinterval = 3
  49. checkfails = 1
  50. hotstandby = false
  51. startcmd = "kdb_logminerd start $MODE$"
  52. stopcmd = "kdb_logminerd stop $PID$"
  53. needswitch = true
  54. retrytimes = 0
  55. 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

  1. #!/bin/bash
  2. c1=`/sbin/ifconfig | grep 192.168.137.99 | wc -l`
  3. if [ $c1 -gt 0 ];then
  4. echo "float ip is on"
  5. else
  6. /sbin/ifconfig ens33:0 192.168.137.99 netmask 255.255.255.0 up
  7. echo "float ip is on now"
  8. fi

delip.sh

  1. #!/bin/bash
  2. c1=`/sbin/ifconfig | grep 192.168.137.99 | wc -l `
  3. if [ $c1 -gt 0 ];then
  4. /sbin/ifconfig ens33:0 down
  5. echo "float ip is down"
  6. else
  7. echo "float ip is down now"
  8. 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,内容如下

  1. [observer]
  2. server_ip_1 = '192.168.137.90'
  3. server_ip_2 = '192.168.137.91'
  4. server_port_1 = 54322
  5. server_port_2 = 54322
  6. server_timeout = 10
  7. network_timeout = 10
  8. log_directory = '/home/kingbase/KingbaseES/log/observer.log'
  9. query_interval = 1
  10. TCP = 54324

2.启动观察期

./observer &

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/980347
推荐阅读
相关标签
  

闽ICP备14008679号