KINGBASE数据库集群部署(二)

    1. 预安装工作
      1. 安装前检查(主备节点都执行)
1.3.1.1 检查操作系统时间

查看时间:date

修改正确时间:date -s 正确时间

同步到硬件:/sbin/hwclock --systohc

能连接外网的话,可以通过ntp来同步

1.3.1.2 关闭防火墙

(以CentOS7举例)

[root@node1 ~]# systemctl status firewalld.service 查看防火墙状态

[root@node1 ~]# systemctl stop firewalld.service  关闭防火墙

[root@node1 ~]# systemctl disable firewalld.service  禁用防火墙

1.3.1.3 禁用selinux

[root@node1 ~]# vim /etc/selinux/config  追加以下内容

SELINUX=disabled

1.3.2创建安装用户

在linux 系统中,需要以非 root 用户执行安装程序,且该用户要有标准的 home 目录。因此,建议在正式安装前,新建 kingbase 用户作为金仓数据库管理系统 KingbaseES 专用的系统用户。

在主节点创建 kingbase 用户:

[root@node1 ~]# useradd kingbase

为kingbase用户设置密码:

[root@node1 ~]# passwd kingbase

1.3.3 修改系统参数(主备节点都执行)

  1. 编辑 /etc/security/limits.conf 文件,追加以下内容

[root@node1 ~]# vim /etc/security/limits.conf

root soft nofile   655360

root hard nofile     655360

root soft nproc   655360

root hard nproc   655360

root soft memlock  50000000

root hard memlock  50000000

root soft core      unlimited

root hard core      unlimited

kingbase soft nofile   655360

kingbase hard nofile     655360

kingbase soft nproc   655360

kingbase hard nproc   655360

kingbase soft memlock  50000000

kingbase hard memlock  50000000

kingbase soft core      unlimited

kingbase hard core      unlimited

附参数详解:

soft ——指当前系统生效的设置值。

hard——指系统中所能设定的最大值。soft的限制不能比hard的限制高。

nofile——指打开文件的最大数目

nproc——指进程的最大数目

core ——指限制内核文件的大小

  1. 编辑/etc/sysctl.conf 文件,追加以下内容

[root@node1 ~]# vi /etc/sysctl.conf  

kernel.sem = 50100 64128000 50100 1280  

# 释放time_wait链接

net.ipv4.tcp_syncookies = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_timestamps= 1   

net.ipv4.tcp_fin_timeout = 30   

# TCP端口使用范围

net.ipv4.tcp_keepalive_time = 1200

net.ipv4.tcp_keepalive_probes = 3

net.ipv4.tcp_keepalive_intvl = 30

net.ipv4.ip_local_port_range = 10000 65000

net.ipv4.tcp_max_tw_buckets = 6000  

# 记录的那些尚未收到客户端确认信息的连接请求的最大值

net.ipv4.tcp_max_syn_backlog = 65536  

# 每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目

net.core.netdev_max_backlog = 32768

net.core.wmem_default = 8388608

net.core.rmem_default = 8388608

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

net.ipv4.tcp_synack_retries = 2

net.ipv4.tcp_syn_retries = 2

net.ipv4.route.gc_timeout = 100

net.ipv4.tcp_wmem = 8192 436600 873200

net.ipv4.tcp_rmem  = 32768 436600 873200

net.ipv4.tcp_mem = 94500000 91500000 92700000

net.ipv4.tcp_max_orphans = 3276800

vm.swappiness=1

fs.file-max=7672460

fs.aio-max-nr=1048576

net.core.somaxconn=4096

vm.min_free_kbytes=521000

vm.vfs_cache_pressure=200

   

执行以下命令重新加载生效

[root@node1 ~]# sysctl -p

  1. 修改/etc/systemd/system.conf文件中的DefaultTasksAccounting参数

[root@node1 ~]# vim /etc/systemd/system.conf

DefaultTasksAccounting=no  注:所有服务不再有此限制

执行以下命令生效

[root@node1 ~]# systemctl daemon-reload

[root@node1 ~]# systemctl daemon-reexec

执行以下命令观察是否生效(无Limit那一行),若无生效,重启。

[root@node1 ~]# service sshd status

  1. 修改磁盘IO调度策略

echo deadline > /sys/block/[磁盘名]/queue/scheduler

此命令添加到rc.local

Tips:

deadline综合测试性能表现更稳定。

  1. 修改/etc/systemd/logind.conf文件中RemoveIPC=no

[root@node1 ~]# vim /etc/systemd/logind.conf

 RemoveIPC=no

生效方式

[root@node1 ~]#  systemctl daemon-reload

[root@node1 ~]# systemctl restart systemd-logind

1.3.4准备安装程序

以下操作仅在主节点执行即可

  1. 将数据库安装包和license文件拷贝到指定路径下并修改权限为kingbase用户所有

[root@node1 ~]# chown -R kingbase.kingbase /home/kingbase/kdb_install/

  1. 使用root用户挂载安装包,本次挂载在/mnt目录下(如果是压缩包形式,直接解压即可)

[root@node1~]# mount /home/kingbase/kdb_install/KingbaseES_V008R006C005B0033_Lin64_install.iso /mnt

第2章 安装集群软件(仅需在主节点安装)

2.2 命令行安装

2.2.1 启动安装程序

需使用kingbase用户执行

[kingbase@node1 mnt]$ sh setup.sh -i console

2.2.2 简介

按 <ENTER>继续

2.2.3 许可协议

一直按 <ENTER>继续,直至询问是否接受许可协议,输入Y(不区分大小写)接受协议,按 <ENTER>继续

2.2.4 选择安装集

输入 2,选择“客户端安装”安装集

