-
반응형
mongo 쉘 진입을 위해서 mongo 입력시 Error: couldn't connect to server 127.0.0.1 오류에 직면 했다.
$ mongo MongoDB shell version v4.2.10 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb 2020-10-23T16:57:38.500+0000 E QUERY [js] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused : connect@src/mongo/shell/mongo.js:353:17 @(connect):2:6 2020-10-23T16:57:38.501+0000 F - [main] exception: connect failed 2020-10-23T16:57:38.501+0000 E - [main] exiting with code 1
사실 이 오류가 뜨는 이유는 다양해서 딱히 정해진 해결법이 하나 있다고는 할 수 없다. 그래서 mongod를 실행해서 확인 해봐야 한다.
$ mongod 2020-06-09T19:52:14.630+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2020-06-09T19:52:14.632+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] MongoDB starting : pid=27618 port=27017 dbpath=/data/db 64-bit host=ip-*-*-*-*.eu-central-1.compute.internal 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] db version v4.2.7 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] allocator: tcmalloc 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] modules: none 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] build environment: 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distmod: rhel70 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] distarch: x86_64 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] target_arch: x86_64 2020-06-09T19:52:14.632+0000 I CONTROL [initandlisten] options: { storage: { dbPath: "/data/db" } } 2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. 2020-06-09T19:52:14.633+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=256M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress], 2020-06-09T19:52:15.356+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:356822][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7 2020-06-09T19:52:15.412+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:412272][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7 2020-06-09T19:52:15.500+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:500634][27618:0x7f9b34a81c40], txn-recover: Main recovery loop: starting at 6/22528 to 7/256 2020-06-09T19:52:15.609+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:609015][27618:0x7f9b34a81c40], txn-recover: Recovering log 6 through 7 2020-06-09T19:52:15.672+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:672877][27618:0x7f9b34a81c40], txn-recover: Recovering log 7 through 7 2020-06-09T19:52:15.727+0000 I STORAGE [initandlisten] WiredTiger message [1591732335:727038][27618:0x7f9b34a81c40], txn-recover: Set global recovery timestamp: (0, 0) 2020-06-09T19:52:15.735+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0) 2020-06-09T19:52:15.739+0000 I STORAGE [initandlisten] Timestamp monitor starting 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] ** We suggest setting it to 'never' 2020-06-09T19:52:15.741+0000 I CONTROL [initandlisten] 2020-06-09T19:52:15.743+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded> 2020-06-09T19:52:15.744+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment. 2020-06-09T19:52:15.744+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded> 2020-06-09T19:52:15.745+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded> 2020-06-09T19:52:15.746+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded> 2020-06-09T19:52:15.746+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' 2020-06-09T19:52:15.748+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded> 2020-06-09T19:52:15.749+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded> 2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock 2020-06-09T19:52:15.749+0000 I NETWORK [listener] Listening on 127.0.0.1 2020-06-09T19:52:15.749+0000 I NETWORK [listener] waiting for connections on port 27017 2020-06-09T19:52:16.000+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>
저번에 겪었던 dbpath를 지정안해서 생긴 NonExistentPath: Data directory /data/db 오류는 아니였고 Marking collection local.oplog.rs as collection version: <unsharded>이 단계에서 더 이상 진행이 되지 않던 문제가 있었다.
일단 복구 실행옵션인 --repair를 실행시키고 재시작 이후 mongo를 다시 실행 시켜보았다.
$ mongod --repair 2020-10-23T17:24:42.552+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' 2020-10-23T17:24:42.553+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup 2020-10-23T17:24:42.554+0000 I CONTROL [initandlisten] MongoDB starting : pid=15466 port=27017 dbpath=/data/db 64-bit host=sugimoto-1 2020-10-23T17:24:42.554+0000 I CONTROL [initandlisten] db version v4.2.10 ... $ service mongod restart $ mongo MongoDB shell version v4.2.10 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb Implicit session: session { "id" : UUID("51271f1b-ddc0-4774-9aed-c014ed2224ec") } MongoDB server version: 4.2.10 Server has startup warnings: 2020-10-23T17:50:41.720+0000 I STORAGE [initandlisten] 2020-10-23T17:50:41.720+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 2020-10-23T17:50:41.720+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem 2020-10-23T17:50:42.606+0000 I CONTROL [initandlisten] 2020-10-23T17:50:42.606+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. 2020-10-23T17:50:42.606+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. 2020-10-23T17:50:42.606+0000 I CONTROL [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended. 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** WARNING: This server is bound to localhost. 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** Remote systems will be unable to connect to this server. 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip <address> to specify which IP 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning. 2020-10-23T17:50:42.607+0000 I CONTROL [initandlisten] --- Enable MongoDB's free cloud-based monitoring service, which will then receive and display metrics about your deployment (disk utilization, CPU, operation statistics, etc). The monitoring data will be available on a MongoDB website with a unique URL accessible to you and anyone you share the URL with. MongoDB may use this information to make product improvements and to suggest MongoDB products and deployment options to you. To enable free monitoring, run the following command: db.enableFreeMonitoring() To permanently disable this reminder, run the following command: db.disableFreeMonitoring() --- >
그러자 갑자기 잘 작동하는 mongo...
이 방식이 안된다면 mongod.lock을 수동으로 지우고 /etc/mongod.conf을 수정하는 방법을 선택해야 하는데 이 방식은 아래 링크로 가서 해결하면 된다. 일본어지만 그냥 대충 흐름만 보면 뭘 시키는지 알 수 있다. 정 안되면 번역기를...
qiita.com/sirius1000/items/e4dc31bb3ce186cfe9d8
반응형'코딩' 카테고리의 다른 글
REACT-NATIVE 버튼 둥글게 만들기 (0) 2020.11.11 react native 안드로이드 스튜디오에서 에뮬레이터 앱 실행이 안되는 현상 (0) 2020.11.09 REACT NATIVE란 (0) 2020.11.09 HTTPS, 대칭 키와 비대칭 키 (0) 2020.11.04 grabCut를 이용한 이미지 전경(배경)제거 - png로 배경 투명! (0) 2020.10.27