KingbaseES V8R3集群部署案例之---通用机无ssh环境脚本部署集群
案例说明:
在一些通用机的生产环境,不允许主机之间通过ssh通讯,或者不允许root用户建立ssh互信或登录。默认KingbaseES V8R3集群通用机环境部署需要建立数据库用户及root用户,在集群节点之间建立ssh互信,如果生产环境不允许,可以使用集群自带的es_server工具建立节点之间的通讯,部署集群。
适用版本:
KingbaseES V8R3(本案例使用较新版本 V008R003C002B0370,较早版本不支持。)
集群节点信息:

一、部署集群软件环境
1、安装数据库软件(集群任一节点)

2、查看集群安装所需文件
# 如下所示,集群部署所需的压缩包
[kingbase@node101 Lin64]$ pwd
/opt/Kingbase/ES/V8R3_370/DeployTools/zip/Lin64
[kingbase@node101 Lin64]$ ls
db.zip kingbasecluster.zip
3、创建集群安装目录及分发集群所需文件(所有节点)
# 创建集群安装目录
[kingbase@node102 ~]$ mkdir -p /home/kingbase/cluster/HAR3/
# 分发安装包到集群安装目录下
[kingbase@node101 Lin64]$ cp *.zip /home/kingbase/cluster/HAR3/
[kingbase@node101 Lin64]$ cp /data/soft/license_V8R3_2022-01-04-365.dat /home/kingbase/cluster/HAR3/license.dat
[kingbase@node101 r3_install]$ ls -lh /home/kingbase/cluster/HAR3/
total 37M
-rw-r--r-- 1 kingbase kingbase 32M Sep 28 13:13 db.zip
-rw-r--r-- 1 kingbase kingbase 5.3M Sep 28 13:13 kingbasecluster.zip
-rw-r--r-- 1 kingbase kingbase 3.1K Sep 28 13:14 license.dat
4、解压集群部署压缩包
[kingbase@node101 HAR3]$ unzip db.zip
[kingbase@node101 HAR3]$ unzip kingbasecluster.zip
[kingbase@node101 HAR3]$ ls
db db.zip kingbasecluster kingbasecluster.zip license.dat
[kingbase@node101 db]$ ls
bin data es_server etc kb_scripts lib share
5、执行NEWHA.sh脚本(更新集群部署所需的脚本,以适用于es_server部署)
[kingbase@node101 es_server]$ sh NEWHA.sh
[CHECK] check old files in /home/kingbase/cluster/HAR3/db/bin ...
[INFO] /home/kingbase/cluster/HAR3/db/bin/install.conf exist, will rename it
......
[UPDATE] update files in /home/kingbase/cluster/HAR3/kingbasecluster ... OK
[UPDATE] DONE
二、部署和配置es_server服务环境(root用户)
1、查看es_server配置文件(es_server默认使用8890端口,可以修改此配置文件,更改端口号)
[kingbase@node101 share]$ cat esHA.conf
# it can be 'systemd' or 'crontab'
# systemd: start the es_server by service of systemctl
# crontab: start the es_server by crontab
start_method=systemd
# the port of es_server
# if it is null, will be default 8890
es_port=8890
2、初始化和启动es_server服务
[root@node101 bin]# sh esHAservice.sh --help
Usage: esHAservice.sh { init | start | stop | status }
# 初始化es_server服务环境
[root@node101 bin]# sh esHAservice.sh init
successfully initialized the es_server, please use "esHAservice.sh start" to start the es_server
[root@node101 bin]# sh esHAservice.sh start
Created symlink from /etc/systemd/system/multi-user.target.wants/es_server.service to /etc/systemd/system/es_server.service.
[root@node101 bin]# ps -ef |grep es_server
root 20196 1 0 13:28 ? 00:00:00 /home/kingbase/cluster/HAR3/db/bin/es_server -f /home/kingbase/cluster/HAR3/db/share/es_server.conf
[root@node101 bin]# netstat -antlp |grep 8890
tcp 0 0 0.0.0.0:8890 0.0.0.0:* LISTEN 20196/es_server
[root@node101 bin]#
3、systemctl管理es_server
# 停止es_server服务
[root@node101 ~]# systemctl stop es_server
[root@node101 ~]# systemctl status es_server
● es_server.service - KingbaseES - es_server daemon
Loaded: loaded (/etc/systemd/system/es_server.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2022-09-28 14:12:02 CST; 2s ago
Process: 20795 ExecStart=/home/kingbase/cluster/HAR3/db/bin/es_server -f /home/kingbase/cluster/HAR3/db/share/es_server.conf (code=exited, status=0/SUCCESS)
Main PID: 20795 (code=exited, status=0/SUCCESS)
Sep 28 14:11:50 node101 systemd[1]: Started KingbaseES - es_server daemon.
Sep 28 14:12:02 node101 systemd[1]: Stopping KingbaseES - es_server daemon...
Sep 28 14:12:02 node101 systemd[1]: Stopped KingbaseES - es_server daemon.
#启动es_server服务
[root@node101 ~]# systemctl start es_server
[root@node101 ~]# systemctl status es_server
● es_server.service - KingbaseES - es_server daemon
Loaded: loaded (/etc/systemd/system/es_server.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-09-28 14:12:10 CST; 3s ago
Main PID: 20819 (es_server)
Tasks: 1
CGroup: /system.slice/es_server.service
└─20819 /home/kingbase/cluster/HAR3/db/bin/es_server -f /home/kingbase/cluster/HAR3/db/share/es_server.conf
Sep 28 14:12:10 node101 systemd[1]: Started KingbaseES - es_server daemon.
4、测试节点间通讯
[root@node102 es_server]# ./es_client root@192.168.1.101 'hostname'
node101
5、查看es_server服务配置
# systemctl管理配置
[root@node101 bin]# cat /etc/systemd/system/es_server.service
[Unit]
Description=KingbaseES - es_server daemon
After=network.target
[Service]
Type=simple
ExecStart=/home/kingbase/cluster/HAR3/db/bin/es_server -f /home/kingbase/cluster/HAR3/db/share/es_server.conf
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
RestartSec=10s
[Install]
WantedBy=multi-user.target
#用户密钥认证配置
[root@node101 ~]# ls .es/ -lh
total 8.0K
-rw------- 1 root root 381 Sep 28 13:28 accept_hosts
-rw------- 1 root root 1.7K Sep 28 13:28 key_file
[root@node101 ~]# ls -lh /home/kingbase/.es
total 8.0K
-rw------- 1 kingbase kingbase 381 Sep 28 13:28 accept_hosts
-rw------- 1 kingbase kingbase 1.7K Sep 28 13:28 key_file
三、执行脚本部署集群
1、部署配置文件
[kingbase@node101 bin]$ cat install.conf |grep -v ^$|grep -v ^#
on_bmj=0
all_node_ip=(192.168.1.101 192.168.1.102)
cluster_path="/home/kingbase/cluster/HAR3"
db_package="/home/kingbase/cluster/HAR3/db.zip"
cluster_package="/home/kingbase/cluster/HAR3/kingbasecluster.zip"
license_file=(license.dat)
db_user="SYSTEM" # the user name of database
db_password="123456" # the password of database, since the R3 has a special feature that password cannot be stored in clear text, please delete the password after the cluster deployment is complete.
db_port="54321" # the port of database, defaults is 54321
trust_ip="192.168.1.1"
db_vip="192.168.1.204"
cluster_vip="192.168.1.205"
net_device=(enp0s3 enp0s3)
ipaddr_path="/sbin"
arping_path="/home/kingbase/cluster/HAR3/db/bin/"
super_user="root"
cluster_user="kingbase"
use_sshd=0 # choose whether to use sshd service, 0 means not to use, 1 means to use, default value is 0
wd_deadtime="30" # cluster heartbeats timeout, unit: seconds
check_retries="6" # number of detection retries in case of database failure
check_delay="10" # detection retry interval in case of database failure
connect_timeout="10000" # timeout value in milliseconds before giving up to connect to backend
auto_primary_recovery="0" # automatic recovery parameter of cluster primary host, default value is 0
ssh_port="22" # the port of sshd [if on_bmj=1 or use_sshd=0, you do not need to configure this parameter]
es_port="8890" # the port of es_server
case_sensitive="on" # select whether database is case sensitive, off means case insensitive, on means case sensitive,the default value is on
max_available_level="1" # when all databases are down, should the cluster be automatically started. 1 means yes, 0 means no, default value is 1
如下图所示:关闭ssh分发的部署。

2、执行部署脚本
[kingbase@node101 bin]$ sh V8R3_cluster_install.sh
[INFO]-Check if the cluster_vip "192.168.1.205" is already exist ...
.......
[INSTALL] start up the slave on "192.168.1.102" ... OK
[INSTALL] Create physical_replication_slot on 192.168.1.101
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node1,)
(1 row)
[INSTALL] Create physical_replication_slot on 192.168.1.101 ... OK
[INSTALL] Create physical_replication_slot on 192.168.1.101
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node2,)
(1 row)
[INSTALL] Create physical_replication_slot on 192.168.1.101 ... OK
[INSTALL] Create physical_replication_slot on 192.168.1.102
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node1,)
(1 row)
[INSTALL] Create physical_replication_slot on 192.168.1.102 ... OK
[INSTALL] Create physical_replication_slot on 192.168.1.102
SYS_CREATE_PHYSICAL_REPLICATION_SLOT
--------------------------------------
(slot_node2,)
(1 row)
[INSTALL] Create physical_replication_slot on 192.168.1.102 ... OK
[INSTALL] start up the whole cluster ...
-----------------------------------------------------------------------
2022-09-28 14:26:38 KingbaseES automation beging...
......
2022-09-28 14:26:48 Del kingbase VIP [192.168.1.204/24] ...
DEL VIP NOW AT 2022-09-28 14:26:46 ON enp0s3
No VIP on my dev, nothing to do.
2022-09-28 14:26:48 Done...
......................
all stop..
ping trust ip 192.168.1.1 success ping times :[3], success times:[2]
......
Redirecting to /bin/systemctl restart crond.service
Redirecting to /bin/systemctl restart crond.service
......................
all started..
...
now we check again
=======================================================================
| ip | program| [status]
[ 192.168.1.101]| [kingbasecluster]| [active]
[ 192.168.1.102]| [kingbasecluster]| [active]
[ 192.168.1.101]| [kingbase]| [active]
[ 192.168.1.102]| [kingbase]| [active]
=======================================================================
[INSTALL] start up the whole cluster ... OK
---如上所示:集群部署成功。
四、验证集群
1、查看集群节点状态
[kingbase@node101 bin]$ ./ksql -U SYSTEM -W 123456 TEST -p 9999
ksql (V008R003C002B0370)
Type "help" for help.
TEST=# show pool_nodes;
node_id | hostname | port | status | lb_weight | role | select_cnt | load_balance_node | replication_delay
---------+---------------+-------+--------+-----------+---------+------------+-------------------+-------------------
0 | 192.168.1.101 | 54321 | up | 0.500000 | primary | 0 | false | 0
1 | 192.168.1.102 | 54321 | up | 0.500000 | standby | 0 | true | 0
(2 rows)
2、查看流复制状态
[kingbase@node101 bin]$ ./ksql -U SYSTEM -W 123456 TEST
ksql (V008R003C002B0370)
Type "help" for help.
TEST=# select * from sys_stat_replication;
PID | USESYSID | USENAME | APPLICATION_NAME | CLIENT_ADDR | CLIENT_HOSTNAME | CLIENT_PORT | BACKEND_START |BACKEND_XMIN | STATE | SENT_LOCATION | WRITE_LOCATION | FLUSH_LOCATION | REPLAY_LOCATION | SYNC_PRIORITY | SYNC_STATE
-------+----------+---------+------------------+---------------+-----------------+-------------+-------------------------------+--------------+-----------+---------------+----------------+----------------+-----------------+---------------+------------
27905 | 10 | SYSTEM | node2 | 192.168.1.102 | | 59898 | 2022-09-28 14:26:58.204189+08 | | streaming | 0/30000D0 | 0/30000D0 | 0/30000D0 | 0/30000D0 | 2 | sync
(1 row)
五、总结
通过es_server在无ssh的通用机环境,可以很方便的执行集群的部署,对于一些对安全要求比较严格的生产环境,可以参考以上案例执行集群的部署。
KingbaseES V8R3集群部署案例之---通用机无ssh环境脚本部署集群的更多相关文章
- KingbaseES V8R3集群运维案例之---用户自定义表空间管理
案例说明: KingbaseES 数据库支持用户自定义表空间的创建,并建议表空间的文件存储路径配置到数据库的data目录之外.本案例复现了,当用户自定义表空间存储路径配置到data下时,出现的故障问 ...
- KingbaseES V8R6C5B041手工创建集群测试案例
案例说明: KingbaseES V8R6C5B041版本和以前的KingbaseES R6有一定的区别,增加了"securecmdd"的工具,并且在install.conf配 ...
- KingbaseES R6 通过脚本构建集群案例
案例说明: KingbaseES V8R6部署一般可采用图形化方式快速部署,但在生产一线,有的服务器系统未启用图形化环境,所以对于KingbaseES V8R6的集群需采用手工字符界面方式部署,本 ...
- KingbaseES V8R3集群维护案例之---在线添加备库管理节点
案例说明: 在KingbaseES V8R3主备流复制的集群中 ,一般有两个节点是集群的管理节点,分为master和standby:如对于一主二备的架构,其中有两个节点是管理节点,三个数据节点:管理节 ...
- KingbaseES V8R3 集群专用机网关失败分析案例
KingbaseES R3集群网关检测工作机制: 1.Cluster下watchdog进程在固定间隔时间,通过ping 网关地址监控链路的连通性,如果连通网关地址失败,则修改cluster sta ...
- KingbaseES V8R3集群运维案例之---主库系统down failover切换过程分析
案例说明: KingbaseES V8R3集群failover时两个cluster都会触发,但只有一个cluster会调用脚本去执行真正的切换流程,另一个有对应的打印,但不会调用脚本,只是走相关的 ...
- KingbaseES V8R3集群管理维护案例之---集群迁移单实例架构
案例说明: 在生产中,需要将KingbaseES V8R3集群转换为单实例架构,可以采用以下方式快速完成集群架构的迁移. 适用版本: KingbaseES V8R3 当前数据库版本: TEST=# s ...
- KingbaseES V8R3集群管理和维护案例之---failover切换wal日志变化分析
案例说明: 本案例通过对KingbaseES V8R3集群failover切换过程进行观察,分析了主备库切换后wal日志的变化,对应用者了解KingbaseES V8R3(R6) failover ...
- KingbaseES V8R3集群运维案例之---kingbase_monitor.sh启动”two master“案例
案例说明: KingbaseES V8R3集群,执行kingbase_monitor.sh启动集群,出现"two master"节点的故障,启动集群失败:通过手工sys_ctl启动 ...
- KingbaseES V8R3集群维护案例之---pcp_node_refresh应用
案例说明: 在一次KingbaseES V8R3集群切换分析中,运维人员执行了pcp_node_refresh,导致集群发生了failover的切换.此文档对pcp_node_refresh工具做了应 ...
随机推荐
- Nacos2作为Dubbo3的配置中心踩坑总结
本文阐述问题所使用的组件版本分别是,Dubbo:3.2.4,Nacos服务端:2.2.3,Nacos客户端:2.2.4. 在Dubbo3的官方文档中,关于如何使用Nacos作为配置中心的详细介绍参考: ...
- 【C# .Net】继承重写父类方法,C# 与 JAVA的不同之处
一直都没仔细研究c#重写,new关键字的作用,最近在回头看书,复习C#基础的时候才发现了 C# 重写和 JAVA大不一样的地方. C# 提供特定实现的子类可以重写(override)标识为 virtu ...
- java中sha1.md5,base64到底怎么回事
MD5 Message Digest Algorithm MD5(中文名为消息摘要算法第五版)为计算机安全领域广泛使用的一种散列函数,用以提供消息的完整性保护.MD5用的是哈希函数,在计算机网络中应用 ...
- 【Azure 应用服务】遇见“无法创建hybrid connection for App Service”的解决办法
Hybrid Connection (混合连接) 在两个联网应用程序之间启用了双向.请求-响应和二进制流通信以及简单的数据报流.通过混合连接,可以实现应用部署在公网环境中,而数据库保存在本地私网环境中 ...
- MAUI调用.so库
必要条件: (一)安装JDK (二)安装NDK (三)安装Android Studio(其实可以不用装也行) 使用Android Studio构件.so包 构件.so包 1. 使用Android st ...
- 十四: Mysql数据结构选择的合理性
Mysql数据结构选择的合理性 从MySQL的角度讲,不得不考虑一个现实问题就是磁盘I/O. 如果我们能让索引的数据结构尽量减少硬盘的I/O操作,所消耗的时间也就越小.可以说,磁盘的I/O操作次数对索 ...
- C++ //count_if //按条件统计元素个数 //自定义和 内置
1 //按条件统计元素个数 2 //count_if 3 4 #include <iostream> 5 #include<string> 6 #include<vect ...
- Mac上LLAMA2大语言模型安装到使用
LLAMA介绍 LLaMA是由Facebook的母公司Meta AI设计的一个新的大型语言模型.LLaMA拥有70亿到650亿个参数的模型集合,是目前最全面的语言模型之一. Llama是目前唯一一个可 ...
- 文心一言 VS 讯飞星火 VS chatgpt (210)-- 算法导论16.1 1题
一.根据递归式(16.2)为活动选择问题设计一个动态规划算法.算法应该按前文定义计算最大兼容活动集的大小 c[i,j]并生成最大集本身.假定输入的活动已按公式(16.1)排好序.比较你的算法和GREE ...
- Mac下使用Docker快速布署FastGPT实现AI私有知识库
FastGPT 是一个基于 LLM 大语言模型的知识库问答系统,提供开箱即用的数据处理.模型调用等能力.同时可以通过 Flow 可视化进行工作流编排,从而实现复杂的问答场景! 官网地址为:https: ...