CentOS installation MongoDB

Source: Internet
Author: User
Tags openssl iptables

centos6.6 under Installation MongoDB3.0.1From the MongoDB3.0 version, its installation package is more refined than before, some friends may not understand the difference, a simple explanation:
Linux 64-bit Legacy This version is mongodb-linux-x86_64-3.0.1.tgz is not recommended in the formal environment, this version is not connected with SSL-related libraries, and may lack some performance optimizations for the operating system, but can be tested, Easy to install. It is recommended that the corresponding installation package be selected according to the appropriate operating system version, such as CENTOS6 rhel6 select Rhel 6 Linux 64-bit, which is mongodb-linux-x86_64-rhel62-3.0.1.tgz this installation package.

Depending on the server's hard disk condition, where/home is the SSD,/data is the SSD/storage for the mechanical disk

[Email protected] ~]# DF-LH
Filesystem Size used Avail use% mounted on
/dev/sda2 197G 1.6G 186G 1%/
Tmpfs 63G 0 63G 0%/dev/shm
/DEV/SDA1 380M 70M 290M 20%/boot
/DEV/SDB1 733G 197M 696G 1%/data
/dev/sda5 410G 235M 389G 1%/Home
/DEV/SDC1 9.0T 40M 8.5T 1%/storage

Installing OpenSSL
#yum install-y Openssl-devel OpenSSL

# wget Https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.1.tgz
# tar XZVF mongodb-linux-x86_64-rhel62-3.0.1.tgz

# mkdir-p/home/local/
# MV Mongodb-linux-x86_64-rhel62-3.0.1/home/local/mongodb
# mkdir-p/data/mongodb
# mkdir-p/data/logs/mongodb
# Touch/data/logs/mongodb/mongodb.log
# Chmod-r 777/data/logs/mongodb/mongodb.log

Sets the value of Ulimit-n and ulimit-u greater than 20000. If the value of Ulimit is set too low, when MongoDB is in a state of frequent access, an error will result, resulting in the inability to connect to the MongoDB instance.
# Ulimit-n 25000
# Ulimit-u 25000

# cd/home/local/mongodb/bin/
# VI Mongodb.conf
port=20000 #端口
Dbpath=/data/mongodb #数据文件存放目录
Logpath=/data/logs/mongodb/mongodb.log #日志文件存放目录
Logappend=true #使用追加的方式写日志
Fork=true #以守护程序的方式启用, which runs in the background
maxconns=5000 #最大同时连接数 Default 2000
bind_ip=127.0.0.1,172.16.20.126 #只允许通过局域网IP: 172.16.20.126 and native access
Noauth=true #不启用验证
Nohttpinterface=true
Rest=false

Set up a firewall so that other servers within the LAN can access
Vi/etc/sysconfig/iptables

-A input-m state--state new-m tcp-p TCP--dport 20000-j ACCEPT

/etc/init.d/iptables restart

If you do not have the NUMACTL command, use Yum to install
Yum Install-y Numactl

To turn off Numa in proc
# echo 0 >/proc/sys/vm/zone_reclaim_mode
# sysctl-w Vm.zone_reclaim_mode=0


Start command:
# Numactl--interleave=all/home/local/mongodb/bin/mongod--config/home/local/mongodb/bin/mongodb.conf
Or
# Numactl--interleave=all/home/local/mongodb/bin/mongod-f/home/local/mongodb/bin/mongodb.conf

About-to-fork child process, waiting until server was ready for connections.
Forked process:25071
Child process started successfully, parent exiting


Normal Stop method:
# PS aux | grep Mongod
# Kill-2 PID
Or
#/home/local/mongodb/bin/mongo-port 20000
> Use admin
> Db.shutdownserver ();

2015-03-19t00:43:27.760+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' Always '.
2015-03-19t00:43:27.760+0800 I CONTROL [initandlisten] * * We suggest setting it to ' never '

Do not restart the server in case of a workaround, under Linux execution:
echo Never >/sys/kernel/mm/transparent_hugepage/enabled
echo Never >/sys/kernel/mm/transparent_hugepage/defrag

