社区版本下载地址: https://www.mongodb.com/try/download/community-kubernetes-operator
我选择的是:
Version: 7.0.3
Platform: RedHat/CentOS 7.0 x64
Package: tgz
将安装包mongodb-linux-x86_64-rhel70-7.0.3.gz上传到/usr/local 目录中
cd /usr/local
tar -zxvf mongodb-linux-x86_64-rhel70-7.0.3.gz
cd /usr/local
mkdir mongodb
cd /usr/local/mongodb
mkdir data
mkdir logs
touch /usr/local/mongodb/logs/mongodb.log
将解压后的mongodb-linux-x86_64-rhel70-7.0.3 中的所有文件全部移动到 /usr/local/mongodb 中
mv mongodb-linux-x86_64-rhel70-7.0.3/* /usr/local/mongodb
vim /etc/profile
在文件中增加以下配置:
export MONGODB_HOME=/usr/local/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
vim /etc/mongodb.conf
#指定数据库路径
dbpath=/usr/local/mongodb/data
#指定MongoDB日志文件
logpath=/usr/local/mongodb/logs/mongodb.log
# 使用追加的方式写日志
logappend=true
#端口号
port=27017
#方便外网访问,外网所有ip都可以访问,不要写成固定的linux的ip
bind_ip=0.0.0.0
fork=true # 以守护进程的方式运行MongoDB,创建服务器进程
#auth=true #启用用户验证
#bind_ip=0.0.0.0 #绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定则默认本地所有IP
vim /lib/systemd/system/mongodb.service
粘贴以下内容
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/mongod --config /etc/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /etc/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start mongodb.service
systemctl enable mongodb.service
systemctl stop mongodb.service
systemctl status mongodb.service
cd /usr/local/mongodb/bin
mongod -f /etc/mongodb.conf
mongod --shutdown -f /etc/mongodb.conf
ps -ef | grep mongod