选择MongoDB版本
https://www.mongodb.com/try/download/community-kubernetes-operator
我的系统是centos7.9 这里只能最高只能选择mongo7
复制下载链接:https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-7.0.15.tgz
获取安装教程:
https://www.mongodb.com/zh-cn/docs/v7.0/tutorial/install-mongodb-on-red-hat-tarball/
选择你要安装mongo的版本和操作系统
依赖包安装;
sudo yum install libcurl openssl xz-libs
下载并配置
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-7.0.15.tgz
tar -zxvf mongodb-linux-x86_64-rhel70-7.0.15.tgz
mv mongodb-linux-x86_64-rhel70-7.0.15 /usr/local/mongodb7
sudo mkdir -p /usr/local/mongodb7/data
sudo mkdir -p /usr/local/mongodb7/log
sudo chown `whoami` /usr/local/mongodb7/data
sudo chown `whoami` /usr/local/mongodb7/log
添加环境变量:
vim /etc/profile
文件最后添加
export PATH=/usr/local/mongodb7/bin:$PATH
生效配置
source /etc/profile
启动
方式一
命令后面加参数:
mongod --dbpath /usr/local/mongodb7/data --logpath /usr/local/mongodb7/log/mongod.log --fork
方式二
启动参数写在配置文件中
cd /usr/local/mongodb7/bin
vim mongodb.conf
#数据文件存放目录
dbpath = /usr/local/mongodb7/data
#日志文件存放目录
logpath = /usr/local/mongodb7/log/mongod.log
#端口
port = 27017
#以守护程序的方式启用,即在后台运行
fork = true
mongod 启动
mongod --config /usr/local/mongodb7/bin/mongodb.conf
查看日志:/usr/local/mongodb7/log/mongod.log
"msg":"Waiting for connections","attr":{"port":27017,"ssl":"off"}}
安装mongosh
mongosh 安装教程:
https://www.mongodb.com/zh-cn/docs/mongodb-shell/install/
安装包下载 https://www.mongodb.com/try/download/compass
wget https://downloads.mongodb.com/compass/mongosh-2.3.3-linux-x64.tgz
tar -zxvf mongosh-2.3.3-linux-x64.tgz
cd mongosh-2.3.3-linux-x64/bin/
sudo cp mongosh /usr/local/bin/
sudo cp mongosh_crypt_v1.so /usr/local/lib/
mongosh 命令默认连接test数据库