Immediate effect after server restart:
# vi/etc/rc.local
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


Boot auto Start MongoDB
# vi/etc/rc.d/rc.local
Rm-rf/data/mongodb/mongod.lock
Numactl--interleave=all/home/local/mongodb/bin/mongod-f/home/local/mongodb/bin/mongodb.conf

Description: Must be added Numactl--interleave=all Two, MongoDB 3.0 installation configuration at startup faqhttp://webprox.redstonesrv.fr/browse.php/qu6obihy/_2btwuwx/ rlznresq/miu7der5/iseotge5/jncv4que/lsbdvehs/w0d3g_3d/b29/

MongoDB 3.0 version installation media
MongoDB 3.0 version of the installation package is more granular than before, some friends may not understand the difference, a simple explanation:
Linux 64-bit Legacy This version of MONGODB-LINUX-X86_64-3.0.0.TGZ is not recommended for use in formal environments, this version features no SSL-related libraries, and may lack some performance optimizations for the operating system, but can be tested and easy to install. The
recommended installation package for the appropriate operating system version, such as CENTOS6 rhel6 select Rhel 6 Linux 64-bit, mongodb-linux-x86_64-rhel62-3.0.0.tgz this installation package.
A friend is not installed because a dependent library such as OpenSSL is also required to install the relevant libraries. The
is missing the OpenSSL-related library

, as shown below.

 LDD Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongodmongodb-linux-x86_64-rhel62-3.0.0/bin/mongod:/usr/lib64/ Libssl.so.10:no version information available (required by Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongod) Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongod:/usr/lib64/libcrypto.so.10:no version information available (required by Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongod) Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongod:/usr/lib64/ Libcrypto.so.10:no version information available (required by Mongodb-linux-x86_64-rhel62-3.0.0/bin/mongod) Linux-vdso.so.1 = (0x00007ffffd961000) libpthread.so.0 =/lib64/libpthread.so.0 (0x0000003d5b600000) libssl.so.10 =/usr/lib64/libssl.so.10 (0x0000003d62e00000) libcrypto.so.10 =/usr/lib64/libcrypto.so.10 ( 0x0000003d60e00000) librt.so.1 =/lib64/librt.so.1 (0x0000003d5be00000) libdl.so.2 =/lib64/libdl.so.2 ( 0x0000003d5ae00000) libstdc++.so.6 =/usr/lib64/libstdc++.so.6 (0x00000039bc800000) libm.so.6 =/lib64/ Libm.so.6 (0x0000003d5ba00000) libgcc_s.so.1 =/lib64/libgcc_s.so.1 (0x0000003d5ce00000) libc.so.6 =/lib64/libc.so.6 ( 0x0000003d5b200000)/lib64/ld-linux-x86-64.so.2 (0x0000003d5aa00000) libgssapi_krb5.so.2 =/lib64/libgssapi_ Krb5.so.2 (0x0000003d61a00000) libkrb5.so.3 =/lib64/libkrb5.so.3 (0x0000003d60a00000) libcom_err.so.2 =/ Lib64/libcom_err.so.2 (0x0000003d5e200000) libk5crypto.so.3 =/lib64/libk5crypto.so.3 (0x0000003d60600000) Libz.so.1 =/lib64/libz.so.1 (0x0000003d5c200000) libkrb5support.so.0 =/lib64/libkrb5support.so.0 ( 0x0000003d61e00000) libkeyutils.so.1 =/lib64/libkeyutils.so.1 (0x0000003d60200000) libresolv.so.2 =/lib64/ Libresolv.so.2 (0x0000003d5d600000) libselinux.so.1 =/lib64/libselinux.so.1 (0x0000003d5ca00000)

After installation

