安裝mongo
下載mongoDB RPM
https://repo.mongodb.org/yum/redhat/
https://repo.mongodb.org/yum/redhat/8/mongodb-org/4.2/x86_64/RPMS/
- 下載4.2.8 版,共5個檔案
- mongodb-org-4.2.8-1.el8.x86_64.rpm
- mongodb-org-mongos-4.2.8-1.el8.x86_64.rpm
- mongodb-org-server-4.2.8-1.el8.x86_64.rpm
- mongodb-org-shell-4.2.8-1.el8.x86_64.rpm
- mongodb-org-tools-4.2.8-1.el8.x86_64.rpm
需先安裝python
sudo dnf install python
安裝mongodb rpm
sudo rpm -ivh mongodb-org-server-4.2.8-1.el8.x86_64.rpm mongodb-org-mongos-4.2.8-1.el8.x86_64.rpm mongodb-org-shell-4.2.8-1.el8.x86_64.rpm mongodb-org-tools-4.2.8-1.el8.x86_64.rpm mongodb-org-4.2.8-1.el8.x86_64.rpm
SELinux is preventing /usr/bin/mongod from read access on the file memory.limit_in_bytes 解決方式
- 參考https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
- sudo yum install checkpolicy
- Create a custom policy file
mongodb_cgroup_memory.te
:
cat > mongodb_cgroup_memory.te <<EOF
module mongodb_cgroup_memory 1.0;
require {
type cgroup_t;
type mongod_t;
class dir search;
class file { getattr open read };
}
#============= mongod_t ==============
allow mongod_t cgroup_t:dir search;
allow mongod_t cgroup_t:file { getattr open read };
EOF
- Once created, compile and load the custom policy module by running these three commands:
checkmodule -M -m -o mongodb_cgroup_memory.mod mongodb_cgroup_memory.te
semodule_package -o mongodb_cgroup_memory.pp -m mongodb_cgroup_memory.mod
sudo semodule -i mongodb_cgroup_memory.pp
- sudo systemctl retart mongod
Failed to unlink socket file /tmp/mongodb-27017.sock errno:1 Operation not permitted解決方式
rm /tmp/mongodb-27017.sock
sudo systemctl retart mongod