Linux环境配置
cpu查看
#lscpu
物理内存(RAM)检查:
#grep MemTotal /proc/meminfo #最少8GB,推荐16GB以上
swap空间检查:
grep SwapTotal /proc/meminfo #Between 1 GB and 2 GB: 1.5 times the size of the RAM
#Between 2 GB and 16 GB: Equal to the size of the RAM
#More than 16 GB: 16 GB
文件系统检查:
#df -hT 临时文件系统/tmp至少为10GB
介质文件系统/stage至少5GB
软件文件系统/Kingbase至少10GB
硬盘查看:
lsblk -o name,rota #返回值为0是SSD,1是HDD
cat /sys/block/sda/queue/rotational #返回值为0是SSD,1是HDD
内核版本检查:
#cat /etc/redhat-release
#uname -a
网关查看:
route -v
创建用户
#groupadd kingbase
#useradd -m -d /home/kingbase kingbase -g kingbase
#echo "kingbase"|passwd kingbase --stdin / passwd kingbase
软件包检查
#yum install -y sysstat.x86_64 unixODBC.x86_64 unixODBC-devel.x86_64
JDK版本检查
#java -version #kingbase V8R6默认提供为java version "1.8.0_92"
禁用SELINUX
# setenforce 0 #临时关闭selinux防火墙
#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config / vi /etc/selinux/config SELINUX=disabled
#getenforce #查看selinux的工作模式
禁用IPC移除
#vi /etc/systemd/logind.conf
RemoveIPC=no
#systemctl daemon-reload #重新加载所有修改过的配置文件
#systemctl restart systemd-logind.service
修改DefaultTasksAccounting参数
#vi /etc/systemd/system.conf
DefaultTasksAccounting=no
# systemctl daemon-reload
# systemctl daemon-reexec
修改磁盘IO调度策略
vi /etc/rc.local
echo noop >/sys/block/sda/queue/scheduler
禁用防火墙
#systemctl disable firewalld.service
#systemctl stop firewalld.service
内核参数调整
#vi /etc/sysctl.conf
fs.aio-max-nr= 1048576
fs.file-max= 6815744
kernel.shmall= 2097152
kernel.shmmax= 4294967295
kernel.shmmni= 4096
kernel.sem= 250 32000 100 128
net.ipv4.ip_local_port_range= 9000 65500
net.core.rmem_default= 262144
net.core.rmem_max= 4194304
net.core.wmem_default= 262144
net.core.wmem_max= 1048576
vm.swappiness = 10
#sysctl -p
limits配置
#vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65535
* soft nproc 65536
* hard nproc 65535
* soft core unlimited
* hard core unlimited
* soft memlock unlimited
* hard memlock unlimited
集群安装
配置静默安装配置文件
$cd /KingbaseES/V8/ClientTools/guitools/DeployTools
$vi install.conf
示例
on_bmj=0
all_ip=(192.168.122.193 192.168.122.194)
witness_ip="192.168.122.195"
production_ip=()
local_disaster_recovery_ip=()
remote_disaster_recovery_ip=()
install_dir="/home/kingbase/cluster/install"
zip_package="/KingbaseES/V8/ClientTools/guitools/DeployTools/zip/db.zip"
license_file=(license.dat)
db_user="system"
db_port="54321"
db_mode="oracle"
db_auth="scram-sha-256"
db_case_sensitive="yes"
db_checksums="yes"
trusted_servers="192.168.122.1"
running_under_failure_trusted_servers='on'
data_directory=""
waldir=''
virtual_ip="192.168.122.196"
net_device=(team0 team0 )
net_device_ip=(192.168.122.193 192.168.122.194)
ipaddr_path="/sbin"
arping_path=""
ping_path="/bin"
super_user="root"
execute_user="kingbase"
deploy_by_sshd=1
use_scmd=0
reconnect_attempts="10"
reconnect_interval="6"
recovery="standby"
ssh_port="22"
scmd_port="8890"
auto_cluster_recovery_level='1'
use_check_disk='off'
synchronous=''
sync_in_same_location=0
failover_need_server_alive='off'
节点配置信任
# cd /home/kingbase/KingbaseES/V8/ClientTools/guitools/DeployTools/zip
# ./ trust_cluster.sh
部署主备集群
$ cd /home/kingbase/KingbaseES/V8/ClientTools/guitools/DeployTools/zip
$ ./V8R6_cluster_install.sh
部署过程查看日志
$ cd ${install_dir}/log
检查
$cd /home/kingbase/cluster/install/kingbase/bin
$./repmgr cluster show
配置环境变量(主备节点都配置)
$vi .bashrc
export PATH=$PATH:/home/kingbase/cluster/install/kingbase/bin
export KINGBASE_DATA=/data
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/kingbase/cluster/install/kingbase/lib
$source .bashrc
修改es_rep.conf文件(优化集群数据库参数)
向data目录下的es_rep.conf文件中追加以下内容:
max_connections = 1000
shared_buffers = 16GB #RAM/4
effective_cache_size = 48GB #RAM/4*3
maintenance_work_mem = 2GB #RAM/16
checkpoint_completion_target = 0.9
wal_buffers = 16MB #-1 表示自动调优
default_statistics_target = 100
random_page_cost = 1.1 #HDD 4,SSD 1.1,SAN存储 1.1
effective_io_concurrency = 200 #HDD 2,SSD 200,SAN存储 300
work_mem = 10MB
min_wal_size = 2GB
max_wal_size = 8GB
max_worker_processes = 32
max_parallel_workers_per_gather = 4
max_parallel_workers = 32
max_parallel_maintenance_workers = 4
wal_compression=on
checkpoint_timeout=20min
max_locks_per_transaction=1024
log_truncate_on_rotation=on
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
synchronous_standby_names='ANY 1 (*)'
synchronous_commit=remote_apply
wal_keep_segments=4096
max_replication_slots=32
hot_standby=on
hot_standby_feedback=on
wal_log_hints=on
log_replication_commands=on
log_connections=on
log_disconnections=on
archive_mode=on
archive_command=''