[root[@ccj-SF] (/user/ccj-sf) export]# ldd/export/mongodb/bin/mongodlinux-vdso.so.1 = (0x00007fff8f7ff000) libpthread.so.0 =/lib64/libpthread.so.0 (0x00007f6e0d5a9000) libssl.so.10 =/usr/lib64/libssl.so.10 ( 0x00007f6e0d33d000) libcrypto.so.10 =/usr/lib64/libcrypto.so.10 (0x00007f6e0cf59000) librt.so.1 =/lib64/ Librt.so.1 (0x00007f6e0cd51000) libdl.so.2 =/lib64/libdl.so.2 (0x00007f6e0cb4d000) libstdc++.so.6 =/usr/ Lib64/libstdc++.so.6 (0x00007f6e0c846000) libm.so.6 =/lib64/libm.so.6 (0x00007f6e0c5c2000) libgcc_s.so.1 =/ Lib64/libgcc_s.so.1 (0x00007f6e0c3ac000) libc.so.6 =/lib64/libc.so.6 (0x00007f6e0c017000)/lib64/ Ld-linux-x86-64.so.2 (0x00007f6e0d7cf000) libgssapi_krb5.so.2 =/lib64/libgssapi_krb5.so.2 (0x00007f6e0bdd3000) Libkrb5.so.3 =/lib64/libkrb5.so.3 (0x00007f6e0baed000) libcom_err.so.2 =/lib64/libcom_err.so.2 ( 0x00007f6e0b8e8000) libk5crypto.so.3 =/lib64/libk5crypto.so.3 (0x00007f6e0b6bc000) libz.so.1 =/lib64/ Libz.so.1 (0x00007f6e0b4a6000) libkrb5support.so.0 =/lib64/libkrb5support.so.0 (0x00007f6e0b29a000) libkeyutils.so.1 =/ Lib64/libkeyutils.so.1 (0x00007f6e0b097000) libresolv.so.2 =/lib64/libresolv.so.2 (0x00007f6e0ae7d000) Libselinux.so.1 =/lib64/libselinux.so.1 (0x00007f6e0ac5d000)

Configuration file
MMAPV1 engine, the configuration file is exactly the same as the 2.x version. Such as:

# cat mongod.cnf dbpath=/export/data/mongodb30/mongodlogpath=/export/data/mongodb30/log/mongod.logpidfilepath=/export/data/mongodb30/pid/mongod.piddirectoryperdb=truereplSet=a3logappend=truekeyFile=/export/data/mongodb30/keyport=20000fork=true

Wiretiger engine configuration to increase the relevant parameters, take the replica set as an example, such as:

# cat mongod.cnf dbpath=/export/data/mongodb30/mongodlogpath=/export/data/mongodb30/log/mongod.logpidfilepath=/export/data/mongodb30/pid/mongod.piddirectoryperdb=truereplSet=a3logappend=truekeyFile=/export/data/mongodb30/keyport=20000fork=truestorageEngine=wiredTigerwiredTigerCacheSizeGB=10wiredTigerStatisticsLogDelaySecs=0wiredTigerJournalCompressor=snappywiredTigerDirectoryForIndexes=truewiredTigerCollectionBlockCompressor=snappywiredTigerIndexPrefixCompression=1

YAML Format configuration file:
The 2.6 version was introduced with the above replica set as an example:

$ cat mongodb.cnf systemLog: destination: file path: /export/data/mongodb30/log/mongod.log logAppend: truestorage: journal:  enabled: true dbPath: /export/data/mongodb30/mongod directoryPerDB: true engine: wiredTiger wiredTiger:  engineConfig:   cacheSizeGB: 10   directoryForIndexes: true  collectionConfig:   blockCompressor: snappy  indexConfig:   prefixCompression: truenet: port: 20000replication: replSetName: a3 security: keyFile: /export/data/mongodb30/keyprocessManagement: pidFilePath: /export/data/mongodb30/pid/mongod.pid fork: true setParameter:   enableLocalhostAuthBypass: false

Single machine remove replication and keyfile settings, shards add some parameters, such as:
Mongod Increase

sharding: clusterRole: shardsvr

Configer Server

sharding: clusterRole: configsvr

Reference:
http://docs.mongodb.org/manual/reference/configuration-options/

CentOS installation MongoDB

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.