MongoNetworkError: не удалось подключиться к серверу 149.28.156.203:27017 при первом подключении - PullRequest
0 голосов
/ 21 февраля 2019

Я начинаю с mongdb

И я установил mongdb, следуя инструкциям

https://www.digitalocean.com/community/tutorials/how-to-install-mongodb-on-centos-7

Не пропуская ни одного шага, я также импортировал данные

Но когда я подключаюсь к данным, я получаю следующую ошибку

MongoNetworkError: failed to connect to server 149.28.156.203:27017 on first connect
MongoNetworkError: connect EHOSTUNREACH 149.28.156.203:27017

https://i.stack.imgur.com/FdSGA.png

Я создал дополнительного пользователя для теста данных

db.createUser({ user: "username", pwd: "password", roles: [ { role: "readWrite", db: "test" } ] })

Информация

Mongodb работает

# systemctl status mongod

mongod.service - High-performance, schema-free document-oriented database
   Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
   Active: active (running) since T5 2019-02-21 08:47:02 UTC; 3min 55s ago
     Docs: https://docs.mongodb.org/manual
  Process: 26534 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
  Process: 26532 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 26530 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
  Process: 26528 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
 Main PID: 26537 (mongod)
   CGroup: /system.slice/mongod.service
           └─26537 /usr/bin/mongod -f /etc/mongod.conf

Пользователь, пароль, имя, IP-адрес при подключении не так

mongodb://username:password@149.28.156.203:27017/?authSource=test

# монго

MongoDB shell version v3.4.19
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.19
Server has startup warnings: 
2019-02-21T08:47:02.120+0000 I STORAGE  [initandlisten] 
2019-02-21T08:47:02.120+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-02-21T08:47:02.120+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] 
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] 
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] 
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] 
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-21T08:47:02.687+0000 I CONTROL  [initandlisten] 

Файл /etc/mongo.conf

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# Where and how to store data.
storage:
  dbPath: /var/lib/mongo
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
  fork: true  # fork and run in background
  pidFilePath: /var/run/mongodb/mongod.pid  # location of pidfile

# network interfaces
net:
  port: 27017
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:

Монго лог

sudo tail / var /log / mongodb / mongod.log

2019-02-21T09:23:36.131+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-21T09:23:36.131+0000 I CONTROL  [initandlisten] 
2019-02-21T09:23:36.131+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-02-21T09:23:36.131+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-21T09:23:36.131+0000 I CONTROL  [initandlisten] 
2019-02-21T09:23:36.134+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/lib/mongo/diagnostic.data'
2019-02-21T09:23:36.139+0000 I NETWORK  [thread1] waiting for connections on port 27017
2019-02-21T09:24:03.773+0000 I NETWORK  [thread1] connection accepted from 127.0.0.1:54348 #1 (1 connection now open)
2019-02-21T09:24:03.774+0000 I NETWORK  [conn1] received client metadata from 127.0.0.1:54348 conn1: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.19" }, os: { type: "Linux", name: "CentOS Linux release 7.6.1810 (Core) ", architecture: "x86_64", version: "Kernel 3.10.0-957.1.3.el7.x86_64" } }
2019-02-21T09:29:00.515+0000 I -        [conn1] end connection 127.0.0.1:54348 (1 connection now open)

Так в чем же причина?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...