In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
First of all, download the mongodb installation package http://www.mongodb.org/downloads from the official website. My system is redhat5.8. All choose the corresponding version package, ok. Now the latest version is 3.0.3.
Decompress mongodb-linux-x86_64-rhel55-3.0.3.tgz
[root@mongodb] # tar zxvf mongodb-linux-x86_64-rhel55-3.0.3.tgz-C / opt/mongodb-linux-x86_64-rhel55-3.0.3/READMEmongodb-linux-x86_64-rhel55-3.0.3/THIRD-PARTY-NOTICESmongodb-linux-x86_64-rhel55-3.0.3/GNU-AGPL-3.0mongodb-linux-x86_64-rhel55-3.0.3/bin/mongodumpmongodb-linux-x86_64-rhel55-3.0 .3 / bin/mongorestoremongodb-linux-x86_64-rhel55-3.0.3/bin/mongoexportmongodb-linux-x86_64-rhel55-3.0.3/bin/mongoimportmongodb-linux-x86_64-rhel55-3.0.3/bin/mongostatmongodb-linux-x86_64-rhel55-3.0.3/bin/mongotopmongodb-linux-x86_64-rhel55-3.0.3/bin/bsondumpmongodb-linux-x86_64-rhel55-3.0.3/bin/mongofilesmongodb-linux-x86_64 -rhel55-3.0.3/bin/mongooplogmongodb-linux-x86_64-rhel55-3.0.3/bin/mongoperfmongodb-linux-x86_64-rhel55-3.0.3/bin/mongodmongodb-linux-x86_64-rhel55-3.0.3/bin/mongosmongodb-linux-x86_64-rhel55-3.0.3/bin/mongo [root@mongodb opt] # ln-sv mongodb-linux-x86_64-rhel55-3.0.3 / mongodbcreate symbolic link `mongodb' to `mongodb-linux- X86_64-rhel55-3.0.3cusp'
3. Create a mongodb user
[root@mongodb /] # useradd mongodb
4. Create the appropriate file directory and modify permissions
[root@mongodb /] # mkdir / data/db-p [root@mongodb /] # chown mongodb:mongodb / data/-R [root@mongodb opt] # chown-R mongodb:mongodb / opt/*
5. Add PATH environment variables to the utility that accesses mongodb normally under shell
[root@mongodb bin] # vim / etc/profile.d/mongodb.shexport PATH=$PATH:/opt/mongodb/bin [root@mongodb bin] # source / etc/profile.d/mongodb.sh [root@mongodb bin] # echo $PATH / usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/opt/mongodb/bin
6. Create a PID storage directory for mongodb
[root@mongodb run] # mkdir / var/run/mongodb [root@mongodb run] # chown mongodb:mongodb / var/run/mongodb/-R [root@mongodb opt] # mongod-dbpath / data/db/-logpath / var/log/mongodb.log-logappend-port 27017-pidfilepath / var/run/mongodb/mongodb.pid-maxConns 27017-rest-httpinterface-forkabout to fork child process, waiting until server is ready for connections.forked process: 4060child process started successfully Parent exiting--maxConns: indicates that the maximum number of connections is 250-- rest-- httpinterface: web interface Specify this port 28017 to enable-- fork: run in the background
7. Problems encountered during installation
After installation, the following warning appears on the connection
(1). [root@mongodb] # mongoMongoDB shell version: 3.0.3connecting to: testServer has startup warnings: 2015-06-15T20:27:49.892+0800 I CONTROL [initandlisten] * * WARNING: You are running this process as the root user, which is not recommended.2015-06-15T20:27:49.892+0800 I CONTROL [initandlisten]
When this problem occurs, check the file permissions about mongodb, mainly the permissions of / opt / data/db/ / var/run/mongodb/ / var/log/mongodb.log. Because the initialization is running with the privileges of the root user, the permissions under these directories may become root root.
[mongodb@mongodb db] $mongod-- dbpath / data/db/-- logpath / var/log/mongodb.log-- logappend-- port 27017-- pidfilepath / var/run/mongodb/mongodb.pid-- maxConns 250-- rest-- httpinterface-- fork2015-06-15T17:41:25.721+0800 I CONTROL [initandlisten] * * WARNING: / sys/kernel/mm/transparent_hugepage/enabled is' always'.2015-06-15T17:41:25.721+0800 I CONTROL [initandlisten ] * * We suggest setting it to 'never'2015-06-15T17:41:25.721+0800 I CONTROL [initandlisten] 2015-06-15T17:41:25.721+0800 I CONTROL [initandlisten] * * WARNING: / sys/kernel/mm/transparent_hugepage/defrag is' always'.2015-06-15T17:41:25.721+0800 I CONTROL [initandlisten] * * We suggest setting it to 'never'
You can modify two parameters.
Echo "never" > / sys/kernel/mm/transparent_hugepage/enabled echo "never" > / sys/kernel/mm/transparent_hugepage/defrag
8. Install successfully and log in
[root@mongodb ~] # ss-tanlp | grep mongod0 0 *: 27017 *: * users: (("mongod", 4095 mongod 6)) 0 *: 28017 *: * users: (("mongod") 4) [root@mongodb ~] # mongoMongoDB shell version: 3.0.3connecting to: test > help db.help () help on db methods db.mycoll.help () help on collection methods sh.help () sharding helpers rs.help () replica set helpers help admin administrative help help connect Connecting to a db help help keys key shortcuts help misc misc things to know help mr mapreduce show dbs show database names show collections show collections in current database show users show users in current database show profile show most recent system.profile entries with time > = 1ms show logs show the accessible logger names show log [name] prints out the last segment of log in memory 'global' is default use set current database db.foo.find () list objects in collection foo db.foo.find ({a: 1}) list objects in foo where a = = 1 it result of the last line evaluated Use to further iterate DBQuery.shellBatchSize = x set default number of items to display on shell exit quit the mongo shell
Log in to port 28017 of web interface
9. Shut down the server
(1). [root@mongodb] # mongod-- shutdown killing process with pid: 3936 (2). [root@mongodb ~] # killall mongod
10. Write a configuration file / etc/mongodb.conf for mongodb
[root@mongodb ~] # grep-v ^ # / etc/mongodb.conf logpath=/var/log/mongodb.loglogappend=truefork = truedbpath=/data/dbpidfilepath = / var/run/mongodb/mongodb.pidrest = truehttpinterface = true
Start
[root@mongodb ~] # mongod-f / etc/mongodb.conf about to fork child process, waiting until server is ready for connections.forked process: 4169child process started successfully, parent exiting [root@mongodb ~] # ss-tanlp | grep mongod0 0 *: 27017 *: * users: ("mongod" (4169 mongod 6)) 0 *: 28017 *: * users: (("mongod", 4169 force 8))
11. Start mongodb with service mongodb *
Startup script: / etc/rc.d/init.d/mongod
#! / bin/bash# mongod-Startup script for mongod# chkconfig: 35 85 "description: Mongo is a scalable, document-oriented database.# processname: mongod# config: / etc/mongod.conf# pidfile: / var/run/mongo/mongod.pid. / etc/rc.d/init.d/functions# things from mongod.conf get there by mongod reading itCONFIGFILE= "/ etc/mongodb.conf" OPTIONS= "- f $CONFIGFILE" SYSCONFIG= "/ etc/sysconfig/mongod" DBPATH= `awk-F ='/ ^ dbpath=/ {print $2}'"$CONFIGFILE" `PIDFILE= `awk-F ='/ ^ dbpath\ s =\ s / {print $2}'"$CONFIGFILE" `mongod=$ {MONGOD-/opt/mongodb/bin/mongod} MONGO_USER=mongodbMONGO_GROUP=mongodbif [- f "$SYSCONFIG"]; then. "$SYSCONFIG" fi# Handle NUMA access to CPUs (SERVER-3574) # This verifies the existence of numactl as well as testing that the command worksNUMACTL_ARGS= "- interleave=all" if which numactl > / dev/null 2 > / dev/null & & numactl $NUMACTL_ARGS ls / > / dev/null 2 > / dev/nullthen NUMACTL= "numactl $NUMACTL_ARGS" else NUMACTL= "fistart () {echo-n $" Starting mongod: "daemon-user" $MONGO_USER "$NUMACTL $mongod $OPTIONS RETVAL=$? Echo [$RETVAL-eq 0] & & touch / var/lock/subsys/mongod} stop () {echo-n $"Stopping mongod:" killproc-p "$PIDFILE"-d 300 / opt/mongodb/bin/mongod RETVAL=$? Echo [$RETVAL-eq 0] & & rm-f / var/lock/subsys/mongod} restart () {stop start} ulimit-n 12000RETVAL=0case "$1" in start) start;; stop) stop;; restart | reload | force-reload) restart;; condrestart) [- f / var/lock/subsys/mongod] & restart | |:; status) status $mongod RETVAL=$? *) echo "Usage: $0 {start | stop | status | restart | reload | force-reload | condrestart}" RETVAL=1esacexit $RETVAL
Test start
[root@mongodb ~] # service mongod startStarting mongod: about to fork child process, waiting until server is ready for connections.forked process: 4426child process started successfully, parent exiting [OK] [root@mongodb init.d] # ss-tanlp | grep mongod0 0 *: 27017 *: * users: ("mongod" 4426 mongoMongoDB shell version 6)) 0 *: 28017 *: * users: ("mongod", 4426 ~ 8)) [root@mongodb ~] # mongoMongoDB shell version: 3.0.3connecting to: test > [root@mongodb ~] # service mongod startStarting mongod: about to fork child process Waiting until server is ready for connections.forked process: 4426child process started successfully, parent exiting [OK] [root@mongodb ~] # service mongod stopStopping mongod: [OK]
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.