Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
TetraWiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Mongo DB Doc Prepared @ AIRTEL for DT Project
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
<center>'''MongoDB installation and configuration guide'''</center> '''Note:- Make sure that when u do any configuration on mongo database server. Stop the server before working on it.''' 1.Use below command to download the mongo database. curl -O [http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz http://downloads.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz] 2. Extract the downloded file to specified location <nowiki>[root@DTdb opt]# </nowiki>tar -zxvf mongodb-linux-x86_64-2.4.9.tgz 3. Rename the extracted file. PFB <nowiki>[root@DTdb opt]#</nowiki>mv mongodb-linux-i686-2.4.9 mongodb 4. Create directory inside the mongodb folder <nowiki>[root@DTdb mongodb]#</nowiki> mkdir conf <nowiki>[root@DTdb mongodb]#</nowiki>mkdir data 5. Create a file under the conf directory <nowiki>[root@DTdb mongodb]# </nowiki>vim soptree.conf <nowiki>##insert the below entries on that file.##</nowiki> verbose = true vvvv = true port = 27017 <nowiki>#bind_ip = 127.0.0.1</nowiki> logpath = /opt/mongodb/db.log logappend = true fork = true auth = true dbpath = /opt/mongodb/data/ 6. Create Rc script for the mongodb <nowiki>[root@DTdb conf]# </nowiki>vim /etc/init.d/mongodb <nowiki>#!/bin/bash</nowiki> <nowiki>#</nowiki> <nowiki># mongodb </nowiki>Startup script for the mongodb server <nowiki>#</nowiki> <nowiki># chkconfig: - 64 36</nowiki> <nowiki># description: MongoDB Database Server</nowiki> <nowiki>#</nowiki> <nowiki># processname: mongodb</nowiki> <nowiki>#</nowiki> <nowiki># Source function library</nowiki> . /etc/rc.d/init.d/functions <nowiki>if [ -f /etc/sysconfig/mongodb ]; then</nowiki> . /etc/sysconfig/mongodb fi prog="mongod" mongod="/opt/mongodb/bin/mongod -config /opt/mongodb/conf/soptree.conf" <nowiki>#mongod="/opt/mongodb/bin/mongod"</nowiki> RETVAL=0 start() { echo -n $"Starting $prog: " <nowiki>#daemon $mongod "--fork --logpath /var/log/mongodb.log --logappend 2>&1 >>/var/log/mongodb.log"</nowiki> daemon $mongod "--fork --logpath /opt/mongodb/db.log --logappend 2>&1 >>/opt/mongodb/db.log" RETVAL=$? echo <nowiki>[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog</nowiki> return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $prog RETVAL=$? echo <nowiki>[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog</nowiki> return $RETVAL } reload() { echo -n $"Reloading $prog: " killproc $prog -HUP RETVAL=$? echo return $RETVAL } case "$1" in start) start <nowiki>;;</nowiki> stop) stop <nowiki>;;</nowiki> restart) stop start <nowiki>;;</nowiki> condrestart) <nowiki>if [ -f /var/lock/subsys/$prog ]; then</nowiki> stop start fi <nowiki>;;</nowiki> reload) reload <nowiki>;;</nowiki> status) status $mongod RETVAL=$? <nowiki>;;</nowiki> <nowiki>*)</nowiki> echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}" RETVAL=1 esac exit $RETVAL Then save and quit the file. 7. Copy the database from remote location to this server. Then do following steps. # Shutdown the MongoDB server # ## cd /opt/mongodb/bin ## ./mongo ## db.shutdownServer() ## exit # copy existing copy of backup folder into “backup” # ## cd /opt/mongodb/bin ## mkdir backup ## <nowiki><copy backup files from source machine to ../bin/backup folder></nowiki> ## ./mongorestore –dbpath /opt/mongodb/data/ -o /opt/mongodb/bin/backup # Restart MongoDb server ## /etc/init.d/mongodb start 8. Create the user for database. Do following steps. # cd /opt/mongodb/bin # ./mongo # use soptree # db.addUser(“admin”,”@irTel#321”) '''How to configure Master-Slave for MongoDB:-''' Reference:- [https://library.linode.com/databases/mongodb/clusters#sph_configure-master-slave-replication https://library.linode.com/databases/mongodb/clusters#sph_configure-master-slave-replication] '''On Master Node:-''' Go to RootDirectory and edit below file. RootDirectory:- /home/mongodb vim /home/mongodb/conf/soptree.conf dbpath = /home/mongodb/data ( define data location where all data will be alien) logpath = /home/mongodb/db.log(define log location and log file name) logappend = true bind_ip = 10.56.139.68(master server ip) port = 27017 fork = true auth = true <nowiki># noauth = true</nowiki> master = true( cluster status) '''On Slave Node''':- dbpath = /home/mongodb/data( define data location where all data will be alien) logpath = /home/mongodb/db.log(define log location and log file name) logappend = true bind_ip = 10.56.139.69(Slave node ip) port = 27017 fork = true auth = true <nowiki># noauth = true</nowiki> slave = true(Cluster status) autoresync = true source = 10.56.139.68:27017(Master’s node ip and port number) Now Restart service on both nodes
Summary:
Please note that all contributions to TetraWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
TetraWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)