服务器运维MongoDB
2025-04-03 14:50阅读:82评论: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,理论其他环境一样,下载对应版本即可_PROTECTED0_ - 下载wget
- 解压tar -zxvf mongodb-linux-x86\__PROTECTED_4__64-rhel62-4.4.16 /usr/local/mongodb
- 环境配置export PATH=/usr/local/mongodb/bin:\$PATH
1
2
3
4
5
6
7
8
9
10
#加入以下内容dbpath=/usr/local/mongodb/data #事先创建该文件logpath=/usr/local/mongodb/logs/mongo.log #事先创建该文件logappend=truejournal=truequiet=trueport=27017fork=true #后台运行bind_ip=0.0.0.0 #允许任何IP进行连接 - mongo.log必须事先创建,否则会提示如下错误
1
2
3
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_PROTECTED0__
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
28
#!/bin/bash#chkconfig: 2345 80 90#description: mongodbstart() { /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 1esac _PROTECTED0__
1
2
3
4
5
vi /etc/init.d/mongodbchmod +x mongodb chkconfig --add mongodbchkconfig mongodb on