gpt4 book ai didi

linux - MongoDB 不能作为独立的 EC2 AWS 实例 CENTOS 7

转载 作者:太空宇宙 更新时间:2023-11-04 12:11:29 24 4
gpt4 key购买 nike

我一直在尝试在一个 EC2 实例上设置 Mongodb,并希望将其用作我在另一个 EC2 实例上当前运行的 api 的数据库。我正在使用 Centos 7。

我试图遵循这些 instructions在 mongodb 网站上了解如何做到这一点,但它们似乎已经过时了。一个明显的问题是 /dev/xvdf/dev/xvdg/dev/xvdh 或 sd* 等价物 不存在。相反,我将日志/数据/日志挂载到 /dev/xvda1

当我运行 sudo service mongod start 时,输出如下:

● mongod.service - High-performance, schema-free document-oriented database
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2018-02-12 16:47:57 UTC; 14s ago
Docs: https://docs.mongodb.org/manual
Process: 8348 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=100)
Process: 8345 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8343 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 8342 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)

Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal systemd[1]: Starting High-performance, schema-free document-oriented database...
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal mongod[8348]: about to fork child process, waiting until server is ready for connections.
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal mongod[8348]: forked process: 8351
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal mongod[8348]: ERROR: child process failed, exited with error number 100
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal mongod[8348]: To see additional information in this output, start without the "--fork" option.
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=100
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal systemd[1]: Failed to start High-performance, schema-free document-oriented database.
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal systemd[1]: Unit mongod.service entered failed state.
Feb 12 16:47:57 ip-111-11-4-246.us-east-2.compute.internal systemd[1]: mongod.service failed.

基于此article我已经运行了 mongod --storageEngine wiredTiger --dbpath/data 它将打开 mongo 但将以 waiting for connections on port 27017 结束,然后可以在另一个 mongo 实例上打开但是这是不可维护的我的服务器也无法访问。

这是我对该应用程序的完整历史记录。注意(这是一个新的 ec2 实例,以便尝试重新启动进程。)

    1  lsls
2 ls
3 cd ../..
4 ls
5 cd etc
6 ls
7 cd yum.repos.d/
8 ls
9 touch mongodb-org-3.6.repo
10 sudo touch mongodb-org-3.6.repo
11 sudo vi mongodb-org-3.6.repo
12 sudo yum -y update && sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools
13 ls
14 cd ../../..
15 ls
16 sudo mkdir /data /log /journal
17 sudo mkfs.xfs /dev/xvda1
18 echo '/dev/xvdf /data xfs defaults,auto,noatime,noexec 0 0
/dev/xvdg /journal xfs defaults,auto,noatime,noexec 0 0
/dev/xvdh /log xfs defaults,auto,noatime,noexec 0 0' | sudo tee -a /etc/fstab
19 sudo mount /data
20 sudo mount /dev/xvda1 /data
21 sudo mount /dev/xvda1 /log
22 sudo mount /dev/xvda1 /journal
23 sudo mount /dev/xvda1 /data
24 sudo chown mongod:mongod /data /journal /log
25 sudo ln -s /journal /data/journal
26 sudo vi etc/mongod.conf
27 cd ../..
28 ls
29 echo '* soft nofile 64000
* hard nofile 64000
* soft nproc 64000
* hard nproc 64000' | sudo tee /etc/security/limits.d/90-mongodb.conf
30 echo 'ACTION=="add|change", KERNEL=="xvda1", ATTR{bdi/read_ahead_kb}="0"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
31 sudo service mongod start --storageEngine wiredTiger
32 sudo service mongod start
33 journalctl -xe
34 systemctl status mongod.service
35 mongo
36 mongod --storageEngine wiredTiger --dbpath /data --fork --logpath
37 mongod --storageEngine wiredTiger --dbpath /data --fork --logpath /log
38 cd log
39 ls
40 cd log
41 ls
42 cd ..
43 cd log
44 sudo touch mongo.log
45 cd ..
46 mongod --storageEngine wiredTiger --dbpath /data --fork --logpath /log
47 mongod --storageEngine wiredTiger --dbpath /data --fork --logpath /log/mongo.log
48 --fork mongod --storageEngine wiredTiger --dbpath /data --logpath /log/mongo.log
49 sudo service mongod start
50 systemctl status mongod.service
51 systemctl status mongod.service --fork
52 sudo setenforce 0
53 systemctl status mongod.service --fork
54 sudo service mongod start
55 ls -Z
56 sudo chcon -Rv --type=mongod_log_t $logpath
57 sudo blockdev --setra 0 /dev/xvda1
58 echo 'ACTION=="add|change", KERNEL=="xvda1", ATTR{bdi/read_ahead_kb}="0"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules
59 /dev/mapper/my_vol /var/lib/mongodb xfs noatime,noexec 0 0
60 sudo chown mongod:mongod /data /journal /log
61 sudo chmod 777 /data /journal /log
62 sudo chmod 777 /data /journal /logsudo ln -s /journal /data/journal
63 ls
64 sudo ln -s /journal /data/journal
65 sudo chmod 400 /data /journal /logsudo ln -s /journal /data/journal
66 sudo service mongod start
67 systemctl status mongod.service
68 sudo systemctl start mongod.service
69 systemctl status mongod.service
70 sudo -u mongod /usr/bin/mongod -f /etc/mongod1.conf
71 sudo vi etc/mongod.conf
72 history

最佳答案

我让它工作了。

sudo mongod --storageEngine wiredTiger --dbpath/data --bind_ip_all 运行应用程序。

sudo chkconfig mongod on 这让它在后台永久运行。

老实说,最终版本与上面的版本略有不同,但不幸的是,我无法完全弄清楚还有哪些其他更改使其起作用。

关于linux - MongoDB 不能作为独立的 EC2 AWS 实例 CENTOS 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48752062/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com