Mongodb的安装部署
Posted jks212454
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mongodb的安装部署相关的知识,希望对你有一定的参考价值。
Mongodb的安装部署
一、环境介绍
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源
# /etc/yum.repos.d/mongodb.repo
[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]# systemctl start mongod.service
2.查看mongodb的状态
[root@node-3 yum.repos.d]# systemctl status mongod
● 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 ~]# netstat -tunlp |grep 27017
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 15750/mongod
[root@node-3 ~]#
四、进入mongodb
[root@node-3 ~]# mongo
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
>
以上是关于Mongodb的安装部署的主要内容,如果未能解决你的问题,请参考以下文章