You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
cd /usr/local
rz -be 选择: mongodb-linux-x86_64-rhel80-4.2.24.tgz
tar zxvf mongodb-linux-x86_64-rhel80-4.2.24.tgz -C /usr/local/
mv mongodb-linux-x86_64-rhel80-4.2.24 mongodb
rm -rf mongodb-linux-x86_64-rhel80-4.2.24.tgz
#添加环境变量
vi /etc/profile
export PATH=/usr/local/mongodb/bin:$PATH
#生效
source /etc/profile
# 创建文件
cd /usr/local/mongodb
touch mongodb.conf
mkdir db
mkdir log
cd log
touch mongodb.log
# 修改配置文件
vi /usr/local/mongodb/mongodb.conf
port=27017 #端口 默认端口是27017, 但是mongodb特别容易被攻击, 所以这里不建议使用默认端口
dbpath= /usr/local/mongodb/db #数据库存文件存放目录,如果有数据盘最好放在数据盘里面
logpath= /usr/local/mongodb/log/mongodb.log #日志文件存放路径
logappend=true #使用追加的方式写日志
fork=true #以守护进程的方式运行,创建服务器进程
maxConns=100 #最大同时连接数
auth=false #不启用验证,先不开启,配完用户在更改开启
journal=true #每次写入会记录一条操作日志( 通过journal可以重新构造出写入的数据) 。
#即使宕机, 启动时wiredtiger会先将数据恢复到最近一次的checkpoint点, 然后重放后续的journal日志来恢复。
storageEngine=wiredTiger #存储引擎有mmapv1、wiretiger、mongorocks
bind_ip = 0.0.0.0 #0.0.0.0代表任何IP地址, 如果写127.0.0.1那就只能本机访问,其他同理
#设置文件夹权限
cd /usr/local/mongodb
chmod 777 db
chmod 777 log
# 启动MongoDB
mongod -f /usr/local/mongodb/mongodb.conf
yum install net-tools -y
netstat -lanp | grep "27017"
mongo #进入MongoDB控制台
show dbs #查看默认数据库
use admin #切换到admin数据库
exit #退出MongoDB控制台
# 关闭数据库
/usr/local/mongodb/bin/mongod --shutdown --dbpath /usr/local/mongodb/db
# 常用维护命令
https://blog.csdn.net/Waldocsdn/article/details/130155631