MongoDB pseudo-Replica set cluster construction

Source: Internet
Author: User
Tags mongodb snmp

Reference article: http://www.cnblogs.com/kevingrace/p/5685486.html
Download MongoDB and Unzip

https://www.mongodb.com/download-center/enterprise/releases
tar -zxvf mongodb-linux-x86_64-enterprise-rhel70-3.6.5.tgz

Renaming

mv mongodb-linux-x86_64-enterprise-rhel70-3.6.5 mongo1

Setting environment variables

echo -e "# append mongodb_env\nexport PATH=$PATH:/software/mongo1/bin" >> /etc/profile

Immediate effect

source /etc/profile

Switch to the MONGO1 directory to create a data store directory

mkdir datamkdir logstouch keyfilechmod 666 keyfile

Enter the logs directory to create the log file

touch m.log

Installing NET-SNMP

yum install net-snmp

Start the service

./mongod --dbpath /software/mongo1/data --logpath /software/mongo1/log/m.log --port 27017 --fork --smallfiles

Stop the MONGO process

pkill -9 mongo

Copy Mongo2, Mongo3

cp -rf mongo1 mongo2cp -rf mongo1 mongo3

Start three services separately

./mongod --dbpath /software/mongo1/data --logpath /software/mongo1/log/m.log --bind_ip 0.0.0.0 --port 27017 --fork --smallfiles --replSet rs01./mongod --dbpath /software/mongo2/data --logpath /software/mongo2/log/m.log --bind_ip 0.0.0.0 --port 27018 --fork --smallfiles --replSet rs01./mongod --dbpath /software/mongo3/data --logpath /software/mongo3/log/m.log --bind_ip 0.0.0.0 --port 27019 --fork --smallfiles --replSet rs01

Configuring replica sets, initializing replica sets

#登录任何一台机器 [[email protected] bin]#./mongo 10.0.117.129:27017mongodb Shell version v3.6.5connecting to:mongodb:// 10.0.117.129:27017/testmongodb server version:3.6.5welcome to the MongoDB shell. For interactive help, type ' help '. For more comprehensive documentation, see http://docs.mongodb.org/Questions? Try the support group Http://groups.google.com/group/mongodb-userServer have startup warnings:2018-06-21t13:25:52.561+ 0800 I control [Initandlisten] 2018-06-21t13:25:52.561+0800 i control [initandlisten] * * warning:access CONTROL is not  Enabled for the database.2018-06-21t13:25:52.561+0800 I CONTROL [initandlisten] * * Read and Write access to data and configuration is unrestricted.2018-06-21t13:25:52.561+0800 I CONTROL [initandlisten] * * warning:you is running thi s process as the root user, which is not recommended.2018-06-21t13:25:52.561+0800 I CONTROL [Initandlisten] 2018-06-21t13 : 25:52.561+0800 i CONTROL [Initandlisten] 2018-06-21t13:25:52.561+0800 i CONTROL [Initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' always '. 2018-06-21t13:25:52.561+0800 I control [initandlisten] * * We suggest setting it to ' Never ' 2018-06-21t13:25:52.561+0800 I control [Initandliste N] 2018-06-21t13:25:52.561+0800 I CONTROL [initandlisten] * * WARNING:/sys/kernel/mm/transparent_hugepage/defrag is ' Always '. 2018-06-21t13:25:52.561+0800 I CONTROL [initandlisten] * * We suggest setting it to ' Never ' 2018-06-21t13:25  : 52.561+0800 I CONTROL [Initandlisten]

Switch to the admin database

MongoDB Enterprise > use adminswitched to db admin
#配置副本集MongoDB Enterprise > var rsconf={ _id:"rs01", members:[ {"_id" : 0, "host" : "10.0.117.129:27017"}, {"_id" : 1, "host" : "10.0.117.129:27018"}, {"_id" : 2, "host" : "10.0.117.129:27019"} ] }#初始化副本集MongoDB Enterprise > rs.initiate(rsconf){    "ok" : 1,    "operationTime" : Timestamp(1529559644, 1),    "$clusterTime" : {        "clusterTime" : Timestamp(1529559644, 1),        "signature" : {            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),            "keyId" : NumberLong(0)        }    }}

MongoDB pseudo-Replica set cluster construction

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.