一、环境介绍
1.配置模式:一主两从
2.系统:rhel7.1
3.配置节点及IP: node-3 192.168.3.13
node-4 192.168.3.14
node-5 192.168.3.15
二、配置mongodb的yum源
[mongodb-org]
name=MongoDB Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mongodb/yum/el$releasever/
gpgcheck=0
enabled=1
三、安装mongodb
yum install -y mongodb-org-server mongodb-org
三、启动mongodb
1.mongodb启动
[root@node-3 yum.repos.d]
2.查看mongodb的状态
[root@node-3 yum.repos.d]
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2022-01-19 17:58:27 CST; 11s ago
Docs: https://docs.mongodb.org/manual
Process: 15741 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=0/SUCCESS)
Process: 15740 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 15734 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 15731 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 15750 (mongod)
CGroup: /system.slice/mongod.service
└─15750 /usr/bin/mongod -f /etc/mongod.conf
Jan 19 17:58:27 node-3 systemd[1]: Starting MongoDB Database Server...
Jan 19 17:58:27 node-3 mongod[15741]: about to fork child process, waiting until server is ready for connections.
Jan 19 17:58:27 node-3 mongod[15741]: forked process: 15750
Jan 19 17:58:27 node-3 systemd[1]: Started MongoDB Database Server.
3.查看监听端口
[root@node-3 ~]
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 15750/mongod
[root@node-3 ~]
四、进入mongodb
[root@node-3 ~]
MongoDB shell version v5.0.5
五、查看mongodb的所有数据库
> show dbs;
admin 0.000GB
config 0.000GB
local 0.000GB
> show databases;
admin 0.000GB
config 0.000GB
local 0.000GB
>