First, through the RPM installation 1, System preparation
Our system version isCentOS Linux release 7.3.1611 (Core)
2. installation package Download
: http://mirrors.aliyun.com/mongodb/yum/redhat/, can be selected according to your own system version.
The path I chose: http://mirrors.aliyun.com/mongodb/yum/redhat/7/mongodb-org/3.2/x86_64/RPMS/.
The version I chose for MongoDB is the 3.2.6
package as follows:
mongodb-org-3.2.6-1.el7.x86_64.rpm
mongodb-org-mongos-3.2.6-1.el7.x86_64.rpm
mongodb-org-server-3.2.6-1.el7.x86_64.rpm
mongodb-org-shell-3.2.6-1.el7.x86_64.rpm
mongodb-org-tools-3.2.6-1.el7.x86_64.rpm
3. Start the installation
yum install *.rpm
4. Create Data Catalog
install -o mongod -g mongod -d /data/mongodb
5. Modify the configuration file/etc/mongod.conf
Modify DBPath and comment out Bindip
storage: dbPath: /data/mongodb journal: enabled: truenet: port: 27017# bindIp: 127.0.0.1
6. Start MongoDB
systemctl start mongod
7. Check
[[email protected] ~]# netstat -tlnpActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 16640/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1924/master tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 16724/zabbix_agentd tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN 11188/mongod
8. Login to MongoDB
[[email protected] ~]# mongomongodb Shell version:3.2.6connecting To:testserver has startup warnings:2018-07-31t1 7:40:28.137+0800 I control [Initandlisten] 2018-07-31t17:40:28.137+0800 i control [initandlisten] * * warning:you is RU Nning on a NUMA machine.2018-07-31t17:40:28.137+0800 I CONTROL [initandlisten] * * We suggest launching Mongod Li Ke this to avoid performance problems:2018-07-31t17:40:28.137+0800 I CONTROL [initandlisten] * * Numactl--in Terleave=all Mongod [Other options]2018-07-31t17:40:28.138+0800 I CONTROL [Initandlisten] 2018-07-31t17:40:28.138+ 0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' always '. 2018-07-31t17 : 40:28.138+0800 i CONTROL [initandlisten] * * We suggest setting it to ' Never ' 2018-07-31t17:40:28.138+0800 i contro L [Initandlisten] 2018-07-31t17:40:28.138+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_ Hugepage/defrag is ' always '. 2018-07-31t17:40:28.138+0800 I control [initandlisten] * * We suggest setting it to ' Never ' 2018-07-31t17:40:28.138+0800 i control [init Andlisten] 2018-07-31t17:40:28.138+0800 I CONTROL [initandlisten] * * warning:soft rlimits too low. Rlimits set to 4096 processes, 64000 files. Number of processes should is at least 32000:0.5 times number of files.2018-07-31t17:40:28.138+0800 I CONTROL [Initandl Isten]
From the middle we will see a lot of warnings, we hit to make changes.
1. Disable THP
Transparent Huge Pages (THP) has been introduced since the CENTOS6 release, which is enabled by default, starting with the CentOS7 version. Although THP is intended to improve memory performance, some database vendors recommend that you turn off THP directly (for example, Oracle, MariaDB, MongoDB, and so on), which may cause performance degradation.
First check the activation status of THP:
[[email protected] ~]# cat /sys/kernel/mm/transparent_hugepage/defrag[always] madvise never[[email protected] ~]# cat /sys/kernel/mm/transparent_hugepage/enabled[always] madvise never
This status indicates that all are enabled.
We can, of course, modify the above two files individually to disable THP,
Temporary Solutions
Remember to restart MongoDB
echo never >> /sys/kernel/mm/transparent_hugepage/enabledecho never >> /sys/kernel/mm/transparent_hugepage/defrag
Permanent effect
To edit a /etc/rc.d/rc.local
file:
Add the following content:
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
2. Rlimits setting
echo "mongod soft nofile 64000" >> /etc/security/limits.confecho "mongod hard nofile 64000" >> /etc/security/limits.confecho "mongod soft nproc 32000" >> /etc/security/limits.confecho "mongod hard nproc 32000" >> /etc/security/limits.conf
3, set Numactl
Since the startup script has already been determined, we have previously minimized the installation system, so we only need to install NUMACTL.
yum install numactl -y
When you're done, restart MongoDB.
Second, download the installation package 1, download the package
MongoDB provides a 64-bit installation package for each Linux distribution, and you can download the installation package on the website.
: https://www.mongodb.com/download-center#community
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.0.tgz
2. Extract to the specified directory
tar -zxvf mongodb-linux-x86_64-rhel70-4.0.0.tgzmv mongodb-linux-x86_64-rhel70-4.0.0 /usr/local/mongodb
Linux System Installation Mongodb database