1. 程式人生 > >linux -mongodb 啟動問題(Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : )

linux -mongodb 啟動問題(Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed : )

-bash-4.1# ./mongo
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
2017-09-20T20:02:14.620+0800 W NETWORK [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: Connection refused
2017-09-20T20:02:14.620+0800 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed :

[email protected]/mongo/shell/mongo.js:237:13
@(connect):1:6

啟動時,錯誤如上

(1) cd /usr/local/mongodb/bin
(2) ./mongod –dbpath =/data/db/
(3)出現內容如下:(後面省略)
-bash-4.1# /usr/local/mongodb/bin/mongod –dbpath=/data/db/
2017-09-20T20:31:49.199+0800 I CONTROL [initandlisten] MongoDB starting : pid=xxx port=xxx dbpath=/data/db/ 64-bit host=xxxx
2017-09-20T20:31:49.199+0800 I CONTROL [initandlisten] db version v3.4.6
2017-09-20T20:31:49.199+0800 I CONTROL [initandlisten] git version:

(4) 上一步路徑設定成功,但是不要關閉這個介面,需要重新開啟一個新的視窗來啟動mongo
(5)-bash-4.1# cd /usr/local/mongodb/
(6)-bash-4.1# ./bin/mongo
(7)出現如下介面表示啟動成功:
-bash-4.1# cd /usr/local/mongodb/
-bash-4.1# ./bin/mongo
MongoDB shell version v3.4.6
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.6
Server has startup warnings:
2017-09-20T20:14:22.717+0800 I STORAGE [initandlisten]
2017-09-20T20:14:22.717+0800 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-09-20T20:14:22.717+0800 I STORAGE [initandlisten] ** See

http://dochub.mongodb.org/core/prodnotes-filesystem
2017-09-20T20:14:23.057+0800 I CONTROL [initandlisten]
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten]
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten]
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten]
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten]
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 15219 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2017-09-20T20:14:23.058+0800 I CONTROL [initandlisten]