Как настроить два сервера MongoDB в одной локальной системе? - PullRequest
0 голосов
/ 09 июля 2020

Чтобы выполнить репликацию в MongoDB в Windows 10, в одной системе необходимо несколько серверов. Но клиент не может подключиться к серверу. После создания хоста с использованием

mongod --bind_ip localhost,My-Example-Associated-Hostname

вывод будет

2020-07-09T19:41:00.708+0530 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-07-09T19:41:01.913+0530 W  ASIO     [main] No TransportLayer configured during NetworkInterface startup
2020-07-09T19:41:02.065+0530 I  CONTROL  [initandlisten] MongoDB starting : pid=18840 port=27017 dbpath=C:\data\db\ 64-bit host=DESKTOP-1R3OPQG
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] db version v4.2.7
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] git version: 51d9fe12b5d19720e72dcd7db0f2f17dd9a19212
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] allocator: tcmalloc
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] modules: none
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten] build environment:
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten]     distmod: 2012plus
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten]     distarch: x86_64
2020-07-09T19:41:02.066+0530 I  CONTROL  [initandlisten]     target_arch: x86_64
2020-07-09T19:41:02.067+0530 I  CONTROL  [initandlisten] options: { net: { bindIp: "localhost,My-Example-Associated-Hostname" } }
2020-07-09T19:41:03.115+0530 W  NETWORK  [initandlisten] Found no addresses for HostNotFound: Could not find address for My-Example-Associated-Hostname:27017: SocketException: No such host is known.
2020-07-09T19:41:03.142+0530 I  STORAGE  [initandlisten] Detected data files in C:\data\db\ created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2020-07-09T19:41:03.143+0530 I  STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3533M,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-07-09T19:41:03.348+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303863:347681][18840:140716566797904], txn-recover: Recovering log 11 through 12
2020-07-09T19:41:03.497+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303863:497260][18840:140716566797904], txn-recover: Recovering log 12 through 12
2020-07-09T19:41:03.641+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303863:641697][18840:140716566797904], txn-recover: Main recovery loop: starting at 11/6144 to 12/256
2020-07-09T19:41:03.900+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303863:899522][18840:140716566797904], txn-recover: Recovering log 11 through 12
2020-07-09T19:41:04.077+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303864:77045][18840:140716566797904], txn-recover: Recovering log 12 through 12
2020-07-09T19:41:04.210+0530 I  STORAGE  [initandlisten] WiredTiger message [1594303864:209691][18840:140716566797904], txn-recover: Set global recovery timestamp: (0, 0)
2020-07-09T19:41:04.667+0530 I  RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
2020-07-09T19:41:04.704+0530 I  STORAGE  [initandlisten] Timestamp monitor starting
2020-07-09T19:41:04.799+0530 I  CONTROL  [initandlisten]
2020-07-09T19:41:04.800+0530 I  CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-07-09T19:41:04.801+0530 I  CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2020-07-09T19:41:04.801+0530 I  CONTROL  [initandlisten]
2020-07-09T19:41:04.895+0530 I  SHARDING [initandlisten] Marking collection local.system.replset as collection version: <unsharded>
2020-07-09T19:41:04.915+0530 I  STORAGE  [initandlisten] Flow Control is enabled on this deployment.
2020-07-09T19:41:04.916+0530 I  SHARDING [initandlisten] Marking collection admin.system.roles as collection version: <unsharded>
2020-07-09T19:41:04.933+0530 I  SHARDING [initandlisten] Marking collection admin.system.version as collection version: <unsharded>
2020-07-09T19:41:04.961+0530 I  SHARDING [initandlisten] Marking collection local.startup_log as collection version: <unsharded>
2020-07-09T19:41:07.946+0530 I  FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'C:/data/db/diagnostic.data'
2020-07-09T19:41:07.950+0530 I  SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: <unsharded>
2020-07-09T19:41:07.997+0530 I  SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: <unsharded>
2020-07-09T19:41:08.045+0530 I  NETWORK  [listener] Listening on 127.0.0.1
2020-07-09T19:41:08.045+0530 I  NETWORK  [listener] waiting for connections on port 27017
2020-07-09T19:41:08.083+0530 I  SHARDING [ftdc] Marking collection local.oplog.rs as collection version: <unsharded>

Затем в клиенте я даю

mongo --host My-Example-Associated-Hostname

Но вывод

MongoDB shell version v4.2.7
connecting to: mongodb://My-Example-Associated-Hostname:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-07-09T19:41:30.776+0530 E  QUERY    [js] Error: couldn't connect to server My-Example-Associated-Hostname:27017, connection attempt failed: HostNotFound: Could not find address for My-Example-Associated-Hostname:27017: SocketException: No such host is known. :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-07-09T19:41:30.812+0530 F  -        [main] exception: connect failed
2020-07-09T19:41:30.812+0530 E  -        [main] exiting with code 1

Как решить эту проблему?

1 Ответ

0 голосов
/ 09 июля 2020

Ваше имя хоста не подключается при вызове клиента. Это должно быть mon go --host localhost

...