我正在开发一个由mongodb支持的应用程序。无论是从shell还是以编程方式从应用程序进行与数据库服务器的交互都可以正常工作。问题是它只有在我以root身份运行服务器时才有效。否则它不起作用。在Windows上工作时我没有这个问题。我正在使用ubuntu 16.04。
首先,它是db路径,我更改了配置文件。然后它告诉我它无法创建锁文件,我更改了权限,(我不确定这是不是很好的做法),现在我有这个错误:
Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2017-04-29T21:22:44.897+0100 I STORAGE [initandlisten]
2017-04-29T21:22:44.897+0100 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-04-29T21:22:44.897+0100 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-04-29T21:22:44.897+0100 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=413M,session_max=20000,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),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
2017-04-29T21:22:44.922+0100 E STORAGE [initandlisten] WiredTiger error (1) [1493497364:922160][28430:0x7f168c50dcc0], file:WiredTiger.wt, connection: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
2017-04-29T21:22:44.924+0100 I - [initandlisten] Assertion: 28595:1: Operation not permitted src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 267
2017-04-29T21:22:44.924+0100 I STORAGE [initandlisten] exception in initAndListen: 28595 1: Operation not permitted, terminating
此外,当我尝试将其作为服务service mongod start
运行时,它会抛出一个错误,即没有这样的服务文件。我在/ etc / systemd / system目录中创建了一个mongod.service文件但它仍然给出了相同的错误,没有这样的文件。
以下是systemctl status mongod
的结果:
mongod.service - MongoDB Database Service
Loaded: loaded (/etc/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: inactive (dead) (Result: exit-code) since ح 2017-04-30 00:15:00 WEST; 14h ago
Process: 958 ExecStart=/usr/bin/mongod --config /etc/mongod.conf (code=exited, status=100)
Main PID: 958 (code=exited, status=100)
أبر 30 00:15:00 archer09 systemd[1]: mongod.service: Main process exited, code=exited, status=100/n/a
أبر 30 00:15:00 archer09 systemd[1]: mongod.service: Unit entered failed state.
أبر 30 00:15:00 archer09 systemd[1]: mongod.service: Failed with result 'exit-code'.
أبر 30 00:15:00 archer09 systemd[1]: mongod.service: Service hold-off time over, scheduling restart.
أبر 30 00:15:00 archer09 systemd[1]: Stopped MongoDB Database Service.
أبر 30 00:15:00 archer09 systemd[1]: mongod.service: Start request repeated too quickly.
أبر 30 00:15:00 archer09 systemd[1]: Failed to start MongoDB Database Service.
答案 0 :(得分:0)
我遇到了同样的问题。
sudo systemctl start mongod
似乎在我的环境中无效。
尝试sudo service mongod start
它解决了我的问题。
使用sudo systemctl status mongod
给了我;
mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-01-24 13:01:38 UTC; 44min ago
Docs: https://docs.mongodb.org/manual
Main PID: 23900 (mongod)
Tasks: 25
Memory: 143.9M
CPU: 8.935s
CGroup: /system.slice/mongod.service
└─23900 /usr/bin/mongod --config /etc/mongod.conf