Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongo replica set cluster installation configuration

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

New users and directories

Useradd mongodb

Mkdir-p / comm/mg10000/data

Mkdir-p / comm/mg10001/data

Mkdir-p / comm/mg10002/data

Mkdir-p / comm/mg10000/log

Mkdir-p / comm/mg10001/log

Mkdir-p / comm/mg10002/log

Mkdir-p / comm/mongodb

Chown-R mongodb:mongodb / comm/*

Software installation

Https://www.mongodb.org/dl/linux/

Tar zxvf mongodb-linux-x86_64-rhel70-v3.0-latest.tgz

Mv mongodb-linux-x86_64-rhel70-3.0.15-9-g0513806/ / comm/mongodb/3.0

Process start

Export PORT=10000

MONGODB_HOME/bin/mongod-- fork-- dbpath / comm/mg$ {PORT} / data-- logpath=/comm/mg$ {PORT} / log/mg$ {PORT} .log-- port ${PORT}-- replSet repset

Export PORT=10001

MONGODB_HOME/bin/mongod-- fork-- dbpath / comm/mg$ {PORT} / data-- logpath=/comm/mg$ {PORT} / log/mg$ {PORT} .log-- port ${PORT}-- replSet repset

Export PORT=10002

MONGODB_HOME/bin/mongod-- fork-- dbpath / comm/mg$ {PORT} / data-- logpath=/comm/mg$ {PORT} / log/mg$ {PORT} .log-- port ${PORT}-- replSet repset

Log in to any server and initialize the members

$MONGODB_HOME/bin/mongo

Use admin

Config = {_ id: "repset"

Members: [

{_ id:0,host: "192.168.16.130 10000"}

{_ id:1,host: "192.168.16.130 10001"}

{_ id:2,host: "192.168.16.130 10002"}

]}

Initialize replica set

Rs.initiate (config)

View the status of cluster nodes

Rs.status ()

Stop it

Export PORT=10000

Mongod-- port ${PORT}-- shutdown-- dbpath=/comm/mg$ {PORT} / data

Log in

Export PORT=10002

$MONGODB_HOME/bin/mongo-- port ${PORT}

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report