单机版mongodb
1.下载安装包
wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-1.8.2.tgz
下载完成后解压缩压缩包
tar zxf mongodb-linux-i686-1.8.2.tgz
2. 安装准备
将mongodb移动到/usr/local/server/mongdb文件夹
mv mongodb-linux-i686-1.8.2 /usr/local/mongodb
创建数据库文件夹与日志文件
mkdir /usr/local/mongodb/data
touch /usr/local/mongodb/logs
3. 设置开机自启动
将mongodb启动项目追加入rc.local保证mongodb在服务器开机时启动
echo "/usr/local/server/mongodb/bin/mongod --dbpath=/usr/local/server/mongodb/data –logpath=/usr/local/server/mongodb/logs –logappend --auth –port=27017" >> /etc/rc.local
4.添加start.sh脚本
#!/bin/bash
/usr/local/mongodb/bin/mongod --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/logs --logappend --port=27017 --fork
echo 'mongodb started!'
5.添加stop.sh脚本
#!/bin/bash
/usr/local/mongodb/bin/mongod --shutdown --dbpath /usr/local/mongodb/data/
echo 'mongodb stoped'
6.给脚本授执行权限
chmod +x *.sh
7.开启mongodb Cli
cd /usr/local/mongodb/bin
./mongo