Get the App
SLTechnology News&Howtos  ›  Database  › 

Mongo replica set cluster installation configuration

Shulou Source: shulou.com Published: 2022-06-01 05:08:37 10月04日 Update

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}

Tags: Login replica cluster member status user directory node software process any one configuration Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Docker Shulou Tech Info Linux Shulou Information