配置文件"/>
配置MongoDb配置文件
一、配置MongoDb配置文件
[root@lgy conf]# vim /opt/mongodb/conf/mongo.conf
systemLog: #系统日志destination: file #日志保存类型path: "/opt/mongodb/log/mongod.log" #日志保存路径logAppend: true #如果为 true,当 mongod/mongos 重启后,将在现有日志的尾部继续添加日志。否则,将会备份当前日志文件,然后创建一个新的日志文件;默认为 false。
storage: #存储dbPath: "/opt/mongodb/data/" #数据存储目录journal:enabled: true
processManagement:fork: true #后台运行
net:bindIp: 127.0.0.1,10.0.0.169 #绑定的ipport: 27017 #端口
启动命令:
[root@lgy opt]# mongod -f /opt/mongodb/conf/mongod.conf --fork
二、配置mongodb使用systemd管理
[root@lgy conf]# cat > /etc/systemd/system/mongod.service <<EOF
[Unit]
Description=mongodb
After=network.target remote-fs.target nss-lookup.target
[Service]
User=mongod
Type=forking
ExecStart=/opt/mongodb/bin/mongod --config /opt/mongodb/conf/mongo.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/opt/mongodb/bin/mongod --config /opt/mongodb/conf/mongo.conf --shutdown
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF[root@lgy opt]# systemctl daemon-reload
[root@lgy opt]# systemctl restart mongod
[root@lgy opt]# systemctl stop mongod
[root@lgy opt]# systemctl start mongod
更多推荐
配置MongoDb配置文件
发布评论