部署单机副本集最终目的:以后扩展的时候也好进行扩展。在不用停机的情况下,进行添加节点。
添加用户组
groupadd -g 355 mongodb
添加用户mgousr02
useradd -u 369 -g mongodb -G mongodb,users -d /data/users/mgousr02 -m mgousr02
修改mgousr01用户密码
passwd mgousr02 --stdin <<< mgousr02
切换到mgousr02用户
创建如下目录
添加环境变量
# su - mgousr02
mkdir -p mongodb/bin
mkdir -p mongodb/dbdata
mkdir -p mongodb/etc
mkdir -p mongodb/logs
#[monogdb]
export MGO_HOME=/opt/freeware/mongodb-linux-x86_64-rhel62-3.2.0-rc2
export PATH=$MGO_HOME/bin:$PATH
[mgousr02@mongodb-test1 etc]$ more mongo-1m.conf
dbpath=/data/users/mgousr02/mongodb/dbdata/rs0
logpath=/data/users/mgousr02/mongodb/logs/mongo-1m.log
pidfilepath=/data/users/mgousr02/mongodb/dbdata/rs0/mongo-1m.pid
directoryperdb=true
logappend=true
replSet=rs0
bind_ip=IP Addr
port=PORT
oplogSize=8000
fork=true
#noprealloc=true
#auth=true
journal=true
profile=1
slowms=10
quiet=true
maxConns=1024
wiredTigerCacheSizeGB=24
#keyFile=/data/users/mgousr01/mongodb/etc/keyFile/keyFilers0.key
#cpu=true
#nssize=
#quota=true
#quotaFiles=50
比之前部署单节点多了两个步骤(如下标记红色部分)
$ mongo IP:PORT
>config={_id:"rs0",members:[{_id:0,host:"IP:PORT",priority:6}]}
{
"_id" : "rs0",
"members" : [
{
"_id" : 0,
"host" : "IP:PORT",
"priority" : 6
}
]
}
>rs.initiate(config)
{ "ok" : 1 }
测试数据:
rs0:PRIMARY> use paris
switched to db paris
rs0:PRIMARY> for(var i=0;i<=100000;i++) db.users.insert({"ip" : "192.168.168.254","g_roup" : "kiwi","mac" : "of:fd:67:8c:2f:8f","address" : "hongmei1801num","user_id" : i,"name" : "user10000000","title" : "system","database" : "mongodb","telphone" : NumberLong("15718441234"),"mail" : "yj@chinapnr.com","os" : "win7","company" : "chinapnr"})
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。