标签:mongodb 自动安装
vim mongodb_install.sh
#!/bin/bash cd /opt/ echo "Download mongdb software..." wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.0.4.tgz echo " mongdb software..." tar -zxf mongodb-linux*.tgz mkdir software mv mongodb-linux-*.tgz software mv mongodb-linux* mongodb cd mongodb/ echo "create log,data,conf dir and create mongodb.log , mongod.conf" mkdir log data conf cd log/ touch mongodb.log cd .. cd conf echo "port = 12345 dbpath = data logpath = log/mongod.log fork = true #在linux中fork为启动后台命令" >> mongod.conf cd .. echo "create mongod.conf and transfer to /usr/bin" echo "#!/bin/bash cd /opt/mongodb/ ./bin/mongod -f conf/mongod.conf cd - " >> mongod.sh mv mongod.sh /usr/bin/ chmod a+x /usr/bin/mongod.sh echo "Modify /etc/bash.bashrc" echo "alias mongod=‘/usr/bin/mongod.sh‘" >> /etc/bash.bashrc source /etc/bash.bashrc cd -
chmod a+x mongodb_install.sh
已root用户运行此脚步 ./mongodb_install.sh
脚本运行完毕,输入mongod就能启动mongo服务。
启动客户端
cd /opt/mongodb
root@adela-vm:/opt/mongodb# ./bin/mongo 127.0.0.1:12345/test
在浏览器中访问http://192.168.56.163:12345/
手动安装请参照:http://adelazhu.blog.51cto.com/9455045/1625360
本文出自 “Adela” 博客,谢绝转载!
Ubuntu 14.04 下自动安装mongodb shell 脚本
标签:mongodb 自动安装
原文地址:http://adelazhu.blog.51cto.com/9455045/1672138