日期:2014-05-16  浏览次数:20415 次

MongoDB 副本集replSet 配置与分析
2个Standard节点+1个Arbiter节点 搭建MongoDB Replication Sets

创建目录
[root@localhost ~]# mkdir -p /data/replset/r0
[root@localhost ~]# mkdir -p /data/replset/r1
[root@localhost ~]# mkdir -p /data/replset/r2
[root@localhost ~]# mkdir -p /data/replset/key
[root@localhost ~]# mkdir -p /data/replset/log


创建KEY
[root@localhost ~]# echo "replset1 key" > /data/replset/key/r0
[root@localhost ~]# echo "replset1 key" > /data/replset/key/r1
[root@localhost ~]# echo "replset1 key" > /data/replset/key/r2
[root@localhost ~]# chmod 600 /data/replset/key/r*  //600,防止其它程序改写此KEY


/Apps/mongo/bin/mongod --dbpath=/data/replset/r0 --replSet replset1 --keyFile /data/replset/key/r0 --port 28010

/Apps/mongo/bin/mongod --dbpath=/data/replset/r1 --replSet replset1 --keyFile /data/replset/key/r1 --port 28011

/Apps/mongo/bin/mongod --dbpath=/data/replset/r2 --replSet replset1 --keyFile /data/replset/key/r2 --port 28012

注:--keyFile /data/key/r0 加了这个后,MongVUE就连不到了



改用下面的就行了(这是里为方便看日志,直接在命令行输出查看)

/Apps/mongo/bin/mongod --dbpath=/data/replset/r0 --replSet  replset1 --port 28010 --directoryperdb

/Apps/mongo/bin/mongod --dbpath=/data/replset/r1 --replSet  replset1 --port 28011 --directoryperdb