- 10、配置系统服务启动mongod
[root@moyang /]# vim /lib/systemd/system/mongod.service// 添加内容如下--------------------------------------------------------[Unit]Description=mongodbAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingExecStart=/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/mongodb.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/usr/local/mongodb/bin/mongod --shutdown -f /usr/local/mongodb/mongodb.confPrivateTmp=true[Install]WantedBy=multi-user.target--------------------------------------------------------[root@moyang /]# chmod 754 /lib/systemd/system/mongod.service[root@moyang /]# systemctl status mongod.service// 查看启动状态[root@moyang /]# systemctl start mongod.service// 启动服务[root@moyang /]# systemctl restart mongod.service// 重启服务[root@moyang /]# systemctl stop mongod.service// 停止服务 00f">小知识:开机启动服务相关命令
centos7自启项已不用chkconfig
- https://www.cnblogs.com/zwcry/p/9602756.html
- 查看开机自启项 左边是服务名称,右边是状态,enabled是开机启动,disabled是开机不启动
[root@moyang /]# systemctl list-unit-files - 过滤查看开机启动项
[root@moyang /]# systemctl list-unit-files | grep enabled[root@moyang /]# systemctl list-unit-files | grep mongod - 启用 | 禁用 开机启动
[root@moyang /]# systemctl enable mongod// 启用[root@moyang /]# systemctl disable mongod// 禁用 三、安装git
[root@moyang /]# yum -y install git 开始部署Yapi注意事项
云服务器请先确认安全组是否开放 3000 9090端口http://tool.chinaz.com/port/
服务器的防火墙和iptables是否开放 3000 9090端口或者可以直接关闭这两个服务
- 开始搭建YApi,安装命令
[root@moyang /] npm install -g yapi-cli --registry https://registry.npm.taobao.org - 启动服务
[root@moyang /] yapi server在浏览器打开 http://0.0.0.0:9090 访问 。非本地服务器,请将 0.0.0.0 替换成指定的域名或ip - 在线部署
- 在浏览器访问 :9090 服务器公网ip>
- 根据提示配置,如果mongodb数据库开启了权限认证,需要开启下图的数据库认证,并且输入数据库账号,密码
- 部署完成启动Yapi服务,这种模式shell终端不能关闭
[root@moyang /] node <yapi部署路径>/vendors/server/app.js yapi服务管理
利用pm2方便服务管理维护 。
// 更换npm淘宝镜像源[root@moyang /] npm config set registry https://registry.npm.taobao.org// 安装pm2[root@moyang /] npm install pm2 -g// pm2管理yapi服务[root@moyang /] cd{yapi部署路径}[root@moyang yapi] pm2 start "vendors/server/app.js" --name yapi //启动服务[PM2] Starting /data/wwwroot/yapi/vendors/server/app.js in fork_mode (1 instance)[PM2] Done.┌─────┬─────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐│ id│ name│ namespace│ version │ mode│ pid│ uptime │ ?│ status│ cpu│ mem│ user│ watching │├─────┼─────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤│ 0│ yapi│ default│ 1.8.7│ fork│ 13231│ 0s│ 0│ online│ 0%│ 13.1mb│ root│ disabled │└─────┴─────────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴─────────[root@moyang /] pm2 info yapi//查看服务信息[root@moyang /] pm2 stop yapi//停止服务[root@moyang /] pm2 restart yapi//重启服务 00f">小知识:mongodb开启权限验证
https://www.jianshu.com/p/62736bff7e2e
也可以使用windows终端https://robomongo.org/
推荐阅读
- 服务器的1U、2U是什么意思?42U机柜可以放多少台服务器?
- ssh免密登录在Linux服务器之间的设置
- Nginx服务器的六种负载均衡策略详解
- 一文教您如何实现持续集成服务器环境搭建
- Docker配置阿里云镜像服务
- 大连家电维修服务哪家好
- 福建武夷山市金融机构产品创新服务茶业发展
- 福建,优质供电服务保驾福鼎白茶复兴与富民之行
- 如何提高Web服务器安全性
- 我仅用10步,就写出了全网最全的微服务架构详解
