MongoDB installation and resolution of existing problems (warning)

Source: Internet
Author: User
Tags install mongodb mkdir mongodb openssl openssl version

Environment

OS: CentOS 6.5 x64

MongoDB: 3.2.7

MongoDB cluster installation can refer to: http://blog.csdn.net/john_chang11/article/details/51733670

2. Download mongodb
https://www.mongodb.com/download-center?jmp=nav#community
[root @ VM6-56 ~] $ curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.7.tgz
  % Total% Received% Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
  0 71.6M 0 527k 0 0 25212 0 0:49:40 0:00:21 0:49:19 23015

3. Install mongodb
[root @ VM6-56 ~] # groupadd mongodb
[root @ VM6-56 ~] # useradd -g mongodb mongodb
[root @ VM6-56 ~] # passwd mongodb
[root @ VM6-56 ~] # mkdir / u01 / mongodb -p
[root @ VM6-56 ~] # chown mongodb.mongodb / u01 / mongodb
[root @ VM6-56 ~] # chown mongodb.mongodb mongodb-linux-x86_64-3.2.7.tgz
[root @ VM6-56 ~] # mv mongodb-linux-x86_64-3.2.7.tgz / u01 / mongodb
[root @ VM6-56 ~] # su-mongodb
[mongodb @ VM6-56 ~] $ cd / u01 / mongodb
[mongodb @ VM6-56 mongodb] $ tar -zxvf mongodb-linux-x86_64-3.2.7.tgz
[mongodb @ VM6-56 mongodb] $ mv mongodb-linux-x86_64-rhel62-3.2.7 mongodb327
[mongodb @ VM6-56 mongodb] $ cd
[mongodb @ VM6-56 mongodb] $ vi .bash_profile
export PATH = / u01 / mongodb / mongodb327 / bin: $ PATH: $ HOME / bin

3. Create a directory
[mongodb @ VM6-56 mongodb] $ pwd
/ u01 / mongodb
[mongodb @ VM6-56 mongodb] $ mkdir mongodb #Create the base directory of mongodb
[mongodb @ VM6-56 mongodb] $ cd mongodb
[mongodb @ VM6-56 mongodb] $ mkdir data logs conf #create data log configuration directory
[mongodb @ VM6-56 mongodb] $ cd data
[mongodb @ VM6-56data] $ mkdir mongo #Create shard data directory


4. Configuration file
The start of mongod needs to specify various parameters. These parameters can be written in the file or specified on the command line. Here is the way to write in the file:
[mongodb @ VM6-56 mongodb] $ cd conf
[mongodb @ VM6-56 conf] $ vi mongo.conf
port = 32001 #port
dbpath = / u01 / mongodb / mongodb / data / mongo #data directory
logpath = /u01/mongodb/mongodb/logs/mongo.log #log file
logappend = true #log record
pidfilepath = /u01/mongodb/mongodb/logs/mongo.pid #pid file location
directoryperdb = true
oplogSize = 1024 #Operation log size, the unit is M
fork = true # standalone process running
storageEngine = wiredTiger #New storage engine
#journal = true #Whether to log

5. Run
[mongodb @ VM6-56 ~] $ mongod -f /u01/mongodb/mongodb/conf/mongo.conf
about to fork child process, waiting until server is ready for connections.
forked process: 18789
child process started successfully, parent exiting
Start successfully, check the log, the location of the log file is specified in the parameter file:
[mongodb @ VM6-56 logs] $ cat mongo.log
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] MongoDB starting: pid = 19659 port = 31001 dbpath = / u01 / mongodb / mongodb / data / shard1 64-bit host = VM6-56
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] db version v3.2.7
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] modules: none
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] build environment:
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] distmod: rhel62
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] distarch: x86_64
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] target_arch: x86_64
2016-06-25T20: 36: 24.508 + 0800 I CONTROL [initandlisten] options: {config: "/u01/mongodb/mongodb/conf/mongo.cnf", net: {port: 32001}, processManagement: {fork: true , pidFilePath: "/u01/mongodb/mongodb/logs/mongo.pid"}, replication: {oplogSizeMB: 1024}, storage: {dbPath: "/ u01 / mongodb / mongodb / data / mongo", directoryPerDB: true, engine : "wiredTiger"}, systemLog: {destination: "file", logAppend: true, path: "/u01/mongodb/mongodb/logs/mongo.log"}}
2016-07-03T21: 53: 03.443 + 0800 I STORAGE [initandlisten] wiredtiger_open config: create, cache_size = 18G, session_max = 20000, eviction = (threads_max = 4), config_base = false, statistics = (fast), log = ( enabled = true, archive = true, path = journal, compressor = snappy), file_manager = (close_idle_time = 100000), checkpoint = (wait = 60, log_size = 2GB), statistics_log = (wait = 0),
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten]
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** WARNING: You are running on a NUMA machine.
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** We suggest launching mongod like this to avoid performance problems:
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** numactl --interleave = all mongod [other options]
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten]
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** WARNING: / sys / kernel / mm / transparent_hugepage / enabled is 'always'.
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten]
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** WARNING: / sys / kernel / mm / transparent_hugepage / defrag is 'always'.
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [ini
tandlisten]
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Rlimits set to 1024 processes, 655350 files. Number of processes should be at least 327675: 0.5 times number of files.
2016-06-25T20: 36: 25.172 + 0800 I CONTROL [initandlisten]
2016-06-25T20: 36: 25.175 + 0800 I REPL [initandlisten] Did not find local voted for document at startup; NoMatchingDocument: Did not find replica set lastVote document in local.replset.election
2016-06-25T20: 36: 25.175 + 0800 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2016-06-25T20: 36: 25.176 + 0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/u01/mongodb/mongodb/data/shard1/diagnostic.data'
2016-06-25T20: 36: 25.176 + 0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-06-25T20: 36: 25.177 + 0800 I NETWORK [initandlisten] waiting for connections on port 31001
The content of the log is particularly important. It needs to be read carefully and paid special attention. Here we focus on the three warnings in the above log:
 ** WARNING: You are running on a NUMA machine.
 ** We suggest launching mongod like this to avoid performance problems:
 ** numactl --interleave = all mongod [other options]
 ** WARNING: / sys / kernel / mm / transparent_hugepage / enabled is 'always'.
 ** We suggest setting it to 'never'
 ** WARNING: / sys / kernel / mm / transparent_hugepage / defrag is 'always'.
 ** We suggest setting it to 'never'
 ** WARNING: soft rlimits too low. Rlimits set to 1024 processes, 655350 files. Number of processes should be at least 327675: 0.5 times number of files.
