人大金仓数据库集群安装(主备)

一、安装环境

服务器安装目标
10.0.0.255
10.0.0.8

1.1 安装前准备

  1. 创建部署用户(集群用户)kingbase
  2. 创建安装目录

分别在各个节点执行如下命令

# 分别在各个节点执行如下命令
# 创建集群用户
useradd -U -m kingbase
# 创建安装目录
mkdir -p /data/kingbase/
cd /data/
# 归属
chown kingbase:kingbase kingbase
  1. 创建安装文件存放目录,在主节点上执行(10.0.0.255)
mkdir -p /home/kingbase/r6_install/
  1. 配置开放端口或者关闭防火墙

分别在各个集群节点上执行如下命令:

#数据库端口默认 54321,
firewall-cmd --zone=public --add-port=54321/tcp --permanent
# HA-LOG 分析工具默认端口 65432
firewall-cmd --zone=public --add-port=65432/tcp --permanent
# sys_securecmdd 工具默认端口 8890
firewall-cmd --zone=public --add-port=8890/tcp --permanent

二、开始安装

2.1 安装数据库

推荐在集群主机上安装数据库(10.0.0.255),具体安装过程请参考上一篇文章。

2.2 安装集群

2.2.1 获取集群安装文件

安装成功后,请在 ${install_dir}/ClientTools/guitools/DeployTools/zip/目录下获取如下文件:

  • db.zip #数据库服务器压缩包
  • cluster_install.sh # 部署脚本
  • install.conf # 部署配置文件
  • trust_cluster.sh # 配置 SSH 免密脚本

将如上文件复制到 /home/kingbase/r6_install/

cp db.zip cluster_install.sh install.conf trust_cluster.sh /home/kingbase/r6_install/

请单独准备 license.dat 授权文件并上传至/home/kingbase/r6_install/

2.2.2 配置 install.conf

编辑 install.conf 文件

cd /home/kingbase/r6_install/
vim install.conf

文件中配置项很多,大部分都有默认值,如无特殊需求不需要修改,下面是总结出来的必填项和主要的配置项

## 所有节点IP
all_ip=(10.0.0.225 10.0.0.8)
## 集群安装目录
install_dir="/data/kingbase/cluster"
## 安装文件目录
zip_package="/home/kingbase/r6_install/db.zip"

## 数据库用户名、密码
db_user="system"                 # the user name of database
db_password="123456"             # the password of database.
db_port="54321"                  # the port of database, defaults is 54321
db_mode="mysql"                 # database mode: pg, oracle, mysql
db_auth="scram-sha-256"          # database authority: scram-sha-256, md5, scram-sm3, sm4, default is scram-sha-256
# 大小写敏感
db_case_sensitive="no" 

# 网关
trusted_servers="10.0.0.1"
# 漂移IP
virtual_ip="10.0.0.220"
# 漂移IP 对应的物理IP网卡
net_device=(eth0 eth0)
#漂移IP 对应的物理IP
net_device_ip=(10.0.0.225 10.0.0.8)
use_scmd=0     

2.2.3 SSH 免密配置

使用 trust_cluster.sh 进行 SSH 免密配置,免密配置后,请验证即将要部署集群的所有设备的 root 用户和普通用户之间的免密是否配置正确。

# 使用root用户执行,脚本会根据install.conf 中配置的IP、和用户进行免密设置
./trust_cluster.sh

# 如看到  check ssh connection success! 	则代表配置成功

2.2.4 集群部署

集群部署用户执行 sh cluster_install.sh 命令进行集群部署,部署脚本将按照配置自动完成集群部署工作。

su - kingbase
# 执行脚本前请检查各个机器节点上的安装目录/data/kingbase/及归属是否为kingbase用户
sh cluster_install.sh  

看到类似如下的输出信息,则代表集群安装完成:

[NOTICE] standby node "node2" (ID: 2) successfully registered
[INSTALL] register the standby on "10.0.0.8" ... OK
[INSTALL] start up the whole cluster ...
2023-12-04 14:45:56 Ready to start all DB ...
2023-12-04 14:45:56 begin to start DB on "[10.0.0.225]".
2023-12-04 14:45:56 DB on "[10.0.0.225]" already started, connect to check it.
2023-12-04 14:45:57 DB on "[10.0.0.225]" start success.
2023-12-04 14:45:57 Try to ping trusted_servers on host 10.0.0.225 ...
2023-12-04 14:45:59 Try to ping trusted_servers on host 10.0.0.8 ...
2023-12-04 14:46:02 begin to start DB on "[10.0.0.8]".
2023-12-04 14:46:02 DB on "[10.0.0.8]" already started, connect to check it.
2023-12-04 14:46:03 DB on "[10.0.0.8]" start success.
 ID | Name  | Role    | Status    | Upstream | Location | Priority | Timeline | LSN_Lag | Connection string                                                                                                                                                  
----+-------+---------+-----------+----------+----------+----------+----------+---------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------
 1  | node1 | primary | * running |          | default  | 100      | 1        |         | host=10.0.0.225 user=esrep dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000
 2  | node2 | standby |   running | node1    | default  | 100      | 1        | 0 bytes | host=10.0.0.8 user=esrep dbname=esrep port=54322 connect_timeout=10 keepalives=1 keepalives_idle=2 keepalives_interval=2 keepalives_count=3 tcp_user_timeout=9000  
2023-12-04 14:46:03 The primary DB is started.
2023-12-04 14:46:03 begin to start repmgrd on "[10.0.0.225]".
[2023-12-04 14:46:03] [NOTICE] using provided configuration file "/data/kingbase/cluster/kingbase/bin/../etc/repmgr.conf"
[2023-12-04 14:46:03] [NOTICE] redirecting logging output to "/data/kingbase/cluster/kingbase/log/hamgr.log"

2023-12-04 14:46:05 repmgrd on "[10.0.0.225]" start success.
2023-12-04 14:46:05 begin to start repmgrd on "[10.0.0.8]".
[2023-12-04 14:46:05] [NOTICE] using provided configuration file "/data/kingbase/cluster/kingbase/bin/../etc/repmgr.conf"
[2023-12-04 14:46:05] [NOTICE] redirecting logging output to "/data/kingbase/cluster/kingbase/log/hamgr.log"

2023-12-04 14:46:06 repmgrd on "[10.0.0.8]" start success.
 ID | Name  | Role    | Status    | Upstream | repmgrd | PID   | Paused? | Upstream last seen
----+-------+---------+-----------+----------+---------+-------+---------+--------------------
 1  | node1 | primary | * running |          | running | 21801 | no      | n/a                
 2  | node2 | standby |   running | node1    | running | 7701  | no      | 1 second(s) ago    
[2023-12-04 14:46:07] [NOTICE] redirecting logging output to "/data/kingbase/cluster/kingbase/log/kbha.log"

[2023-12-04 14:46:08] [NOTICE] redirecting logging output to "/data/kingbase/cluster/kingbase/log/kbha.log"

2023-12-04 14:46:08 Done.
[INSTALL] start up the whole cluster ... OK

2.2.5 配置环境变量

# 使用kingbase 
cd 
vim .bash_profile

# 在PATH 后面添加:/data/kingbase/cluster/kingbase/bin

# 修改完成后
source  .bash_profile

2.2.6 集群命令


# 集群检查
repmgr cluster show

#集群一键启停
sys_monitor.sh stop
sys_monitor.sh start

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值