为什么80%的码农都做不了架构师?>>>
一、mac安装mongodb brew update brew install mongodb 配置文件目录: /usr/local/etc/mongod.conf, 启动:brew services start mongodb 重新开启一个窗口: mongo 报错:
mongodb 数据默认存在/data/db, 需要创建一个、data/db目录 sudo mkdir -p /data/db sudo chown id -u
/data/db
然后启动终端 mongod 启动客户端 mongo ,启动成功
重启: brew services restart mongodb 停止:brew services stop mongodb
安装MongoDB客户端: https://robomongo.org/download 二、centos安装mongodb,在线安装 下载官网 官网安装说明 步骤:
1、# root权限进入目录cd /etc/yum.repos.d/,新建mongodb-org-3.6.repo文件 sudo -i cd /etc/yum.repos.d/
vi mongodb-org-3.6.repo
2、把内容拷贝到文件mongodb-org-3.6.repo [mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
3、安装 yum install -y mongodb-org 安装完成。 4 、验证是否安装成功 #rpm -qa |grep mongodb
# rpm -qa |grep mongodb
mongodb-org-tools-3.6.2-1.amzn1.x86_64
mongodb-org-server-3.6.2-1.amzn1.x86_64
mongodb-org-mongos-3.6.2-1.amzn1.x86_64
mongodb-org-3.6.2-1.amzn1.x86_64
mongodb-org-shell-3.6.2-1.amzn1.x86_64
# rpm -ql mongodb-org-server
/etc/init.d/mongod
/etc/mongod.conf
/etc/sysconfig/mongod
/usr/bin/mongod
/usr/share/doc/mongodb-org-server-3.6.2
/usr/share/doc/mongodb-org-server-3.6.2/GNU-AGPL-3.0
/usr/share/doc/mongodb-org-server-3.6.2/MPL-2
/usr/share/doc/mongodb-org-server-3.6.2/README
/usr/share/doc/mongodb-org-server-3.6.2/THIRD-PARTY-NOTICES
/usr/share/man/man1/mongod.1.gz
/var/lib/mongo
/var/log/mongodb
/var/log/mongodb/mongod.log
/var/run/mongodb
/var/lib/mongo 默认的放data文件 /var/log/mongodb 默认的日志文件 5、启动、停止、重启 启动: sudo service mongod start 停止: sudo service mongod stop 重启: sudo service mongod restart
启动
# sudo service mongod start
Starting mongod (via systemctl): [ OK ]
#
验证mongod进程已经成功启动
cat /var/log/mongodb/mongod.log
[initandlisten] waiting for connections on port 27017 # 最后一行显示
mongodb客户端: mongo --host 127.0.0.1:27017
卸载: sudo service mongod stop sudo yum erase $(rpm -qa | grep mongodb-org) sudo rm -r /var/log/mongodb sudo rm -r /var/lib/mongo
参照官网 https://docs.mongodb.com/manual/tutorial/install-mongodb-on-amazon/