- MongoDB 下载链接:
- centos7 镜像下载链接:
- 也可以在服务器上面:wget
1.创建基础目录(已经有的话 , 请跳过)
# 用来存储我们下载好的一些文件或者软件mkdir -p /home/service# 用来存储配置文件mkdir -p /home/config# 用来存储日志mkdir -p /home/logs# sh脚本mkdir -p /home/sh安装wget:yum install wget2. 下载解压mongo(复制全部 , 粘贴运行就好了)
# 没有wget 的话 , yum install wgetcd /home/servicewget tar -xzvf mongodb-linux-x86_64-rhel70-4.4.0.tgz -C /home/service/mv /home/service/mongodb-linux-x86_64-rhel70-4.4.0 /home/service/mongodb3. 编写mongo配置(复制全部 , 粘贴运行就好了)
mkdir -p /home/service/mongodb/myconfigln -s /home/service/mongodb/myconfig /home/config/mongodbcat <<'EOF'> /home/service/mongodb/myconfig/mongodb.confdbpath = /home/service/mongodb/data/dblogpath = /home/service/mongodb/data/logs/mongodb.logport = 27017# 测试下可以0.0.0.0,正式环境:127.0.0.1bind_ip=0.0.0.0fork = true#nohttpinterface = trueauth=trueEOF# 软链ln -s /home/service/mongodb/data/logs /home/logs/mongodb4. 设置mongo自启文件(复制全部 , 粘贴运行就好了)
mkdir -p /home/service/mongodb/data/dbmkdir -p /home/service/mongodb/data/logscat <<'EOF'> /home/service/mongodb/myconfig/mongodb.service[Unit]Description=mongodbAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingExecStart=/home/service/mongodb/bin/mongod --config /home/service/mongodb/myconfig/mongodb.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/home/service/mongodb/bin/mongod --shutdown --config /home/service/mongodb/myconfig/mongodb.confPrivateTmp=true[Install]WantedBy=multi-user.targetEOFcp /home/service/mongodb/myconfig/mongodb.service /lib/systemd/system/mongodb.servicesystemctl enable mongodb.servicesystemctl start mongodb.serviceservice mongodb status5. 配置系统环境(复制全部 , 粘贴运行就好了)
cat <<'EOF'>> /etc/profileexport MONGODB_HOME=/home/service/mongodbexport PATH=$PATH:$MONGODB_HOME/binEOFsource /etc/profile6.创建MongoDB管理员
【centos7 安装 MongoDB (复制粘贴系列)】mongouse admin#创建mongo管理员 , 并且赋予权限db.createUser({ user: 'admin', pwd: 'mongoAdmin', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });#退出登录exit7. 防火墙开启27017端口(复制全部 , 粘贴运行就好了)
yum -y install firewalldsystemctl start firewalld.servicechkconfig --level 35 firewalld onfirewall-cmd --zone=public --add-port=27017/tcp --permanentfirewall-cmd --reloadfirewall-cmd --list-ports8. 测试访问

文章插图
推荐阅读
-
『新浪科技综合』苹果成功押注在线办公设备 这些A股公司有相关业务
-
请叫我绅士|解读幸福婚姻的3个真相,开启幸福,从梁朝伟和刘嘉玲的美满婚姻
-
坠湖公交受伤15人一对一专班救治|坠湖公交受伤15人一对一专班救治,全力救治患者
-
-
阳泉女子要二胎怀不上,医生说是个问题,女子:我没做过人liu
-
-
历史来揭秘@从此掀起了一股以胖为美的浪潮,此皇帝封自己的宠妃为“猪”
-
焦糖老干妈|周冬雨许凯却像偷穿大人衣服的小孩,《千古玦尘》殊效很惊艳
-
-
易快讯TB■Pro后摄信息曝光,拍照表现或更为强悍,荣耀30
-
甘肃高速▲请注意!,【计划施工】4月12日G30连霍高速永古段进行养护施工
-
第一财经|全年社保总减费预计达1.9万亿,近2亿低收入者受益
-
爱集微APP日经:华为供应受限,索尼和三星围绕图像传感器的拉锯战即将升温
-
九门吏部尚殳@在北京是看花的好时候!,这个五一小长假
-
-
嘻哈飞车族|小白轻松入手,最低仅需849元,2020上半年最值得购买的四款机型
-
生活报|印度一新冠患者收治点发生火灾,至少7人死亡
-
「ZAKER」结局出人意料,和平精英:主播挑战机瞄98K加喷子吃鸡
-
iphone8换home键怎么保留指纹?苹果8换home键指纹还有没有_1
-