-
mongoDB 和 redis 一样 都是 键值存储,现持久化使用的redis,考虑支持mongoDB 防止服务器的宕机玩家回档。
MongDB官网
下载中心
https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.9.tgz
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.9.tgz
tar xvf mongodb-linux-x86_64-rhel70-3.2.9.tgz
mv mongodb-linux-x86_64-rhel70-3.2.9 mongodb
\cp -rf mongodb /usr/local/mongodb
vim /etc/profile
加入:
if [ -d /usr/local/mongodb/bin ]; then
export PATH=$PATH:/usr/local/mongodb/bin/
fi
运行生效:
source /etc/profile
阿里云的ssd 默认挂载 在/alidata1目录下
mkdir -p /alidata1/dbdata/mongodb/db
默认centos7 系统
查看透明页是否开启
RHEL使用:
cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
CentOS 和其他系统使用:
cat /sys/kernel/mm/transparent_hugepage/enabled
返回:
[always] madvise never
always:开启
madvise:警示
never:关闭
临时禁用:
echo never >/sys/kernel/mm/transparent_hugepage/defrag
echo never >/sys/kernel/mm/transparent_hugepage/enabled
永久禁用:
方法1:
在grub中禁用
vim /etc/grub.conf
transparent_hugepage=never
方法2:
使用mongodb官网的脚本
在/etc/init.d/创建 disable-transparent-hugepages
vim /etc/init.d/disable-transparent-hugepages
=====>>
#!/bin/sh
### BEGIN INIT INFO
# Provides: disable-transparent-hugepages
# Required-Start: $local_fs
# Required-Stop:
# X-Start-Before: mongod mongodb-mms-automation-agent
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description: Disable Linux transparent huge pages, to improve
# database performance.
### END INIT INFO
case $1 in
start)
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
thp_path=/sys/kernel/mm/transparent_hugepage
elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
thp_path=/sys/kernel/mm/redhat_transparent_hugepage
else
return 0
fi
echo 'never' > ${thp_path}/enabled
echo 'never' > ${thp_path}/defrag
unset thp_path
;;
esac
赋予运行权限
chmod 755 /etc/init.d/disable-transparent-hugepages
Ubuntu and Debian
sudo update-rc.d disable-transparent-hugepages defaults
SUSE
sudo insserv /etc/init.d/disable-transparent-hugepages
Red Hat, CentOS, Amazon Linux, and derivatives
sudo chkconfig --add disable-transparent-hugepages
查看 运行 chkconfig
Note: This output shows SysV services only and does not include native
systemd services. SysV configuration data might be overridden by native
systemd configuration.
If you want to list systemd services use 'systemctl list-unit-files'.
To see services enabled on particular target use
'systemctl list-dependencies [target]'.
aegis 0:off 1:off 2:on 3:on 4:on 5:on 6:off
agentwatch 0:off 1:off 2:on 3:on 4:on 5:on 6:off
disable-transparent-hugepages 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netconsole 0:off 1:off 2:off 3:off 4:off 5:off 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
redis_6379 0:off 1:off 2:on 3:on 4:on 5:on 6:off
修改tuned 和ktune
使用centos7:
创建目录
sudo mkdir /etc/tuned/no-thp
修改配置
vim /etc/tuned/no-thp/tuned.conf
输入
#include=virtual-guest
include=throughput-performance
[vm]
transparent_hugepages=never
显示 配置 看是否有no-thp
tuned-adm list
切换模式
tuned-adm profile no-thp
centos7 检测 开启情况
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
或者:
cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
cat /sys/kernel/mm/redhat_transparent_hugepage/defrag