Installing MongoDB on CentOS 7

Source: Internet
Author: User
Tags touch

Reference post: https://www.jianshu.com/p/ccdd3e884b86

First, installation Preparation
1. Modify the System configuration
#关闭selinux, Firewall
#修改/etc/security/limits.conf Add the following:

    • Soft Nofile 65536
    • Hard Nofile 65536
    • Soft Nproc 65536
    • Hard Nproc 65536
      #修改/etc/security/limits.d/20-nproc.conf
    • Soft Nproc 65536
      3. Create account, Directory
      Groupadd-g MONGO
      Useradd-u 600-g MONGO MONGO

Second, installation steps
1. Unzip the file
Tar xvf mongodb-linux-x86_64-enterprise-rhel70-3.6.2.tgz-c/usr/local/
Cd/usr/local
MV Mongodb-linux-x86_64-enterprise-rhel70-3.6.2/mongodb
CD MongoDB
Mkdir-p data/db
mkdir Log
Touch Log/mongod.log
mkdir etc
Touch etc/mongod.conf
Chown-r Mongo.mongo/usr/local/mongodb
2. Create configuration file/usr/local/mongodb/data/mongodb/config/mongod.conf
Systemlog:
Destination:file
Path:/usr/local/mongodb/data/mongodb/log/mongod.log
Logappend:true
Storage
Journal
Enabled:true
DbPath:/usr/local/mongodb/data/db/
Directoryperdb:true
Engine:wiredtiger
Wiredtiger:
Engineconfig:
Cachesizegb:4
Directoryforindexes:true
Collectionconfig:
Blockcompressor:none
Indexconfig:
Prefixcompression:true
Processmanagement:
Fork:true
Pidfilepath:/usr/local/mongodb/data/mongodb/mongod.pid
Net
port:27017
bindip:192.168.1.213
3, clear large pages in/etc/rc.d/rc.local add the following:
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
chmod +x/etc/rc.d/rc.local
4, modify the environment variables. Bash_profile
Java_home=/usr/local/jdk
Classpath= $JAVA _home/lib
Path= $JAVA _home/bin: $PATH: $HOME/bin:/usr/local/mongodb/bin
Export PATH java_home CLASSPATH
#重新加载. Bash_profile
. . bash_profile
5. Start MongoDB
Yum install-y net-snmp* gcc-c++
Nohup mongod-f/usr/local/mongodb/data/mongodb/config/mongod.conf >/dev/null 2>&1 &
6. Login Test
MONGO 192.168.1.213:27017
7. Mongodb C Drive Installation
Tar xvf mongo-c-driver-1.6.1.tar.gz
CD MONGO-C-DRIVER-1.6.1/
./configure-disable-automatic-init-and-cleanup
Make
Make install

Installing MongoDB on CentOS 7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.