Mongodb 故障分享 初始化时errmsg : exception: new file allocation failure 并且长时间处于STARTUP2...
Hello,大家下午好。
近幾天的項(xiàng)目有點(diǎn)趕,所以耽誤了更新?,F(xiàn)在給大家分享下,在安裝mongodb的過程中,遇到的故障一則。其實(shí)很小白的問題,當(dāng)時(shí)遇到這個(gè)問題的時(shí)候比較心慌,浪費(fèi)了很多時(shí)間,跟大家分享下解決的思路吧。
先描述下我的環(huán)境,請(qǐng)參照前一篇博客,利用腳本初始化出4個(gè)節(jié)點(diǎn)(由于實(shí)驗(yàn)原因,我使用了單臺(tái)的服務(wù)器)。
首先我們啟動(dòng)這四個(gè)初始化節(jié)點(diǎn)。(具體的文件配置,請(qǐng)參照前文,初始化的內(nèi)容,這里僅用/etc/mongodb.conf為例)
[root@1]# cat /etc/mongodb.conf
dbpath=/usr/local/mongodb-3.0.2/data
logpath=/usr/local/mongodb-3.0.2/logs/mongo.log
pidfilepath=/var/run/mongodb/mongodb.pid
unixSocketPrefix=/usr/local/mongodb-3.0.2/socket
directoryperdb=true
replSet=picture
shardsvr=true
logappend=true
port = 27017
maxConns=20000
oplogSize=30720
fork=true
nohttpinterface=true
nojournal=true
[root@1]# mongod --config=/etc/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 32560
child process started successfully, parent exiting
[root@1]# mongod --config=/etc/mongodb1.conf
about to fork child process, waiting until server is ready for connections.
forked process: 32574
child process started successfully, parent exiting
[root@1]# mongod --config=/etc/mongodb2.conf
about to fork child process, waiting until server is ready for connections.
forked process: 32588
child process started successfully, parent exiting
[root@1]# mongod --config=/etc/mongodb3.conf
about to fork child process, waiting until server is ready for connections.
forked process: 32602
child process started successfully, parent exiting
[root@1]# ps -ef | grep mongo????????????????????????????????? //我們可以看到四個(gè)實(shí)例已經(jīng)啟動(dòng)。下一步我們將進(jìn)行角色分配(即副本集搭建)
root???? 32560???? 1? 0 15:43 ???????? 00:00:00 mongod --config=/etc/mongodb.conf
root???? 32574???? 1? 0 15:43 ???????? 00:00:00 mongod --config=/etc/mongodb1.conf
root???? 32588???? 1? 0 15:43 ???????? 00:00:00 mongod --config=/etc/mongodb2.conf
root???? 32602???? 1? 0 15:43 ???????? 00:00:00 mongod --config=/etc/mongodb3.conf
root???? 32616 28203? 0 15:46 pts/0??? 00:00:00 grep mongo
[root@1]#
[root@1]# mongo
MongoDB shell version: 3.0.2
connecting to: test
Server has startup warnings:
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten]
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten]
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] **??????? We suggest setting it to 'never'
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten]
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] **??????? We suggest setting it to 'never'
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten]
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 65535 processes, 655350 files. Number of processes should be at least 327675 : 0.5 times number of files.
2016-01-25T15:43:46.645+0800 I CONTROL? [initandlisten]
> use admin??????????????????????????????????????????? //首先切換到admindb,進(jìn)行副本集配置
switched to db admin
> config = {_id: 'picture', members: [
...?????? {_id: 0, host: '$IP:27017'},
...?????? {_id: 1, host: '$IP:37017'},
...?????? {_id: 2, host: '$IP:47017'},
...?????? {_id: 3, host: '$IP:30000',arbiterOnly:true}]??????????????? //此時(shí)配置將產(chǎn)生一個(gè)主節(jié)點(diǎn),兩個(gè)從節(jié)點(diǎn),一個(gè)仲裁節(jié)點(diǎn)
... }
{
?? ?"_id" : "picture",
?? ?"members" : [
?? ??? ?{
?? ??? ??? ?"_id" : 0,
?? ??? ??? ?"host" : "$IP:27017"
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 1,
?? ??? ??? ?"host" : "$IP:37017"
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 2,
?? ??? ??? ?"host" : "$IP:47017"
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 3,
?? ??? ??? ?"host" : "$IP:30000",
?? ??? ??? ?"arbiterOnly" : true
?? ??? ?}
?? ?]
}
> rs.initiate(config);
{
?? ?"errmsg" : "exception: new file allocation failure",?????????????????? //大家可以看到初始化失敗
?? ?"code" : 12520,
?? ?"ok" : 0
}
查詢下各個(gè)節(jié)點(diǎn)狀態(tài),悲劇了,長(zhǎng)時(shí)間停留在STARTUP2狀態(tài)
picture:OTHER> rs.status()
{
?? ?"set" : "picture",
?? ?"date" : ISODate("2016-01-25T07:51:15.665Z"),
?? ?"myState" : 5,
?? ?"members" : [
?? ??? ?{
?? ??? ??? ?"_id" : 0,
?? ??? ??? ?"name" : "$IP:27017",
?? ??? ??? ?"health" : 1,
?? ??? ??? ?"state" : 5,
?? ??? ??? ?"stateStr" : "STARTUP2",
?? ??? ??? ?"uptime" : 449,
?? ??? ??? ?"optime" : Timestamp(0, 0),
?? ??? ??? ?"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
?? ??? ??? ?"configVersion" : 1,
?? ??? ??? ?"self" : true
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 1,
?? ??? ??? ?"name" : "$IP:37017",
?? ??? ??? ?"health" : 1,
?? ??? ??? ?"state" : 5,
?? ??? ??? ?"stateStr" : "STARTUP2",
?? ??? ??? ?"uptime" : 154,
?? ??? ??? ?"optime" : Timestamp(0, 0),
?? ??? ??? ?"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
?? ??? ??? ?"lastHeartbeat" : ISODate("2016-01-25T07:51:15.326Z"),
?? ??? ??? ?"lastHeartbeatRecv" : ISODate("2016-01-25T07:51:15.326Z"),
?? ??? ??? ?"pingMs" : 0,
?? ??? ??? ?"configVersion" : 1
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 2,
?? ??? ??? ?"name" : "$IP:47017",
?? ??? ??? ?"health" : 1,
?? ??? ??? ?"state" : 5,
?? ??? ??? ?"stateStr" : "STARTUP2",
?? ??? ??? ?"uptime" : 154,
?? ??? ??? ?"optime" : Timestamp(0, 0),
?? ??? ??? ?"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
?? ??? ??? ?"lastHeartbeat" : ISODate("2016-01-25T07:51:15.326Z"),
?? ??? ??? ?"lastHeartbeatRecv" : ISODate("2016-01-25T07:51:15.324Z"),
?? ??? ??? ?"pingMs" : 0,
?? ??? ??? ?"configVersion" : 1
?? ??? ?},
?? ??? ?{
?? ??? ??? ?"_id" : 3,
?? ??? ??? ?"name" : "$IP:30000",
?? ??? ??? ?"health" : 1,
?? ??? ??? ?"state" : 7,
?? ??? ??? ?"stateStr" : "ARBITER",
?? ??? ??? ?"uptime" : 154,
?? ??? ??? ?"lastHeartbeat" : ISODate("2016-01-25T07:51:15.324Z"),
?? ??? ??? ?"lastHeartbeatRecv" : ISODate("2016-01-25T07:51:15.324Z"),
?? ??? ??? ?"pingMs" : 0,
?? ??? ??? ?"configVersion" : 1
?? ??? ?}
?? ?],
?? ?"ok" : 1
}
picture:OTHER> //大家發(fā)現(xiàn)本節(jié)點(diǎn)狀態(tài)為other,………… ,很久很久以后? 依然如此。
?
我們的解決思路是什么?
首先,想跟大家分享下mongodb的整個(gè)的啟動(dòng)和副本集初始化過程(可以關(guān)注下一章節(jié)的博客)。我們知道? STARTUP是其中的一個(gè)階段。
然后,出現(xiàn)問題。其實(shí)第一個(gè)想法就是看log。那么我們看下log告訴我們什么了。
【$IP:27017-log】
2016-01-25T15:48:41.275+0800 I REPL???? [conn1] replSetInitiate admin command received from client
2016-01-25T15:48:41.277+0800 I REPL???? [conn1] replSet replSetInitiate config object with 4 members parses ok
2016-01-25T15:48:41.278+0800 I NETWORK? [initandlisten] connection accepted from $IP:38296 #2 (2 connections now open)
2016-01-25T15:48:41.279+0800 I NETWORK? [initandlisten] connection accepted from $IP:38299 #3 (3 connections now open)
2016-01-25T15:48:41.279+0800 I NETWORK? [initandlisten] connection accepted from $IP:38300 #4 (4 connections now open)
2016-01-25T15:48:41.280+0800 I REPL???? [ReplicationExecutor] New replica set config in use: { _id: "picture", version: 1, members: [ { _id: 0, host: "$IP:27017", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 1, host: "$IP:37017", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 2, host: "$IP:47017", arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 }, { _id: 3, host: "$IP:30000", arbiterOnly: true, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatTimeoutSecs: 10, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 } } }
2016-01-25T15:48:41.280+0800 I REPL???? [ReplicationExecutor] This node is $IP:27017 in the config
2016-01-25T15:48:41.280+0800 I REPL???? [ReplicationExecutor] transition to STARTUP2
2016-01-25T15:48:41.280+0800 I REPL???? [conn1] ******
2016-01-25T15:48:41.280+0800 I REPL???? [conn1] creating replication oplog of size: 30720MB...
2016-01-25T15:48:41.281+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.1, filling with zeroes...
2016-01-25T15:48:41.281+0800 I REPL???? [ReplicationExecutor] Member $IP:47017 is now in state STARTUP
2016-01-25T15:48:41.281+0800 I REPL???? [ReplicationExecutor] Member $IP:37017 is now in state STARTUP
2016-01-25T15:48:41.281+0800 I REPL???? [ReplicationExecutor] Member $IP:30000 is now in state STARTUP
2016-01-25T15:48:41.283+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.1, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.283+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.2, filling with zeroes...
2016-01-25T15:48:41.286+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.2, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.286+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.3, filling with zeroes...
2016-01-25T15:48:41.288+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.3, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.288+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.4, filling with zeroes...
2016-01-25T15:48:41.291+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.4, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.291+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.5, filling with zeroes...
2016-01-25T15:48:41.293+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.5, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.293+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.6, filling with zeroes...
2016-01-25T15:48:41.298+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.6, size: 2047MB,? took 0.004 secs
2016-01-25T15:48:41.298+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.7, filling with zeroes...
2016-01-25T15:48:41.301+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.7, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.301+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.8, filling with zeroes...
2016-01-25T15:48:41.303+0800 I STORAGE? [FileAllocator] done allocating datafile /usr/local/mongodb-3.0.2/data/local/local.8, size: 2047MB,? took 0.002 secs
2016-01-25T15:48:41.304+0800 I STORAGE? [FileAllocator] allocating new datafile /usr/local/mongodb-3.0.2/data/local/local.9, filling with zeroes...
2016-01-25T15:48:41.318+0800 I STORAGE? [FileAllocator] FileAllocator: posix_fallocate? //發(fā)現(xiàn)日志至此不動(dòng)了
【$IP:37017-log】
2016-01-25T15:51:59.127+0800 I STORAGE? [FileAllocator] FileAllocator: posix_fallocate failed: errno:28 No space left on device falling back
//Congratulations!!!!!~~~
沒有空間!!我們查看下系統(tǒng)的空間使用情況。
[root@1 logs]# df -TH
Filesystem???? Type?? Size? Used Avail Use% Mounted on
/dev/vda1????? ext4??? 22G?? 21G???? 0 100% /
tmpfs????????? tmpfs? 8.4G???? 0? 8.4G?? 0% /dev/shm
/dev/vdb?????? ext4??? 22G?? 21G???? 0 100% /
/dev/vdb?????? ext4?? 529G? 208M? 502G?? 1% /data
[root@1 logs]#
就是這么簡(jiǎn)單的問題。這個(gè)是一位好朋友在運(yùn)行了我的腳本之后,反饋給我的。分享給大家。
其實(shí)在實(shí)踐中,能夠遇到各種預(yù)期外的狀況,很開心。
希望大家能多多交流。
謝謝,反饋給我這個(gè)問題的張同學(xué)~~撒花~~
?
轉(zhuǎn)載于:https://www.cnblogs.com/EndlessPang/p/5157745.html
總結(jié)
以上是生活随笔為你收集整理的Mongodb 故障分享 初始化时errmsg : exception: new file allocation failure 并且长时间处于STARTUP2...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: StackExchange.Redis
- 下一篇: H5小内容(一)