mongo安装

# 下载MongoDB

https://www.mongodb.com/try/download/community


4.2.24

RedHat/CentOS7.0

tgz

直接下载

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.24.tgz

上传到服务器路径:/home/software/mongodb/

解压:tar -zxvf mongodb-linux-x86_64-rhel70-4.2.24.tgz

vim /etc/profile

export PATH=/home/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24/bin:$PATH

source /etc/profile

# 创建数据库目录 

sudo mkdir -p /home/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24/data

sudo mkdir -p /home/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24/logs

# 编写启停脚本 

cd /home/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24

vim start.sh

vim stop.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/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24/data --logpath=/home/software/mongodb/mongodb-linux-x86_64-rhel70-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


启动查看进程


进入:/home/software/mongodb/mongodb-linux-x86_64-rhel70-4.2.24/bin/

验证:./mongo



// 连接到MongoDB数据库


mongo


// 切换到admin数据库


use admin


// 创建用户


db.createUser({


  user: "admin",


  pwd: "admin123",


  roles: [


    { role: "userAdminAnyDatabase", db: "admin" },


    { role: "dbAdminAnyDatabase", db: "admin" },


    { role: "readWriteAnyDatabase", db: "admin" }


  ]


})


Node安装

下载:wget https://npm.taobao.org/mirrors/node/v12.19.0/node-v12.19.0-linux-x64.tar.gz

创建目录:/home/software/node/

解压:[root@localhost node]# tar -zxvf node-v12.19.0-linux-x64.tar.gz


vim /etc/profile

export NODE_HOME=/home/software/node/node-v12.19.0-linux-x64

export PATH=$NODE_HOME/bin:$PATH

source /etc/profile

查看版本:


[root@localhost bin]# ./node -v

v12.19.0

npm install -g cnpm --registry=https://registry.npm.taobao.org





yapi安装

npm install -g yapi-cli --registry https://registry.npm.taobao.org

yapi server

如果端口被占用:修改文件:.../lib/node_modules/yapi-cli/src/commands/server.js

我修改了9000

访问地址:http://10.201.9.10:9000/

1.8.8版本




cd /home/software/my-yapi

vim start.sh

vim stop.sh




sh /home/software/my-yapi/start.sh

tail -200f log/start-init.log

192.168.164.128:3000

默认密码: ymfe.org


sh /home/software/my-yapi/stop.sh



start.sh

#!/bin/sh

CUR_DIR="$( cd "$( dirname "$0"  )" && pwd  )"

echo "CUR_DIR=$CUR_DIR"

cd $CUR_DIR


APP_NAME=my-yapi


nohup node vendors/server/app.js >> ./log/start-init.log 2>&1 &

echo "$CUR_DIR/$APP_NAME start up successful."


stop.sh

#!/bin/sh

CUR_DIR="$( cd "$( dirname "$0" )" && pwd )"

echo $CUR_DIR

cd $CUR_DIR


APP_NAME=my-yapi

APP_PORT=9000;


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