SERVER [x.x.x.x:27017] (Type: UNKNOWN)
|_/ Connection error (MongoSocketOpenException): Exception opening socket
|____/ Socket error: Connection refused (Connection refused)
Details:
Timed out after 5000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}, {address=x.x.x.x:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
connection binding to localhost:27017 but not x.x.x.x:27017,this is the problem.
1. find the mongodb configuration file
On Linux, a default /etc/mongod.conf configuration file is included when using a package manager to install MongoDB.
On Windows, a default <install directory>/bin/mongod.cfg configuration file is included during the installation.
On macOS, a default /usr/local/etc/mongod.conf configuration file is included when installing from MongoDB’s official Homebrew tap.
2.vim mongod.conf and then edit the 127.0.0.1 to 0.0.0.0 or special IP
# network interfaces net: port: 27017 bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. #Enter 127.0.0.1, :: to bind local machine
[root@xxx bin]# systemctl restart mongodb.service Failed to restart mongodb.service: Unit not found. [root@xxx bin]# netstat -nltp|grep mongod tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 7533/mongod
Failed to start mariadb.service: Unit not found.
[root@xxx ~]# sudo systemctl enable mongod [root@xxx ~]# sudo service mongod restart Redirecting to /bin/systemctl restart mongod.service Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details. [root@xxx ~]# systemctl status mongod.service ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Thu 2020-01-09 18:40:03 CST; 18s ago Docs: https://docs.mongodb.org/manual Process: 9171 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14) Process: 9168 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 9166 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS) Process: 9164 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS) Main PID: 7533 (code=exited, status=0/SUCCESS) Jan 09 18:40:03 xxx systemd[1]: Starting MongoDB Database Server... Jan 09 18:40:03 xxx mongod[9171]: about to fork child process, waiting un...s. Jan 09 18:40:03 xxx mongod[9171]: forked process: 9179 Jan 09 18:40:03 xxx mongod[9171]: ERROR: child process failed, exited wit...14 Jan 09 18:40:03 xxx mongod[9171]: To see additional information in this o...n. Jan 09 18:40:03 xxx systemd[1]: mongod.service: control process exited, c...14 Jan 09 18:40:03 xxx systemd[1]: Failed to start MongoDB Database Server. Jan 09 18:40:03 xxx systemd[1]: Unit mongod.service entered failed state. Jan 09 18:40:03 xxx systemd[1]: mongod.service failed. Hint: Some lines were ellipsized, use -l to show in full.
Cause by Mongodb SOCK isn't belong to mongodb group & user。
[root@xxx ~]# cd /tmp [root@xxx tmp]# ls Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> mongodb-27017.sock systemd-private-7a4de57bec754f068733415dfd6b94a6-chronyd.service-wJqM50 [root@xxx tmp]# sudo chown mongodb:mognodb mongodb-27017.sock chown: invalid user: ‘mongodb:mognodb’ [root@xxx tmp]# sudo chown mongod:mognod mongodb-27017.sock chown: invalid group: ‘mongod:mognod’ [root@xxx ~]# groups mongod mongod : mongod [root@xxx ~]sudo cchown mongod:mongod /tmp/mongodb-27017.sock [root@xxx ~]# sudo service mongod start Redirecting to /bin/systemctl start mongod.service [root@xxx ~]# systemctl start mongod.service [root@xxx ~]# sudo service mongod status Redirecting to /bin/systemctl status mongod.service ● mongod.service - MongoDB Database Server Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2020-01-15 10:59:13 CST; 25s ago
it works!
Process: 23490 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=48), Failed to start MongoDB...
1.查看 mongod.conf 配置文件找到 MongoDB日志path (/etc/mongod.conf):
path: /var/log/mongodb/mongod.log
2.查看日志具体报错信息
[initandlisten] Failed to set up listener: SocketException: Cannot assign requested address
[initandlisten] now exiting
[initandlisten] shutting down with code:48
最后有一个 Failed to set up listener: SocketException: Cannot assign requested address 错误信息,bind_ip 不要用公网地址,要用内网地址
3.vim /etc/mongod.conf 去掉 bindIp: "127.0.0.1,xxx.xx.xx.xx" 后的公网IP
重启 systemctl restart mongod.service
Active: active (running) since Mon 2020-02-03 11:46:53 CST; 2min 52s ago
It works!
相关推荐
然而,在日常运维中,我们可能会遇到启动MongoDB时遇到各种问题,如本文标题所示:"MongoDB启动报错 Process: 29784 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=14)"。这个错误提示意味着MongoDB服务...
Containerd 是一个控制 runC 的守护进程,主要是为了性能和密度。Containerd 提供一个命令行客户端和 API,在一个机器上管理容器。Containerd 使用 runC 来根据 OCI 规范运行容器 。Containerd 利用 runC 的高级特性...
● hostapd.service - Advanced IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP ... Process: 12218 ExecStart=/usr/sbin/hostapd -P /run/hostapd.pid -B $DAEMON_OPTS ${DAEMON_CONF} (code=exited, status=1/FAILURE)
ExecStart=/usr/local/bin/dockerd \ --graph=/data/docker --selinux-enabled=false \ --log-opt max-size=1g \ --log-level=error \ $DOCKER_NETWORK_OPTIONS ExecReload=/bin/kill -s HUP $MAINPID ...
Linux编译静态链接出现:/usr/bin/ld: cannot find -lc. 将libc.a拷贝到usr/lib/中,问题得以解决。
配置环境变量,vi /etc/profile,在文件最后添加配置 JAVA_HOME=/usr/local/java/jdk1.8.0_231/ JRE_HOME=/usr/local/java/jdk1.8.0_231/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_...
/bin/bashPATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbinstep=5 #间隔的秒数,不能大于10for (( i = 0; i ; i=(i+step) )); docurl ...
export PATH=/usr/mongodb/bin:$PATH 然后,使用以下命令使环境变量生效: $ source /etc/profile 创建数据库目录和日志文件夹 创建数据库目录和日志文件夹是 MongoDB 运行的必要条件。使用以下命令创建数据库...
ExecStart=/usr/local/bin/weather_exporter_jingtian --port 7001 ExecReload=/bin/kill -HUP $MAINPID TimeoutStopSec=20s Restart=always [Install] WantedBy=multi-user.target systemctl daemon-reload ...
修改:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/arm/4.3.2/bin" 改为:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/work/...
我这里是 usr/local/jdk/ 2)输入命令 chmod 777 jdk1.8.0_221/bin/java修改权限 3)再次输入 java -version 成功 总结 以上所述是小编给大家介绍的解决-BASH: /HOME/JAVA/JDK1.8.0_221/BIN/JAVA: 权限不够问题,...
/usr/local/mongodb/mongodb-linux-2.0.7/bin/mongod --dbpath=/usr/local/mongodb/data/db --logpath=/usr/local/mongodb/mongodb-linux-2.0.7/logs/mongodb.log --logappend --port=27017 --fork 知识点 6:配置...
[root@web1 ~]# cat /lib/systemd/...ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf #ExecReload=/usr/local/nginx/sbin/nginx -s reload ExecReload=/usr/bin/kill -s HUP $MAINPID
PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin step=5 #间隔的秒数,不能大于10 for (( i = 0; i ; i=(i+step) )); do curl http://xxx/index/wpay/auto_transfer3 curl http://xxx/index/wpay/auto_transfer2...
/bin/sh: cc: command not found make[1]: * [adlist.o] Error 127 make[1]: Leaving directory `/usr/local/redis-5.0.0/src' make: * [all] Error 2 解决方法是安装 GCC 编译工具,使用以下命令: yum install ...
/usr/local/webserver/mysql/bin:/usr/local/webserver/mysql/bin/:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin 说明添加P
linux输入yum后提示: -bash: /usr/bin/yum: No such file or directory的解决方案 今天在安装程序时,发现有一个插件未安装,我就随手敲了一个命令,看都没看 yum remove yum 然后就杯具了… [root@localhost ~]#...
export CATALINA_HOME=/usr/local/tomcat export CLASSPATH=.:$JAVA_HOME/lib:$CATALINA_HOME/lib export PATH=$PATH:$CATALINA_HOME/bin 执行命令: source /etc/profile 查看环境变量: echo $CLASSPATH 3. 启动...
例如,通常为`/usr/bin`或`/usr/local/bin`。如果不在PATH中,可以通过修改`~/.bashrc`或`/etc/environment`文件添加。 5. **Systemd与Init.d的区别** 在较新的Linux发行版中,Systemd已成为默认的服务管理工具,...