赞
踩
# 下载MongoDB
https://www.mongodb.com/try/download/community
4.2.24
RedHat/CentOS7.0
tgz
# 安装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
#!/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."
#!/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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。