中国移动磐维数据库(ChinaMobileDB),简称“磐维数据库”(CMDB)。是中国移动信息技术中心首个基于中国本土开源数据库打造的面向ICT基础设施的自研数据库产品。
其产品内核能力基于华为 OpenGauss 开源软件,并进一步提升了系统稳定性。
本文将介绍磐维数据库部署之前需要进行的系统环境优化。
1.检查root权限是否禁止登录
cat /etc/ssh/sshd_config | grep PermitRootLogin
#若返回值为:PermitRootLogin yes 则不需要修改
#若返回值为:PermitRootLogin yes 则需要改为yes
vi /etc/ssh/sshd_config
#修改完成后要重启sshd服务
systemctl restart sshd2.关闭SELINUX
cat /etc/selinux/config | grep -i SELINUX
#若返回值为:SELINUX=disabled 则不需要修改
#若返回值为:SELINUX=enforcing 则需要进行关闭
setenforce 03.关闭防火墙
# 查看防火墙状态
systemctl status firewalld
# 关闭防火墙
systemctl disable firewalld.service
systemctl stop firewalld.service
4.设置字符集
# 查看字符集
echo $LANG
# 设置字符集
export LANG=en_US.UTF-8
5.设置时区和时间
# 检查时间和时区,时间应该同步一致;时区应该一样。
date
# 如果不一样,则执行如下操作
## 拷贝时区文件
cp ../usr/share/zoneinfo/Asia/Shanghai /etc/localtime
## 设置三节点统一时间
date -s "Tue Aug 20 16:34:22 CST 2024"
6.关闭 swap 交换
swapoff -a7.设置网卡MTU值
## 检查网卡名称
ip a
## 检查网卡
#当speed 超过 20000Mb/s(万兆)时(不包含20000Mb/s),可设置mtu参数,其他情况下可以跳过此步骤
ethtool bond1 #bond/网卡名
ifconfig bond1 mtu 8192 #bond/网卡名
## 查看MTU值
ifconfig bond1|grep mtu #bond/网卡名
8.关闭THP
#检查THP开启情况
cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
##关闭THP
echo never > /sys/kernel/mm/transparent_hugepage/enabled
## 设置重启后自动关闭
chmod +x /etc/rc.d/rc.local
systemctl enable rc-local.service
cat >> /etc/rc.d/rc.local <<EOF
swapoff -a
if test -f /sys/kernel/mm/transparent_hugepage/enabled;
then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag;
then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
systemctl restart rc-local.service
9.关闭RemoveIPC
(1) 修改/etc/systemd/logind.conf文件中的“RemoveIPC”值为“no”
vim /etc/systemd/logind.conf
RemoveIPC=no
(2) 修改/usr/lib/systemd/system/systemd-logind.service文件中的“RemoveIPC”值为“no”
vim /usr/lib/systemd/system/systemd-logind.service
RemoveIPC=no #没有参数,添加到末尾
(3) 重启服务
systemctl daemon-reload
systemctl restart systemd-logind.service
(4) 结果验证确认
loginctl show-session | grep RemoveIPC
systemctl show systemd-logind | grep RemoveIPC
10.内核参数优化
vi /etc/sysctl.conf
# panweidb
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.tcp_retries1 = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_retries2 = 12
vm.overcommit_memory = 0
net.ipv4.tcp_rmem = 8192 250000 16777216
net.ipv4.tcp_wmem = 8192 250000 16777216
net.core.wmem_max = 21299200
net.core.rmem_max = 21299200
net.core.wmem_default = 21299200
net.core.rmem_default = 21299200
net.ipv4.ip_local_port_range = 26000 65535
kernel.sem = 250 6400000 1000 25600
net.core.somaxconn = 65535
net.ipv4.tcp_syncookies = 1
net.core.netdev_max_backlog = 65535
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_fin_timeout = 60
kernel.shmall = 1073741824
kernel.shmmax = 751619276800
net.ipv4.tcp_sack = 1
net.ipv4.tcp_timestamps = 1
vm.extfrag_threshold = 500
vm.overcommit_ratio = 90
vm.swappiness = 0
# 生效
sysctl -p具体参数含义和作用可见:https://www.modb.pro/db/1814207358919258112
11.配置资源限制
vi /etc/security/90-nproc.conf
或者
vi /etc/security/limits.conf
# panweidb
* soft nofile 1000000
* hard nofile 1000000
* soft nproc 655360
* hard nproc 655360
* soft memlock unlimited
* hard memlock unlimited
* soft core unlimited
* hard core unlimited
* soft stack unlimited
* hard stack unlimited
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




