due to the need of the project, mongodb is installed on a virtual machine, but the following error occurs during startup: font>
[root@localhost bin]# ./mongo
MongoDB shell version v3.4.0
connecting to: mongodb://127.0.0.1:27017
2018-09-27T21:11:14.779+0800 W NETWORK [main] Failed to connect to 127.0.0.1:27017, reason: Connection refused
2018-09-27T21:11:14.780+0800 E QUERY [main] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:234:13
@(connect):1:6
exception: connect failed
the reason for the above may be in the data directory mongod.lock The problem with the document. You can use the command to repair: font>
[root@localhost mongodb]# ./bin/mongod --repair
but for impatient people like me, I went directly to the directory and deleted the file.
After repairing or deleting, restart mongodb: font>
./mongod --dbpath=/usr/local/mongodb/data/db/
then appears as follows: font>
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] MongoDB starting : pid=6748 port=27017 dbpath=/usr/local/mongodb/data/db/ 64-bit host=localhost.localdomain
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] db version v3.4.0
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] git version: f4240c60f005be757399042dc12f6addbc3170c1
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] allocator: tcmalloc
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] modules: none
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] build environment:
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] distarch: x86_64
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] target_arch: x86_64
2018-09-27T21:12:16.441+0800 I CONTROL [initandlisten] options: { storage: { dbPath: "/usr/local/mongodb/data/db/" } }
2018-09-27T21:12:16.482+0800 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=1383M,session_max=20000,eviction=(threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.483+0800 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/usr/local/mongodb/data/db/diagnostic.data'
2018-09-27T21:12:17.769+0800 I INDEX [initandlisten] build index on: admin.system.version properties: { v: 2, key: { version: 1 }, name: "incompatible_with_version_32", ns: "admin.system.version" }
2018-09-27T21:12:17.769+0800 I INDEX [initandlisten] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-09-27T21:12:17.793+0800 I INDEX [initandlisten] build index done. scanned 0 total records. 0 secs
2018-09-27T21:12:17.794+0800 I COMMAND [initandlisten] setting featureCompatibilityVersion to 3.4
2018-09-27T21:12:17.794+0800 I NETWORK [thread1] waiting for connections on port 27017
2018-09-27T21:13:22.539+0800 I NETWORK [thread1] connection accepted from 127.0.0.1:51708 #1 (1 connection now open)
2018-09-27T21:13:22.540+0800 I NETWORK [conn1] received client metadata from 127.0.0.1:51708 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.0" }, os: { type: "Linux", name: "CentOS Linux release 7.5.1804 (Core) ", architecture: "x86_64", version: "Kernel 3.10.0-862.el7.x86_64" } }
2018-09-27T21:14:00.424+0800 I NETWORK [thread1] connection accepted from 192.168.20.29:10351 #2 (2 connections now open)
2018-09-27T21:14:00.424+0800 I - [conn2] end connection 192.168.20.29:10351 (2 connections now open)
2018-09-27T21:14:00.969+0800 I NETWORK [thread1] connection accepted from 192.168.20.29:10386 #3 (2 connections now open)
2018-09-27T21:14:00.969+0800 I NETWORK [thread1] connection accepted from 192.168.20.29:10387 #4 (3 connections now open)
2018-09-27T21:14:03.063+0800 I NETWORK [thread1] connection accepted from 192.168.20.29:10392 #5 (4 connections now open)
2018-09-27T21:14:03.063+0800 I NETWORK [thread1] connection accepted from 192.168.20.29:10393 #6 (5 connections now open)
2018-09-27T21:14:03.063+0800 I - [conn6] end connection 192.168.20.29:10393 (5 connections now open)
2018-09-27T21:14:03.469+0800 I - [conn5] end connection 192.168.20.29:10392 (4 connections now open)
2018-09-27T21:16:31.073+0800 I NETWORK [thread1] connection accepted from 192.168.21.247:1138 #7 (4 connections now open)
2018-09-27T21:16:31.714+0800 I INDEX [conn7] build index on: NCRE3.01.files properties: { v: 2, key: { filename: 1, uploadDate: 1 }, name: "filename_1_uploadDate_1", ns: "NCRE3.01.files" }
2018-09-27T21:16:31.714+0800 I INDEX [conn7] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-09-27T21:16:31.765+0800 I INDEX [conn7] build index done. scanned 0 total records. 0 secs
2018-09-27T21:16:31.765+0800 I COMMAND [conn7] insert NCRE3.system.indexes ninserted:1 numYields:0 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { W: 1 } }, Collection: { acquireCount: { w: 1 } } } 550ms
2018-09-27T21:16:32.627+0800 I INDEX [conn7] build index on: NCRE3.01.chunks properties: { v: 2, unique: true, key: { files_id: 1, n: 1 }, name: "files_id_1_n_1", ns: "NCRE3.01.chunks" }
2018-09-27T21:16:32.627+0800 I INDEX [conn7] building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2018-09-27T21:16:32.994+0800 I INDEX [conn7] build index done. scanned 0 total records. 0 secs
2018-09-27T21:16:32.994+0800 I COMMAND [conn7] insert NCRE3.system.indexes ninserted:1 numYields:0 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { W: 1 } }, Collection: { acquireCount: { w: 1 } } } 1216ms
2018-09-27T21:16:35.895+0800 I - [conn7] end connection 192.168.21.247:1138 (4 connections now open)
^C2018-09-27T21:17:17.799+0800 I CONTROL [signalProcessingThread] got signal 2 (Interrupt), will terminate after current cmd ends
2018-09-27T21:17:17.799+0800 I NETWORK [signalProcessingThread] shutdown: going to close listening sockets...
2018-09-27T21:17:17.799+0800 I NETWORK [signalProcessingThread] closing listening socket: 6
2018-09-27T21:17:17.799+0800 I NETWORK [signalProcessingThread] closing listening socket: 7
2018-09-27T21:17:17.799+0800 I NETWORK [signalProcessingThread] removing socket file: /tmp/mongodb-27017.sock
2018-09-27T21:17:17.801+0800 I NETWORK [signalProcessingThread] shutdown: going to flush diaglog...
2018-09-27T21:17:17.801+0800 I FTDC [signalProcessingThread] Shutting down full-time diagnostic data capture
2018-09-27T21:17:17.803+0800 I STORAGE [signalProcessingThread] WiredTigerKVEngine shutting down
2018-09-27T21:17:19.283+0800 I STORAGE [signalProcessingThread] shutdown: removing fs lock...
2018-09-27T21:17:19.283+0800 I CONTROL [signalProcessingThread] now exiting
2018-09-27T21:17:19.283+0800 I CONTROL [signalProcessingThread] shutting down with code:0
this interface is successful. Then, do not close the interface, open a window again to start: font>
[root@localhost ~]# cd /usr/local/mongodb
[root@localhost mongodb]# ./bin/mongo
MongoDB shell version v3.4.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.0
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions?Try the support group
http://groups.google.com/group/mongodb-user
Server has startup warnings:
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-09-27T21:12:17.294+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten]
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten] ** We suggest setting it to 'never'
2018-09-27T21:12:17.295+0800 I CONTROL [initandlisten]
the appearance of such an interface means that the problem has been solved ~
at this time, visit the website and find that mongodb’s service is really started:
thank you for reading ~ font> font>
Read More:
- error:Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused;error:couldn‘t ….
- Mongodb uses Mongo to report error: could’t connect to server 127.0.0.1:27017, connection attempt failed: socket
- curl: (7) Failed connect to localhost:9200; Connection refused
- curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
- [Solved] failed to connect to server, reason: Unable to establish connection
- error: \*1035 connect() failed (111: Connection refused) while connecting to upstream, client…..
- failed to connect to ‘192.168.199.143:5555‘: Connection refused
- 【Synergy】Error:failed to connect to server:Connection was refused
- samba Error NT_STATUS_CONNECTION_REFUSED Failed to connect with SMB1 — no workgroup available
- Solve the MAC terminal download error curl: (7) failed to connect to raw.githubusercontent.com port 443: Connection refused
- Nginx reports 502 error, log connect() failed (111: Connection refused) while connecting to upstream. A personal effective solution
- Failed to connect to 17.0.0.1 port 1080: Connection refused
- How to Fix java.net.ConnectException: Connection refused: connect
- The mongoDB service failed to start (exception: connect failed)
- JDBC connect to Sql Server to connect to the database–The TCP/IP connection to the host localhost, port 1433 has failed
- Zookeeper connection timeout problem, and refused to connect to solve the problem
- Java connection SQL error, network error IO Exception:Connection refused :connect
- (20200916 Solved)Docker||redis-cli Could not connect to Redis at 127.0.0.1:6379: Connection refused
- solve java.net.ConnectException : Connection refused:connect report errors
- About JMH running ERROR: transport error 202: connect failed: Connection refused ERROR