【MongoDB】安装和配置
安装
tar -zxvf mongodb-linux-x86_64-rhel70-4.4.3.tgz
mv mongodb-linux-x86_64-rhel70-4.4.3 /usr/local/mongodb
配置
cd /usr/local/mongodb/
mkdir -p ./data/db
mkdir -p ./logs
vim mongodb.conf
systemLog:
# MongoDB发送所有日志输出的目标指定为文件
destination: file
path: "/usr/local/mongodb/logs/mongodb.log"
logAppend: true
storage:
# mongod实例存储其数据的目录
dbPath: "/usr/local/mongodb/data/db"
journal:
# 启用或禁用持久性日志以确保数据文件保持有效和可恢复。
enabled: true
processManagement:
# 启用在后台运行mongos或mongod进程的守护进程模式。
fork: true
net:
# 服务实例绑定的IP,默认是localhost,允许远程IP连接
bindIp: 0.0.0.0
port: 27017
./bin/mongod --config mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 20032
child process started successfully, parent exiting
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 /usr/local/mongodb/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/usr/local/mongodb/bin/mongod --shutdown --config /usr/local/mongodb/mongodb.conf
PrivateTmp=true
[Install]
WantedBy=multi-user.target
systemctl start mongodb
systemctl daemon-reload
systemctl enable mongodb
vim /etc/profile
export MONGODB_HOME=/usr/local/mongodb
export PATH=$MONGODB_HOME/bin:$PATH
source /etc/profile
评论区