您好,登錄后才能下訂單哦!
部署單機副本集最終目的:以后擴展的時候也好進行擴展。在不用停機的情況下,進行添加節點。
添加用戶組
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。