Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js__js

來源:互聯網
上載者:User

mongodb所在的目錄許可權被更改導致mongodb意外down機

啟動報錯:

Tue Apr 15 02:49:13.417 [journal] warning: open of lsn file failed
Tue Apr 15 02:50:25.482 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:50:25.482 [journal] warning: open of lsn file failed
Tue Apr 15 02:52:03.172 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:52:03.172 [journal] warning: open of lsn file failed
Tue Apr 15 02:53:13.817 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:53:13.817 [journal] warning: open of lsn file failed
Tue Apr 15 02:53:56.884 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:53:56.884 [journal] warning: open of lsn file failed
Tue Apr 15 02:55:52.733 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:55:52.733 [journal] warning: open of lsn file failed
Tue Apr 15 02:55:55.930 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:55:55.930 [journal] warning: open of lsn file failed
Tue Apr 15 02:57:37.438 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:57:37.438 [journal] warning: open of lsn file failed
Tue Apr 15 02:58:42.993 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:58:42.993 [journal] warning: open of lsn file failed
Tue Apr 15 02:59:03.107 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 02:59:03.107 [journal] warning: open of lsn file failed
Tue Apr 15 03:00:01.257 [conn837] CMD: drop koolearn.tmp.mr.link_694
Tue Apr 15 03:00:01.285 [conn837] CMD: drop koolearn.tmp.mr.link_694_inc
Tue Apr 15 03:00:01.379 [conn837] build index koolearn.tmp.mr.link_694_inc { 0: 1 }
Tue Apr 15 03:00:01.669 [conn837] mr failed, removing collection :: caused by :: boost::filesystem::create_directory: Permission den
ied: "/tol/mongodb/data/_tmp/esort.1397502001.1410"
Tue Apr 15 03:00:01.672 [journal] In File::open(), ::open for '/tol/mongodb/data/journal/lsn' failed with errno:13 Permission denied
Tue Apr 15 03:00:01.672 [journal] warning: open of lsn file failed


+++查看許可權,發現都變成mysql的了

[root@localhost tol]# ll -h
total 28K
drwx------ 2 mysql mysql  16K Jun  8  2013 lost+found
drwxr-xr-x 5 mysql mysql 4.0K Jun 24  2013 mongodb
drwxrwxr-x 3 mysql mysql 4.0K Apr 14 05:38 mongo_dump


更改一下許可權:

[root@localhost tol]# chown -R mongodb:mongodb /tol/mongo*
[root@localhost tol]# ls -lh
total 28K
drwx------ 2 mysql   mysql    16K Jun  8  2013 lost+found
drwxr-xr-x 5 mongodb mongodb 4.0K Jun 24  2013 mongodb
drwxrwxr-x 3 mongodb mongodb 4.0K Apr 14 05:38 mongo_dump


+++再次啟動:

[mongodb@localhost ~]$ nohup mongod --auth --dbpath=/tol/mongodb/data/ --logpath=/tol/mongodb/log/mongo.log  --logappend --port=27017 > /tol/mongodb/log/start_mongodb.log 2>&1 &
[1] 26948

[mongodb@localhost ~]$ mongo
MongoDB shell version: 2.4.4
connecting to: koolearn
Tue Apr 15 17:46:01.367 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed
[mongodb@localhost ~]$ 

+++檢查發現是因為mongo意外down掉導致mongod.lock檔案異常,直接刪掉這個檔案就可以

[mongodb@localhost mongodb]$ locate mongod.lock
/tol/mongodb/data/mongod.lock

[mongodb@localhost data]$ mv mongod.lock ../


++再次啟動就可以正常串連了

[mongodb@localhost ~]$ mongo -u xxxxxxx -p xxxx ]XXX
MongoDB shell version: 2.4.4





相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.