Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mongodb #97

Open
ZhengXingchi opened this issue Jul 19, 2020 · 0 comments
Open

mongodb #97

ZhengXingchi opened this issue Jul 19, 2020 · 0 comments

Comments

@ZhengXingchi
Copy link
Owner

ZhengXingchi commented Jul 19, 2020

创建副本集

  1. 服务器使用docker启动三个mongodb
docker run -d -p 27018:27017 --name mongo mongo --replSet repset
docker run -d -p 27019:27017 --name mongo1 mongo --replSet repset
docker run -d -p 27020:27017 --name mongo2 mongo --replSet repset
  1. 本地使用终端登录其中一个mongo
    mongo [服务器ip]:27018/admin

  2. 创建副本集

var config={_id:"repset",members:[{id:0,host:"[服务器ip]:27018"},{id:1,host:"[服务器ip]:27019"},{id:2,host:"[服务器ip]:27020"}]}

rs.initiate(config)
  1. 查看副本集状态
    rs.status()

报错分析

  1. Attempting to initiate a replica set with name rs0, but command line reports repset; rejecting
    原因在新建mogodb时候docker run -d -p 27018:27017 --name mongo mongo --replSet repset的replSet
    要与config中的_id的属性值一致
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant