ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied

2021-08-31 21:03:10  阅读:1297  来源: 互联网

标签:tmp mongod socket Permission mongodb 27017 usr local log


my mongodb server had stoped working on my mac:

ISSUE:
Failed to unlink socket file /tmp/mongodb-27017.sock Permission denied

check the log file and found the error:

view /usr/local/var/log/mongodb/mongod.log

Check the /tmp/mongodb-27017.sock permission, owner is root?

 

ls -ls /tmp/mongodb-27017.sock
output

"0 srwx------ 1 mongodb mongodb 0 Aug 24 04:01 /tmp/mongodb-27017.sock"

 

solution:

 

rm /tmp/mongodb-27017.sock

then

 

systemctl start mongod.service

 

start mongo, it appears:

 

$ mongo
MongoDB shell version v4.2.5
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
2020-04-08T20:05:01.381+0800 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:341:17
@(connect):2:6
2020-04-08T20:05:01.384+0800 F - [main] exception: connect failed
2020-04-08T20:05:01.384+0800 E - [main] exiting with code 1

try to repair, but failed!

 

$ mongod -–repair
Error parsing command line: unrecognised option '-–repair'
try 'mongod --help' for more information

check th mongod.conf file (/usr/local/etc/mongod.conf), but it's not in the path.

 

view /etc/mongod.conf

ok, reinstall ?

 

$ brew uninstall mongodb-community@4.2

$ brew install mongodb-community@4.2

$ brew services start mongodb-community@4.2

 

In addition to the binaries, the install creates:

the configuration file (/usr/local/etc/mongod.conf)
the log directory path (/usr/local/var/log/mongodb)
the data directory path (/usr/local/var/mongodb)
run mongodb community :

$ mongod --config /usr/local/etc/mongod.conf

about to fork child process, waiting until server is ready for connections.

forked process: 37247

ERROR: child process failed, exited with error number 1

To see additional information in this output, start without the "--fork" option.

192:etc jessea$ mongod --config /usr/local/etc/mongod.conf

2020-04-08T21:51:29.689+0800 F CONTROL [main] Failed global initialization: FileNotOpen: logpath "/usr/local/var/log/mongodb/mongo.log" should name a file, not a directory.

 

$ cd /usr/local/var/log/mongodb/

// if you want to remove file, use rm filename

 

$ rm -r mongo.log

$ touch mongo.log


// To run MongoDB manually as a background process

$ mongod --config /usr/local/etc/mongod.conf --fork

about to fork child process, waiting until server is ready for connections.

forked process: 37320

child process started successfully, parent exiting

 

$ brew services start mongodb-community@4.2

Service `mongodb-community` already started, use `brew services restart mongodb-community` to restart.

 

$ brew services list

Name Status User Plist

mongodb-community started /Users/jessea/Library/LaunchAgents/homebrew.mxcl.mongodb-community.plist

// connect a mongo shell to the running instance. ( or "mongo --port 27017")

$ mongo

MongoDB shell version v4.2.5

connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb

Implicit session: session { "id" : UUID("751dee53-9e1f-4c41-a361-95e2918f4426") }

MongoDB server version: 4.2.5

Server has startup warnings:

2020-04-08T22:05:15.048+0800 I CONTROL [initandlisten]

2020-04-08T22:05:15.049+0800 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.

2020-04-08T22:05:15.050+0800 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.

2020-04-08T22:05:15.051+0800 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()

---

> exit

标签:tmp,mongod,socket,Permission,mongodb,27017,usr,local,log
来源: https://www.cnblogs.com/diruizhixia/p/15212143.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有