In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
MongoDB Master-Slave
System: Centos 6.6x64
Installation directory: /usr/local/
Master: 172.16.15.101
From: 172.16.15.102
1. Download and install:
# wget https://fastdl.mongodb.org/src/mongodb-src-r3.2.7.tar.gz?_ ga=1.217384598.1880361485.1476164670
New Version # wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.9.tgz
# tar -xf mongodb-linux-x86_64-3.2.7.tgz
# mv mmongodb-linux-x86_64-3.2.7 /usr/local/mongodb
2,mongodb environment variable configuration
# cat /etc/profile
# export PATH=$PATH:/usr/local/mongodb/bin
# source /etc/profile
3,iptables/selinux and kernel settings:
# cat /etc/sysconfig/iptables
-A INPUT -p tcp -m state --state NEW -m tcp --dport 28017 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 27017 -j ACCEPT
# sed "s/SELINUX=enables/SELINUX=disabled/g" /etc/sysconfig/selinux
SELINUX=disabled
# cat >>/etc/rc.d/rc.local /sys/kernel/mm/transparent_hugepage/defrag
HERE
4. Create a file storage directory:
# mkdir -p /usr/local/mongodb/{log,db,conf}
Main Service: 172.16.15.101
5,mongod.conf Reference Configuration;
### ****
systemLog:
destination: file
logAppend: true
logRotate: rename
timeStampFormat: ctime
path: /usr/local/mongodb/log/mongod.log
storage:
dbPath: /usr/local/mongodb/db
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /usr/local/mongodb/mongod.pid # location of pidfile
net:
port: 27017
#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
http:
enabled: true
JSONPEnabled: true
RESTInterfaceEnabled: true
setParameter:
enableLocalhostAuthBypass: false
master = true #
# source = 172.16.15.102 #from the service address do not configure
Some parameters are explained//attachments have official configuration files
--fork #background daemon running
--bind_ip #Listen to a comma-separated list of IP addresses
--port #listening port, default 27017
--setParameter enableLocalhostAuthBypass=0 #All interfaces require authentication
--pidfilepath #pid file
--dbpath #db Storage path
--logpath #log file
--config #configuration file
--auth #Enable authentication
--httpinterface #Enable web interface
--rest #rest api
--jsonp #json api
From Service: 172.16.15.102
6, mongod.conf reference configuration;
### ****
systemLog:
destination: file
logAppend: true
logRotate: rename
timeStampFormat: ctime
path: /usr/local/mongodb/log/mongod.log
storage:
dbPath: /usr/local/mongodb/db
journal:
enabled: true
processManagement:
fork: true # fork and run in background
pidFilePath: /usr/local/mongodb/mongod.pid # location of pidfile
net:
port: 27017
#bindIp: 127.0.0.1 # Listen to local interface only, comment to listen on all interfaces.
http:
enabled: true
JSONPEnabled: true
RESTInterfaceEnabled: true
setParameter:
enableLocalhostAuthBypass: false
slave = true #
source = 172.16.15.101 #
7, Start from Server
/usr/local/mongodb/bin/mongod --fork --slave --source 172.16.15.101:27017 --port 27017 --dbpath /usr/local/mongodb/db --logpath /usr/local/mongodb/log/mongodb.log
8, Start detecting mongod process and port
# mongod --fork --httpinterface --rest --jsonp --setParameter enableLocalhostAuthBypass=0 --pidfilepath /usr/local/mongodb/mongod.pid --dbpath /usr/local/mongodb/db --logpath /usr/local/mongodb/log/mongod.log --logappend --logRotate rename --timeStampFormat ctime
The main configuration file log process port starts well;
Start of the Lord:
/usr/local/mongodb/bin/mongod --fork --master --oplogSize=1024 --port 27017 --dbpath /usr/local/mongodb/db --logpath /usr/local/mongodb/log/mongodb.log
# ps -ef|grep mongod
# netstat -tunlp|grep mongod
9,init.d/mongod autocontrol script
# useradd -s /sbin/nologin -r mongod
# chown -R mongod: /usr/local/mongodb
# /etc/init.d/mongod
// * This attachment has official configuration information
# chmod +x /etc/init.d/mongod
// * Configuration directory needs to change
# sed -i '/CONFIGFILE=/i MONGOD="/usr/local/mongodb/bin/mongod"' /etc/init.d/mongod
# sed -i '/CONFIGFILE=/s:/etc/mongod.conf:/usr/local/mongodb/conf/mongod.conf:g' /etc/init.d/mongod
Attachment: down.51cto.com/data/2368237
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.