—— 阿尔伯特·爱因斯坦

程序员の奇妙冒险

服务器运维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 64-rhel62-4.4.16.tgz>
  • 解压tar -zxvf mongodb-linux-x86\__PROTECTED_4__64-rhel62-4.4.16 /usr/local/mongodb
  • 环境配置export PATH=/usr/local/mongodb/bin:\$PATH
_PROTECTED1__
1
2
3
4
5
6
7
8
9
10
#加入以下内容
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
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: 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
 
_PROTECTED0__
1
2
3
4
5
vi /etc/init.d/mongodb
chmod +x mongodb
chkconfig --add mongodb
chkconfig mongodb on
 
评论(0)
暂无评论来抢沙发吧~