当前位置:   article > 正文

MongoDB 4.2.24 内网部署[CentOS7]_mongodb4.2.24下载

mongodb4.2.24下载

mongo安装

# 下载MongoDB
https://www.mongodb.com/try/download/community

4.2.24
RedHat/CentOS7.0
tgz
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

在这里插入图片描述


# 安装MongoDB
mkdir -p /home/jpge/devp-tools/tools
cd /home/jpge/devp-tools/tools
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.24.tgz


tar -zxvf mongodb-linux-x86_64-rhel70-4.2.24.tgz -C /home/jpge/devp-tools
mv /home/jpge/devp-tools/mongodb-linux-x86_64-rhel70-4.2.24/ /home/jpge/devp-tools/mongodb-4.2.24

vim /etc/profile
export PATH=/home/jpge/devp-tools/mongodb-4.2.24/bin:$PATH

source /etc/profile

# 创建数据库目录
sudo mkdir -p /home/jpge/devp-tools/mongodb-4.2.24/data
sudo mkdir -p /home/jpge/devp-tools/mongodb-4.2.24/logs

# 编写启停脚本
cd /home/jpge/devp-tools/mongodb-4.2.24
vim start.sh
vim stop.sh


sh /home/jpge/devp-tools/mongodb-4.2.24/start.sh
# 验证安装是否成功
/home/jpge/devp-tools/mongodb-4.2.24/bin/mongo
> show dbs;
admin   0.000GB
config  0.000GB
local   0.000GB

  • 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
  • 29
  • 30
  • 31
  • 32

start.sh
#!/bin/sh
CUR_DIR="$( cd "$( dirname "$0"  )" && pwd  )"
echo "CUR_DIR=$CUR_DIR"
cd $CUR_DIR

APP_NAME=mongodb-4.2.24

mongod --dbpath=/home/jpge/devp-tools/mongodb-4.2.24/data --logpath=/home/jpge/devp-tools/mongodb-4.2.24/logs/mongodb.log --logappend --port=27017 --fork
echo "$CUR_DIR/$APP_NAME start up successful."
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

stop.sh
#!/bin/sh
CUR_DIR="$( cd "$( dirname "$0" )" && pwd )"
echo $CUR_DIR
cd $CUR_DIR

APP_NAME=mongodb-4.2.24
APP_PORT=27017;

PID=`netstat -nlp|grep :$APP_PORT|awk '{print $7}'|awk -F"/" '{ print $1 }'`
if [ ! -n "$PID" ];
then
 echo "$APP_NAME is not running!"

else
 echo "$APP_NAME $PID is running!"
 kill -9 $PID
  echo "$APP_NAME is killed!"
fi
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/910793
推荐阅读
相关标签
  

闽ICP备14008679号