2.2.5 选择安装目录

输入想要安装到的目录的绝对路径,并输入y确认所输目录正确

2.2.6 预安装摘要

确认即将安装产品的摘要信息正确后,按 <ENTER>继续

2.2.7 开始安装

确认安装后,按 <ENTER>开始安装

2.2.8 安装完成

安装完成,按 <ENTER> 键退出安装程序。

2.3 安装完确认

在安装完成后,可以通过以下几种方式进行安装正确性验证:

  1. 查看安装日志,确认没有错误记录;

安装日志在 安装目录/install/Logs/ 下

2、查看开始菜单:

使用kingbase用户登录,查看应用程序菜单中是否安装了 KingbaseES 菜单项

3、查看安装目录结构如下图

手动分发文件并部署

Note: 此步骤针对通用机环境【无法使用SSHD服务,或者无法通过SSH免密登陆root用户】此类环境可以使用此方式部署集群。

3.2.1 获取集群部署所需文件

1、使用集群部署用户新建目录 r6_install,将安装目录/ClientTools/guitools/DeployTools/zip/中的脚本文件 V8R6_cluster_install.sh、配置文件install.conf拷贝至 r6_install

3.2.2 配置 install.conf

读写分离集群配置示例(各参数含义见4.1.2):

on_bmj=0

all_ip=(192.168.40.11 192.168.40.12)

witness_ip=""

production_ip=()

local_disaster_recovery_ip=()

remote_disaster_recovery_ip=()

install_dir="/home/kingbase/cluster"

zip_package="/home/kingbase/r6_install/db.zip"

license_file=(license.dat)

trusted_servers="192.168.40.1"

data_directory="/home/kingbase/cluster/kingbase/data"

virtual_ip=""

net_device=()

net_device_ip=()

ipaddr_path="/usr/sbin"

arping_path="/usr/sbin"

ping_path="/usr/bin"

super_user="root"

execute_user="kingbase"

deploy_by_sshd=0    

use_scmd=1  

reconnect_attempts="10"

reconnect_interval="6"

recovery="standby"

ssh_port="22"

scmd_port="8890"

auto_cluster_recovery_level='1'

use_check_disk='off'

synchronous='quorum'

3.2.3 创建$install_dir/kingbase目录

1、使用集群用户(操作系统用户,例如:kingbase)在每个节点创建 $install_dir/kingbase 目录(install_dir是配置在install.conf 中的参数)

[kingbase@node1 ~]$ mkdir -p /home/kingbase/cluster/kingbase/

[kingbase@node2 ~]$ mkdir -p /home/kingbase/cluster/kingbase/

  1. 将db.zip和license.dat 拷贝到每个节点的$install_dir/kingbase目录下(db.zip在安装目录/ClientTools/guitools/DeployTools/zip/中)
  2. 在$install_dir/kingbase 目录下解压 db.zip,并将 license.dat 拷贝到解压后出现的$install_dir/kingbase/bin目录下。需注意文件权限属主需为集群部署用户。

3.2.4 启动 SYS_SECURECMDD

使用 root 用户在每个节点的 $install_dir/kingbase/bin目录下

先执行./sys_HAscmdd.sh init初始化sys_securecmdd

再执行./sys_HAscmdd.sh start启动sys_securecmdd。

3.2.5 集群部署

集群部署用户执行 sh V8R6_cluster_install.sh 命令进行集群部署,部署脚本将按照配置自动完成集群部署工作。V8R6_cluster_install.sh脚本在安装目录/ClientTools/guitools/DeployTools/zip/中。

....

3.2.6 部署后检查

部署成功后,在$install_dir/kingbase/bin下,执行命令“./repmgr cluster show”,确认是否真正成功部署集群。

3.3 配置环境变量

主备节点均需配置

[kingbase@node1 ~]$ vi ~/.bash_profile   追加以下内容

export PATH=$PATH:/home/kingbase/cluster/kingbase/bin

export KINGBASE_DATA=/home/kingbase/cluster/kingbase/data

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/kingbase/cluster/kingbase/lib

[kingbase@node1 ~]$ source .bash_profile 执行生效

3.4 修改es_rep.conf文件

向data目录下的es_rep.conf文件中追加以下内容:

listen_addresses='*'

port=54329 

max_connections=1000 #按需配置

shared_buffers=RAM*25% #按需配置

effective_cache_size=RAM*0.5GB

work_mem=10MB

maintenance_work_mem=2GB

huge_pages=try

temp_file_limit=-1

wal_level=replica

fsync=on

synchronous_standby_names='ANY 1 (*)'

full_page_writes=on

synchronous_commit=remote_apply

wal_buffers=-1

wal_compression=on

checkpoint_timeout=20min

checkpoint_completion_target=0.9

wal_keep_segments=4096

max_wal_size=64GB

min_wal_size=1GB

max_locks_per_transaction=1024

max_wal_senders=32

max_replication_slots=32

hot_standby=on

hot_standby_feedback=on

wal_log_hints=on

log_replication_commands=on

archive_mode=on

archive_command=''

ora_input_emptystr_isnull=on

control_file_copy='' #按需配置

logging_collector=on

log_destination=stderr

log_directory='sys_log'

log_filename='kingbase-%d.log'

log_truncate_on_rotation=on

log_rotation_age=1d

log_rotation_size=10MB

log_statement=ddl

log_min_duration_statement=1000

log_line_prefix='%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h'

log_checkpoints=on

log_lock_waits=on

log_autovacuum_min_duration=0

log_temp_files=0

lc_messages='C'

max_parallel_workers_per_gather=0

log_connections=on

log_disconnections=on

注:在所有节点修改完后重启集群生效

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值