程序员の奇妙冒险

返回
服务器运维 MongoDB
2025-04-03 14:50 阅读:112 评论:0

Linux tar.gz安装mongodb

安装环境CentOS 6,理论其他环境一样,下载对应版本即可 安装 下载wget <https://fastdl.mongodb.org/linux/mongodb-linux-x8664-rhel62-4.4.16.tgz> 解压tar -zxvf mongodb-linux-x86\64-rhe

安装环境CentOS 6,理论其他环境一样,下载对应版本即可

安装

mongo.conf配置

1
2
3
4
5
6
7
8
9
#加入以下内容
dbpath=/usr/local/mongodb/data #事先创建该文件
logpath=/usr/local/mongodb/logs/mongo.log #事先创建该文件
logappend=true
journal=true
quiet=true
port=27017
fork=true #后台运行
bind_ip=0.0.0.0 #允许任何IP进行连接
  • mongo.log必须事先创建,否则会提示如下错误
1
2
ERROR: child process failed, exited with 1
To see additional information in this output, start without the "--fork" option.
  • 启动mongodb命令如下

/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongo.conf

配置启动脚步

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
#chkconfig: 2345 80 90
#description: mongodb
start() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongo.conf
}
stop() {
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongo.conf --shutdown
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
netstat -tulnp|grep mongod
;;
restart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

设置启动

1
2
3
4
vi /etc/init.d/mongodb
chmod +x mongodb
chkconfig --add mongodb
chkconfig mongodb on
评论 (0)
暂无评论 来抢沙发吧~