mongoDB3.0.2 升级操作
生活随笔
收集整理的這篇文章主要介紹了
mongoDB3.0.2 升级操作
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
mongodb 升級(jí)到3.0.2
考慮到mongoDB 3.0推出不久,上個(gè)月還不想冒然進(jìn)行升級(jí),雖然性能說(shuō)得很誘人。
現(xiàn)看到版本已到3.0.2,是到要升級(jí)的時(shí)候了。
開(kāi)始在測(cè)試環(huán)境先做一個(gè)升級(jí),沒(méi)有問(wèn)題后,再把生產(chǎn)環(huán)境升級(jí)到3.0.2
測(cè)試環(huán)境:
?? ?版本號(hào):MONGODB 2.6.5
?? ?2臺(tái)服務(wù)器,做成2個(gè)分片,每個(gè)分片有一個(gè)集群(1+1+1),
?? ?集群中有2臺(tái)數(shù)據(jù)存儲(chǔ)服務(wù)器+1臺(tái)仲裁服務(wù)器
?? ?把仲裁服務(wù)器分別放在2臺(tái)服務(wù)器中
?? ?host?? ?ip?? ??? ??? ??? ??? ??? ??? ??? ??? ?端口信息?? ??? ??? ??? ??? ??? ??? ?arbiterOnly?? ?
?? ?---------------------------------------------------------------------------------------
?? ?tm1?? ?192.168.10.91?? ?mongod shard1:28011?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard1:28012 ------------ True
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28021
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config1:28010
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs1:28000
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs2:28001
?? ?tm2?? ?192.168.10.93?? ?mongod shard1:28013
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28022
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28023 ------------ True
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config:28010
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config2:28020
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs2:28000
?? ?
?? ?一、準(zhǔn)備工作:
?? ?1.對(duì) tm1 分片中的集群做升級(jí):
?? ??? ?1.配置新版本,建立新的目錄
?? ??? ?1.1 [192.168.10.93 服務(wù)器]
?? ??? ?su - mongo
?? ??? ?cd /opt/
?? ??? ?tar -xvzf mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz
?? ??? ?mv mongodb-linux-x86_64-enterprise-rhel57-3.0.2 mongodb3.0.2?? ?#更改目錄名稱(chēng)
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard13
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard22
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard23
?? ??? ?mkdir -p /opt/mongodb3.0.2/logs
?? ??? ?mkdir -p /opt/mongodb3.0.2/config
?? ??? ?mkdir -p /opt/mongodb3.0.2/config2
?? ??? ?1.2 先配置好3個(gè)節(jié)點(diǎn)及兩個(gè)配置服務(wù)器的參數(shù):
?? ??? ?[mongo@tm2 bin]$ cat shard13_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod? -f shard13.conf
?? ??? ?[mongo@tm2 bin]$ cat shard22_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f shard22.conf
?? ??? ?[mongo@tm2 bin]$ cat shard23_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f shard23.conf
?? ??? ?
?? ??? ?#配置文件 (注意:配置文件中的冒號(hào)后面一定要有空格)
?? ??? ??? ?[mongo@tm2 bin]$ cat shard13.conf
?? ??? ??? ??? ?systemLog:
?? ??? ??? ??? ??? ? destination: file
?? ??? ??? ??? ??? ? path: "/opt/mongodb3.0.2/logs/shard13.log"
?? ??? ??? ??? ??? ? logAppend: true
?? ??? ??? ??? ?storage:
?? ??? ??? ??? ??? ? journal:
?? ??? ??? ??? ??? ??? ?enabled: true
?? ??? ??? ??? ??? ? directoryPerDB: true
?? ??? ??? ??? ??? ? dbPath: "/opt/mongodb3.0.2/data/shard13"
?? ??? ??? ??? ?processManagement:
?? ??? ??? ??? ??? ? fork: true
?? ??? ??? ??? ?net:
?? ??? ??? ??? ??? ? #bindIp: 127.0.0.1
?? ??? ??? ??? ??? ? port: 28013
?? ??? ??? ??? ?setParameter:
?? ??? ??? ??? ??? ? enableLocalhostAuthBypass: false
?? ??? ??? ??? ?#分片服務(wù)器節(jié)點(diǎn)類(lèi)型
?? ??? ??? ??? ?sharding:
?? ??? ??? ??? ??? ? clusterRole: shardsvr #configsvr
?? ??? ??? ??? ?replication
?? ??? ??? ??? ??? ? replSetName: shard1
?? ??? ?同理,另外兩個(gè)節(jié)點(diǎn):shard22,shard23的配置文件,只是指定的文件目錄,日志文件名,
?? ??? ?集群名不一樣而已。
?? ??? ??? ?systemLog.path: "/opt/mongodb3.0.2/logs/shard22.log"
?? ??? ??? ?storage.dbPath: "/opt/mongodb3.0.2/data/shard22"?? ?
?? ??? ??? ?replication.replSetName: shard2
?? ??? ?1.3 兩個(gè)配置服務(wù)器的啟動(dòng)文件及配置文件
?? ??? ?[mongo@tm2 bin]$ cat configd_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f configsvr.conf
?? ??? ?[mongo@tm2 bin]$ cat configd2_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f configsvr2.conf
?? ??? ?[mongo@tm2 bin]$ cat configsvr.conf
?? ??? ??? ?systemLog:
?? ??? ??? ??? destination: file
?? ??? ??? ??? path: "/opt/mongodb3.0.2/logs/config.log"
?? ??? ??? ??? logAppend: true
?? ??? ??? ?storage:
?? ??? ??? ??? journal:
?? ??? ??? ??? ?? enabled: true
?? ??? ??? ??? dbPath: "/opt/mongodb3.0.2/config"
?? ??? ??? ?processManagement:
?? ??? ??? ??? fork: true
?? ??? ??? ?net:
?? ??? ??? ??? #bindIp: 127.0.0.1
?? ??? ??? ??? port: 28010
?? ??? ??? ?setParameter:
?? ??? ??? ??? enableLocalhostAuthBypass: false
?? ??? ??? ?sharding:
?? ??? ??? ??? clusterRole: configsvr
?? ??? ?[mongo@tm2 bin]$ cat configsvr2.conf
? ? ??? ??? ?systemLog:
?? ??? ??? ??? destination: file
?? ??? ??? ??? path: "/opt/mongodb3.0.2/logs/config2.log"
?? ??? ??? ??? logAppend: true
?? ??? ??? ?storage:
?? ??? ??? ??? journal:
?? ??? ??? ??? ?? enabled: true
?? ??? ??? ??? dbPath: "/opt/mongodb3.0.2/config2"
?? ??? ??? ?processManagement:
?? ??? ??? ??? fork: true
?? ??? ??? ?net:
?? ??? ??? ??? #bindIp: 127.0.0.1
?? ??? ??? ??? port: 28020
?? ??? ??? ?setParameter:
?? ??? ??? ??? enableLocalhostAuthBypass: false
?? ??? ??? ?sharding:
?? ??? ??? ??? clusterRole: configsvr
?? ??? ??? ??? ?#拷貝文件到 91服務(wù)器
?? ??? ??? ??? ?[mongo@tm2 opt]$ scp mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz tm1:/opt/
?? ??? ??? ??? ?1.2 [192.168.10.91 服務(wù)器]
?? ??? ??? ??? ?su - mongo
?? ??? ??? ??? ?cd /opt/
?? ??? ??? ??? ?tar -xvzf mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz
?? ??? ??? ??? ?mv mongodb-linux-x86_64-enterprise-rhel57-3.0.2 mongodb3.0.2?? ?#更改目錄名稱(chēng)
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard11
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard12
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard21
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/logs
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/config
?? ??? ??? ?同理,在91服務(wù)器中的各節(jié)點(diǎn)統(tǒng)計(jì)文件等不再列出。
二、升級(jí)步驟:
?? ??? ?2.1 關(guān)閉 均衡器
?? ??? ??? ?mongo -port 28000
?? ??? ??? ?sh.stopBalancer()
?? ??? ??? ?sh.getBalancerState()
?? ??? ?2.2.升級(jí)集群元數(shù)據(jù)(Upgrade the cluster’s meta data)
?? ??? ?/opt/mongodb3.0.2/bin/mongos --configdb 192.168.10.91:28010,192.168.10.93:28010,192.168.10.93:28020 --port 28080? --logpath /opt/mongodb3.0.2/logs/mongos.log? --upgrade
?? ??? ?
?? ??? ?如果出現(xiàn)以下提示,說(shuō)明升級(jí)成功:
?? ??? ??? ?<timestamp> I SHARDING [mongosMain] upgrade of config server to v6 successful
?? ??? ??? ??? ?...
?? ??? ??? ?<timestamp> I -??????? [mongosMain] Config database is at version v6
?? ??? ?2.3.升級(jí)config server
?? ??? ??? ?升級(jí)完成mongos 后,對(duì)config server 進(jìn)行升級(jí)操作。
?? ??? ??? ?方法:
?? ??? ??? ??? ?2.3.1 逐個(gè)導(dǎo)出數(shù)據(jù),
?? ??? ??? ??? ??? ?mongodump --out <exportDataDestination>
?? ??? ??? ??? ??? ?/opt/mongodb2.6.4/bin/mongodump --port 28010 -o /opt/backup/config2.6
?? ??? ??? ??? ??? ?connected to: 127.0.0.1:28010
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.603+0800 all dbs
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.604+0800 DATABASE: config?? ? to ?? ?/opt/backup/config2.6/config
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.680+0800 ?? ?config.system.indexes to /opt/backup/config2.6/config/system.indexes.bson
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.682+0800 ?? ??? ? 19 documents
?? ??? ??? ??? ??? ?......
?? ??? ??? ??? ?2.3.2 config server 關(guān)閉,
?? ??? ??? ??? ?2.3.3使用 --storageEngine wiredTiger 參數(shù)打開(kāi) 3.0版本
?? ??? ??? ??? ??? ?#文件參數(shù)如下:
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ cat configd_start.sh
?? ??? ??? ??? ??? ?numactl --interleave=all /opt/mongodb2.6.5/bin/mongod --configsvr --config configsvr.conf
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ cat configsvr.conf
?? ??? ??? ??? ??? ?dbpath = /opt/mongodb2.6.5/config
?? ??? ??? ??? ??? ?port = 28010
?? ??? ??? ??? ??? ?logpath = /opt/mongodb2.6.5/logs/config.log
?? ??? ??? ??? ??? ?logappend =true
?? ??? ??? ??? ??? ?fork = true
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ ./configd_start.sh
?? ??? ??? ??? ?2.3.4 導(dǎo)入數(shù)據(jù)
?? ??? ??? ??? ??? ?mongorestore <exportDataDestination>
?? ??? ??? ??? ??? ?/opt/mongodb3.0.2/bin/mongorestore --port 28010 --dir /opt/backup/config2.6
?? ??? ??? ??? ??? ?2015-04-21T15:56:29.394+0800?? ?building a list of dbs and collections to restore from /opt/backup/config2.6 dir
?? ??? ??? ??? ??? ?2015-04-21T15:56:29.408+0800?? ?reading metadata file from /opt/backup/config2.6/config/changelog.metadata.json
?? ??? ??? ??? ??? ?......
?? ??? ??? ??? ??? ?2015-04-21T15:56:37.882+0800?? ?finished restoring config.lockpings
?? ??? ??? ??? ??? ?2015-04-21T15:56:37.882+0800?? ?done
?? ??? ?2.4.升級(jí)各分片中的集群節(jié)點(diǎn)
?? ??? ??? ?2.4.1 關(guān)閉主節(jié)點(diǎn):?? ?
?? ??? ??? ?可以通過(guò)replSetStepDown命令下架主節(jié)點(diǎn)。這個(gè)命令可以登錄主節(jié)點(diǎn)使用
?? ??? ??? ??? ?1.db.adminCommand({replSetStepDown : 1})
?? ??? ??? ??? ??? ?以下操作是把primary 切換到secondary,并關(guān)閉服務(wù)器,
?? ??? ??? ??? ??? ?/opt/mongodb2.6.4/bin/mongo -port 28022
?? ??? ??? ??? ??? ?shard2:PRIMARY>
?? ??? ??? ??? ??? ?shard2:PRIMARY>? rs.stepDown()
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.777+0800 DBClientCursor::init call() failed
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.780+0800 Error: error doing query: failed at src/mongo/shell/query.js:81
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.783+0800 trying reconnect to 127.0.0.1:28022 (127.0.0.1) failed
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.784+0800 reconnect 127.0.0.1:28022 (127.0.0.1) ok
?? ??? ??? ??? ??? ?shard2:SECONDARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard2",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-21T10:12:56Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 2,
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 9470,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 37,
?? ??? ??? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.93:28022"
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28022",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 13065,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28023",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 7865,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:12:56Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 0
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?shard2:SECONDARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard2",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-21T10:13:10Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 2,
?? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "PRIMARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 9484,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:13:09Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:13:09Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 6,
?? ??? ??? ??? ??? ??? ??? ??? ?"electionTime" : Timestamp(1429611174, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionDate" : ISODate("2015-04-21T10:12:54Z")
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28022",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 13079,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"infoMessage" : "syncing to: 192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28023",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 7879,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:13:08Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:13:08Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 0
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?shard2:SECONDARY> db.shutdownServer()
?? ??? ??? ?2.4.2 這時(shí)其它的次節(jié)點(diǎn)上升為主節(jié)點(diǎn),把原主節(jié)點(diǎn)更換成 3.0版本的mongod 實(shí)例。
?? ??? ??? ?使用新的存儲(chǔ)引擎方式啟動(dòng)(端口號(hào)不變):
?? ??? ??? ??? ?mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath>
?? ??? ??? ?
?? ??? ??? ?這時(shí)主節(jié)點(diǎn)會(huì)把數(shù)據(jù)同步到新的3.0版本的實(shí)例中。
?? ??? ??? ?當(dāng)同步完成后 狀態(tài)值:"stateStr" : "STARTUP2" 會(huì)變成 "stateStr" : "STARTUP"。
?? ??? ??? ?當(dāng)此次切換完成后,可以再切換一次,從 PRIMARY 切換成 STARTUP,再把 STARTUP 服務(wù)器
?? ??? ??? ?關(guān)掉,再重啟3.0版本的服務(wù)器,這時(shí)數(shù)據(jù)庫(kù)又會(huì)把? PRIMARY 服務(wù)器的數(shù)據(jù),同步到 STARTUP 服務(wù)器
?? ??? ??? ?如果有多臺(tái)startup只要關(guān)閉后,啟動(dòng)3.0版本即可。
?? ??? ??? ??? ?shard1:PRIMARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard1",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-22T02:26:27Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 1,
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28011",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 5,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "STARTUP2",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 2232,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429667867, 3),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-22T01:57:47Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-22T02:26:27Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 31,
?? ??? ??? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.93:28013"
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28013",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "PRIMARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 71486,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429667867, 3),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-22T01:57:47Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionTime" : Timestamp(1429667221, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionDate" : ISODate("2015-04-22T01:47:01Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28014",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 1423,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 23
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ?2.5 打開(kāi)均衡器器
?? ??? ??? ?sh.setBalancerState(true)
?? ?到這里,mongodb3.0的升級(jí)完成。測(cè)試內(nèi)容不再列舉。
考慮到mongoDB 3.0推出不久,上個(gè)月還不想冒然進(jìn)行升級(jí),雖然性能說(shuō)得很誘人。
現(xiàn)看到版本已到3.0.2,是到要升級(jí)的時(shí)候了。
開(kāi)始在測(cè)試環(huán)境先做一個(gè)升級(jí),沒(méi)有問(wèn)題后,再把生產(chǎn)環(huán)境升級(jí)到3.0.2
測(cè)試環(huán)境:
?? ?版本號(hào):MONGODB 2.6.5
?? ?2臺(tái)服務(wù)器,做成2個(gè)分片,每個(gè)分片有一個(gè)集群(1+1+1),
?? ?集群中有2臺(tái)數(shù)據(jù)存儲(chǔ)服務(wù)器+1臺(tái)仲裁服務(wù)器
?? ?把仲裁服務(wù)器分別放在2臺(tái)服務(wù)器中
?? ?host?? ?ip?? ??? ??? ??? ??? ??? ??? ??? ??? ?端口信息?? ??? ??? ??? ??? ??? ??? ?arbiterOnly?? ?
?? ?---------------------------------------------------------------------------------------
?? ?tm1?? ?192.168.10.91?? ?mongod shard1:28011?? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard1:28012 ------------ True
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28021
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config1:28010
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs1:28000
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs2:28001
?? ?tm2?? ?192.168.10.93?? ?mongod shard1:28013
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28022
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod shard2:28023 ------------ True
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config:28010
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongod config2:28020
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?mongs2:28000
?? ?
?? ?一、準(zhǔn)備工作:
?? ?1.對(duì) tm1 分片中的集群做升級(jí):
?? ??? ?1.配置新版本,建立新的目錄
?? ??? ?1.1 [192.168.10.93 服務(wù)器]
?? ??? ?su - mongo
?? ??? ?cd /opt/
?? ??? ?tar -xvzf mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz
?? ??? ?mv mongodb-linux-x86_64-enterprise-rhel57-3.0.2 mongodb3.0.2?? ?#更改目錄名稱(chēng)
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard13
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard22
?? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard23
?? ??? ?mkdir -p /opt/mongodb3.0.2/logs
?? ??? ?mkdir -p /opt/mongodb3.0.2/config
?? ??? ?mkdir -p /opt/mongodb3.0.2/config2
?? ??? ?1.2 先配置好3個(gè)節(jié)點(diǎn)及兩個(gè)配置服務(wù)器的參數(shù):
?? ??? ?[mongo@tm2 bin]$ cat shard13_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod? -f shard13.conf
?? ??? ?[mongo@tm2 bin]$ cat shard22_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f shard22.conf
?? ??? ?[mongo@tm2 bin]$ cat shard23_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f shard23.conf
?? ??? ?
?? ??? ?#配置文件 (注意:配置文件中的冒號(hào)后面一定要有空格)
?? ??? ??? ?[mongo@tm2 bin]$ cat shard13.conf
?? ??? ??? ??? ?systemLog:
?? ??? ??? ??? ??? ? destination: file
?? ??? ??? ??? ??? ? path: "/opt/mongodb3.0.2/logs/shard13.log"
?? ??? ??? ??? ??? ? logAppend: true
?? ??? ??? ??? ?storage:
?? ??? ??? ??? ??? ? journal:
?? ??? ??? ??? ??? ??? ?enabled: true
?? ??? ??? ??? ??? ? directoryPerDB: true
?? ??? ??? ??? ??? ? dbPath: "/opt/mongodb3.0.2/data/shard13"
?? ??? ??? ??? ?processManagement:
?? ??? ??? ??? ??? ? fork: true
?? ??? ??? ??? ?net:
?? ??? ??? ??? ??? ? #bindIp: 127.0.0.1
?? ??? ??? ??? ??? ? port: 28013
?? ??? ??? ??? ?setParameter:
?? ??? ??? ??? ??? ? enableLocalhostAuthBypass: false
?? ??? ??? ??? ?#分片服務(wù)器節(jié)點(diǎn)類(lèi)型
?? ??? ??? ??? ?sharding:
?? ??? ??? ??? ??? ? clusterRole: shardsvr #configsvr
?? ??? ??? ??? ?replication
?? ??? ??? ??? ??? ? replSetName: shard1
?? ??? ?同理,另外兩個(gè)節(jié)點(diǎn):shard22,shard23的配置文件,只是指定的文件目錄,日志文件名,
?? ??? ?集群名不一樣而已。
?? ??? ??? ?systemLog.path: "/opt/mongodb3.0.2/logs/shard22.log"
?? ??? ??? ?storage.dbPath: "/opt/mongodb3.0.2/data/shard22"?? ?
?? ??? ??? ?replication.replSetName: shard2
?? ??? ?1.3 兩個(gè)配置服務(wù)器的啟動(dòng)文件及配置文件
?? ??? ?[mongo@tm2 bin]$ cat configd_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f configsvr.conf
?? ??? ?[mongo@tm2 bin]$ cat configd2_start.sh
?? ??? ?numactl --interleave=all /opt/mongodb3.0.2/bin/mongod -f configsvr2.conf
?? ??? ?[mongo@tm2 bin]$ cat configsvr.conf
?? ??? ??? ?systemLog:
?? ??? ??? ??? destination: file
?? ??? ??? ??? path: "/opt/mongodb3.0.2/logs/config.log"
?? ??? ??? ??? logAppend: true
?? ??? ??? ?storage:
?? ??? ??? ??? journal:
?? ??? ??? ??? ?? enabled: true
?? ??? ??? ??? dbPath: "/opt/mongodb3.0.2/config"
?? ??? ??? ?processManagement:
?? ??? ??? ??? fork: true
?? ??? ??? ?net:
?? ??? ??? ??? #bindIp: 127.0.0.1
?? ??? ??? ??? port: 28010
?? ??? ??? ?setParameter:
?? ??? ??? ??? enableLocalhostAuthBypass: false
?? ??? ??? ?sharding:
?? ??? ??? ??? clusterRole: configsvr
?? ??? ?[mongo@tm2 bin]$ cat configsvr2.conf
? ? ??? ??? ?systemLog:
?? ??? ??? ??? destination: file
?? ??? ??? ??? path: "/opt/mongodb3.0.2/logs/config2.log"
?? ??? ??? ??? logAppend: true
?? ??? ??? ?storage:
?? ??? ??? ??? journal:
?? ??? ??? ??? ?? enabled: true
?? ??? ??? ??? dbPath: "/opt/mongodb3.0.2/config2"
?? ??? ??? ?processManagement:
?? ??? ??? ??? fork: true
?? ??? ??? ?net:
?? ??? ??? ??? #bindIp: 127.0.0.1
?? ??? ??? ??? port: 28020
?? ??? ??? ?setParameter:
?? ??? ??? ??? enableLocalhostAuthBypass: false
?? ??? ??? ?sharding:
?? ??? ??? ??? clusterRole: configsvr
?? ??? ??? ??? ?#拷貝文件到 91服務(wù)器
?? ??? ??? ??? ?[mongo@tm2 opt]$ scp mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz tm1:/opt/
?? ??? ??? ??? ?1.2 [192.168.10.91 服務(wù)器]
?? ??? ??? ??? ?su - mongo
?? ??? ??? ??? ?cd /opt/
?? ??? ??? ??? ?tar -xvzf mongodb-linux-x86_64-enterprise-rhel57-3.0.2.gz
?? ??? ??? ??? ?mv mongodb-linux-x86_64-enterprise-rhel57-3.0.2 mongodb3.0.2?? ?#更改目錄名稱(chēng)
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard11
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard12
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/data/shard21
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/logs
?? ??? ??? ??? ?mkdir -p /opt/mongodb3.0.2/config
?? ??? ??? ?同理,在91服務(wù)器中的各節(jié)點(diǎn)統(tǒng)計(jì)文件等不再列出。
二、升級(jí)步驟:
?? ??? ?2.1 關(guān)閉 均衡器
?? ??? ??? ?mongo -port 28000
?? ??? ??? ?sh.stopBalancer()
?? ??? ??? ?sh.getBalancerState()
?? ??? ?2.2.升級(jí)集群元數(shù)據(jù)(Upgrade the cluster’s meta data)
?? ??? ?/opt/mongodb3.0.2/bin/mongos --configdb 192.168.10.91:28010,192.168.10.93:28010,192.168.10.93:28020 --port 28080? --logpath /opt/mongodb3.0.2/logs/mongos.log? --upgrade
?? ??? ?
?? ??? ?如果出現(xiàn)以下提示,說(shuō)明升級(jí)成功:
?? ??? ??? ?<timestamp> I SHARDING [mongosMain] upgrade of config server to v6 successful
?? ??? ??? ??? ?...
?? ??? ??? ?<timestamp> I -??????? [mongosMain] Config database is at version v6
?? ??? ?2.3.升級(jí)config server
?? ??? ??? ?升級(jí)完成mongos 后,對(duì)config server 進(jìn)行升級(jí)操作。
?? ??? ??? ?方法:
?? ??? ??? ??? ?2.3.1 逐個(gè)導(dǎo)出數(shù)據(jù),
?? ??? ??? ??? ??? ?mongodump --out <exportDataDestination>
?? ??? ??? ??? ??? ?/opt/mongodb2.6.4/bin/mongodump --port 28010 -o /opt/backup/config2.6
?? ??? ??? ??? ??? ?connected to: 127.0.0.1:28010
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.603+0800 all dbs
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.604+0800 DATABASE: config?? ? to ?? ?/opt/backup/config2.6/config
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.680+0800 ?? ?config.system.indexes to /opt/backup/config2.6/config/system.indexes.bson
?? ??? ??? ??? ??? ?2015-04-21T15:54:04.682+0800 ?? ??? ? 19 documents
?? ??? ??? ??? ??? ?......
?? ??? ??? ??? ?2.3.2 config server 關(guān)閉,
?? ??? ??? ??? ?2.3.3使用 --storageEngine wiredTiger 參數(shù)打開(kāi) 3.0版本
?? ??? ??? ??? ??? ?#文件參數(shù)如下:
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ cat configd_start.sh
?? ??? ??? ??? ??? ?numactl --interleave=all /opt/mongodb2.6.5/bin/mongod --configsvr --config configsvr.conf
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ cat configsvr.conf
?? ??? ??? ??? ??? ?dbpath = /opt/mongodb2.6.5/config
?? ??? ??? ??? ??? ?port = 28010
?? ??? ??? ??? ??? ?logpath = /opt/mongodb2.6.5/logs/config.log
?? ??? ??? ??? ??? ?logappend =true
?? ??? ??? ??? ??? ?fork = true
?? ??? ??? ??? ??? ?[mongo@tm1 bin]$ ./configd_start.sh
?? ??? ??? ??? ?2.3.4 導(dǎo)入數(shù)據(jù)
?? ??? ??? ??? ??? ?mongorestore <exportDataDestination>
?? ??? ??? ??? ??? ?/opt/mongodb3.0.2/bin/mongorestore --port 28010 --dir /opt/backup/config2.6
?? ??? ??? ??? ??? ?2015-04-21T15:56:29.394+0800?? ?building a list of dbs and collections to restore from /opt/backup/config2.6 dir
?? ??? ??? ??? ??? ?2015-04-21T15:56:29.408+0800?? ?reading metadata file from /opt/backup/config2.6/config/changelog.metadata.json
?? ??? ??? ??? ??? ?......
?? ??? ??? ??? ??? ?2015-04-21T15:56:37.882+0800?? ?finished restoring config.lockpings
?? ??? ??? ??? ??? ?2015-04-21T15:56:37.882+0800?? ?done
?? ??? ?2.4.升級(jí)各分片中的集群節(jié)點(diǎn)
?? ??? ??? ?2.4.1 關(guān)閉主節(jié)點(diǎn):?? ?
?? ??? ??? ?可以通過(guò)replSetStepDown命令下架主節(jié)點(diǎn)。這個(gè)命令可以登錄主節(jié)點(diǎn)使用
?? ??? ??? ??? ?1.db.adminCommand({replSetStepDown : 1})
?? ??? ??? ??? ??? ?以下操作是把primary 切換到secondary,并關(guān)閉服務(wù)器,
?? ??? ??? ??? ??? ?/opt/mongodb2.6.4/bin/mongo -port 28022
?? ??? ??? ??? ??? ?shard2:PRIMARY>
?? ??? ??? ??? ??? ?shard2:PRIMARY>? rs.stepDown()
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.777+0800 DBClientCursor::init call() failed
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.780+0800 Error: error doing query: failed at src/mongo/shell/query.js:81
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.783+0800 trying reconnect to 127.0.0.1:28022 (127.0.0.1) failed
?? ??? ??? ??? ??? ?2015-04-21T18:12:48.784+0800 reconnect 127.0.0.1:28022 (127.0.0.1) ok
?? ??? ??? ??? ??? ?shard2:SECONDARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard2",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-21T10:12:56Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 2,
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 9470,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 37,
?? ??? ??? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.93:28022"
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28022",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 13065,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28023",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 7865,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:12:54Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:12:56Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 0
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?shard2:SECONDARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard2",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-21T10:13:10Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 2,
?? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "PRIMARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 9484,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:13:09Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:13:09Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 6,
?? ??? ??? ??? ??? ??? ??? ??? ?"electionTime" : Timestamp(1429611174, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionDate" : ISODate("2015-04-21T10:12:54Z")
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28022",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "SECONDARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 13079,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429581793, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-21T02:03:13Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"infoMessage" : "syncing to: 192.168.10.91:28021",
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28023",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 7879,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-21T10:13:08Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-21T10:13:08Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 0
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?shard2:SECONDARY> db.shutdownServer()
?? ??? ??? ?2.4.2 這時(shí)其它的次節(jié)點(diǎn)上升為主節(jié)點(diǎn),把原主節(jié)點(diǎn)更換成 3.0版本的mongod 實(shí)例。
?? ??? ??? ?使用新的存儲(chǔ)引擎方式啟動(dòng)(端口號(hào)不變):
?? ??? ??? ??? ?mongod --storageEngine wiredTiger --dbpath <newWiredTigerDBPath>
?? ??? ??? ?
?? ??? ??? ?這時(shí)主節(jié)點(diǎn)會(huì)把數(shù)據(jù)同步到新的3.0版本的實(shí)例中。
?? ??? ??? ?當(dāng)同步完成后 狀態(tài)值:"stateStr" : "STARTUP2" 會(huì)變成 "stateStr" : "STARTUP"。
?? ??? ??? ?當(dāng)此次切換完成后,可以再切換一次,從 PRIMARY 切換成 STARTUP,再把 STARTUP 服務(wù)器
?? ??? ??? ?關(guān)掉,再重啟3.0版本的服務(wù)器,這時(shí)數(shù)據(jù)庫(kù)又會(huì)把? PRIMARY 服務(wù)器的數(shù)據(jù),同步到 STARTUP 服務(wù)器
?? ??? ??? ?如果有多臺(tái)startup只要關(guān)閉后,啟動(dòng)3.0版本即可。
?? ??? ??? ??? ?shard1:PRIMARY> rs.status()
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?"set" : "shard1",
?? ??? ??? ??? ??? ??? ?"date" : ISODate("2015-04-22T02:26:27Z"),
?? ??? ??? ??? ??? ??? ?"myState" : 1,
?? ??? ??? ??? ??? ??? ?"members" : [
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 0,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28011",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 5,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "STARTUP2",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 2232,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429667867, 3),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-22T01:57:47Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-22T02:26:27Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 31,
?? ??? ??? ??? ??? ??? ??? ??? ?"syncingTo" : "192.168.10.93:28013"
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.93:28013",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "PRIMARY",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 71486,
?? ??? ??? ??? ??? ??? ??? ??? ?"optime" : Timestamp(1429667867, 3),
?? ??? ??? ??? ??? ??? ??? ??? ?"optimeDate" : ISODate("2015-04-22T01:57:47Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionTime" : Timestamp(1429667221, 1),
?? ??? ??? ??? ??? ??? ??? ??? ?"electionDate" : ISODate("2015-04-22T01:47:01Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"self" : true
?? ??? ??? ??? ??? ??? ??? ?},
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?"_id" : 2,
?? ??? ??? ??? ??? ??? ??? ??? ?"name" : "192.168.10.91:28014",
?? ??? ??? ??? ??? ??? ??? ??? ?"health" : 1,
?? ??? ??? ??? ??? ??? ??? ??? ?"state" : 7,
?? ??? ??? ??? ??? ??? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ??? ??? ??? ??? ??? ?"uptime" : 1423,
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeat" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"lastHeartbeatRecv" : ISODate("2015-04-22T02:26:26Z"),
?? ??? ??? ??? ??? ??? ??? ??? ?"pingMs" : 23
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?],
?? ??? ??? ??? ??? ??? ?"ok" : 1
?? ??? ?2.5 打開(kāi)均衡器器
?? ??? ??? ?sh.setBalancerState(true)
?? ?到這里,mongodb3.0的升級(jí)完成。測(cè)試內(nèi)容不再列舉。
總結(jié)
以上是生活随笔為你收集整理的mongoDB3.0.2 升级操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: mongoDB 从单节点迁移到分布式集群
- 下一篇: 使用MONGODB 集群的OPLOG 日