Solve the second and third warnings, switch to the root user and execute:
[root @ VM6-56 ~] # echo "never"> / sys / kernel / mm / transparent_hugepage / enabled
[root @ VM6-56 ~] # echo "never"> / sys / kernel / mm / transparent_hugepage / defrag
To resolve the fourth warning, switch to the mongodb user and execute:
[mongodb @ VM6-56 ~] $ vi .bash_profile #Add at the end of the file:
ulimit -f unlimited -t unlimited -v unlimited -n 64000 -u 64000
Solving the first warning is to change the way mongod is started:
[mongodb @ VM6-56 ~] $ numactl --interleave = all mongod -f /u01/mongodb/mongodb/conf/shard1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 6426
ERROR: child process failed, exited with error number 48
Report an error, check the log:
[mongodb @ VM6-56 logs] $ tail /u01/mongodb/mongodb/logs/shard1.log
2016-06-26T14: 31: 46.500 + 0800 E NETWORK [initandlisten] listen (): bind () failed errno: 98 Address already in use for socket: 0.0.0.0:31001
2016-06-26T14: 31: 46.500 + 0800 E NETWORK [initandlisten] addr already in use
2016-06-26T14: 31: 46.500 + 0800 E STORAGE [initandlisten] Failed to set up sockets during startup.
2016-06-26T14: 31: 46.500 + 0800 I CONTROL [initandlisten] dbexit: rc: 48
According to the logs, the cause of the error is addr already in use, which is because the mongod process is running and needs to be closed first:
[root @ VM6-56 ~] # ps -ef | grep mongo
root 8083 6176 0 14:40 pts / 0 00:00:00 grep mongo
mongodb 18813 1 0 Jun25? 00:04:11 mongod -f /u01/mongodb/mongodb/conf/shard2.conf
mongodb 19659 1 0 Jun25? 00:04:10 mongod -f /u01/mongodb/mongodb/conf/shard1.conf
[root @ VM6-56 ~] # kill 19659
[root @ VM6-56 ~] # ps -ef | grep mongo
root 8182 6176 0 14:40 pts / 0 00:00:00 grep mongo
mongodb 18813 1 0 Jun25? 00:04:11 mongod -f /u01/mongodb/mongodb/conf/shard2.conf
Start again:
[mongodb @ VM6-56 ~] $ numactl --interleave = all mongod -f /u01/mongodb/mongodb/conf/shard1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 8699
child process started successfully, parent exiting
Started successfully, check the log again to see if there is no warning message:
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] MongoDB starting: pid = 8699 port = 31001 dbpath = / u01 / mongodb / mongodb / data / shard1 64-bit host = VM6-56
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] db version v3.2.7
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] git version: 4249c1d2b5999ebbf1fdf3bc0e0e3b3ff5c0aaf2
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] allocator: tcmalloc
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] modules: none
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] build environment:
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] distmod: rhel62
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] distarch: x86_64
2016-06-26T14: 43: 18.705 + 0800 I CONTROL [initandlisten] target_arch: x86_64
2016-06-26T14: 43: 18.706 + 0800 I CONTROL [initandlisten] options: {config: "/u01/mongodb/mongodb/conf/mongo.cnf", net: {port: 32001}, processManagement: {fork: true , pidFilePath: "/u01/mongodb/mongodb/logs/mongo.pid"}, replication: {oplogSizeMB: 1024}, storage: {dbPath: "/ u01 / mongodb / mongodb / data / mongo", directoryPerDB: true, engine : "wiredTiger"}, systemLog: {destination: "file", logAppend: true, path: "/u01/mongodb/mongodb/logs/mongo.log"

}}
2016-07-03T21: 53: 03.443 + 0800 I STORAGE [initandlisten] wiredtiger_open config: create, cache_size = 18G, session_max = 20000, eviction = (threads_max = 4), config_base = false, statistics = (fast), log = ( enabled = true, archive = true, path = journal, compressor = snappy), file_manager = (close_idle_time = 100000), checkpoint = (wait = 60, log_size = 2GB), statistics_log = (wait = 0),
2016-06-26T14: 43: 19.452 + 0800 I REPL [initandlisten] Did not find local voted for document at startup; NoMatchingDocument: Did not find replica set lastVote document in local.replset.election
2016-06-26T14: 43: 19.452 + 0800 I REPL [initandlisten] Did not find local replica set configuration document at startup; NoMatchingDocument: Did not find replica set configuration document in local.system.replset
2016-06-26T14: 43: 19.453 + 0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/u01/mongodb/mongodb/data/shard1/diagnostic.data'
2016-06-26T14: 43: 19.453 + 0800 I NETWORK [HostnameCanonicalizationWorker] Starting hostname canonicalization worker
2016-06-26T14: 43: 19.455 + 0800 I NETWORK [initandlisten] waiting for connections on port 31001
(END)
No previous warning message this time.


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.