Giter Site home page Giter Site logo

cangshu_devops's Introduction

cangshu_devops

记录仓鼠系统的部署相关,由于系统从简,不建议作为实践案例

1-原则:

  • 从简、节省成本
  • 开源(github,dockerhub)

2-分支策略、部署策略

master 主干开发,不同环境均部署master分支的代码镜像

前端打镜像,以 auth-ui 为例
# 下载代码↓
git clone https://github.com/zhaojing/openlmis-auth-ui
cd openlmis-auth-ui
# 准备环境
touch .env
docker-compose run --service-ports auth-ui
# 在上面步骤启动的容器中执行↓
npm install
grunt build --noTest --noDocs --noStyleguide
# 退出容器后,在工程目录执行↓
docker-compose build image
# re-tag 镜像名称,然后push到dockerhub(没有push权限,找qinrui)
docker tag openlmis/auth-ui:latest cangshuorg/auth-ui:latest
docker push cangshuorg/auth-ui:latest
服务器上更新 reference-ui 具体步骤如下
#step1 先登录服务器
ssh xxx 
#step2 进入目录,以dev环境为例
cd /data/openlmis-ref-distro
#step3 修改 .env 文件中的 reference-ui 版本号

#step4 重启reference-ui
docker-compose up --no-deps --force-recreate -d reference-ui

3-源代码、镜像仓库

  • 源代码

存放于zhaojing的github仓库中(如有权限不够,需要找zhaojing)
https://github.com/zhaojing?tab=repositories

  • 镜像仓库

使用dockerhub (qinrui的dockerhub账号管理,新建了Organizationscangshuorg,如果repo不存在或没有push权限,找qinrui

推送镜像具体步骤见:Google drive

例子: docker push cangshuorg/stockmanagement:tagname

4-服务器、域名等

对比aws、aliyun,考虑aliyun性价比较高,当前目标针对**的业务,所以选择用aliyun

环境 配置 公网IP 状态
dev(开发环境) 8G 2c 47.110.15.xx 已有
prod(生产环境) 16G 4c 暂无 暂无

ssh [email protected] -i ~/<YOUR_PATH>/cangshu-xxx.pem

5-数据库

已在ECS 安全组规则中放开5432端口,对于连接数据库信息,请参考有关服务器信息和配置文件

1-连接
  • 命令行: psql -h 116.62.192.197 -p 5432 -U postgres

  • 图形化界面 - 略

2-数据库备份

pg_dump -h 116.62.192.197 -p 5432 -U postgres -d open_lmis | gzip > /<YOUR_APTH>/backup/date +%Y%m%d%H_dev_pg.gz

脚本见 scripts/backup_db.sh

3-数据库恢复
    1. 先 drop table

找dev同学

    1. 利用备份文件恢复

gunzip -c db-20191023.gz | psql -h localhost -d open_lmis -U postgres

#直接解压,不保留原gz文件
gunzip xxx.gz
#解压保留源gz文件
gunzip -c xxx.gz > xxx.sql
#进去pgsql控制台
psql -U dbUser
#切换到待导入的数据库
\c dbName;
#导入sql文件
\i xxx.sql
#退出控制台
\q

注意点:

  • 1.由于服务器可能重建,公网IP可能会变动
  • 2.数据库需要备份

cangshu_devops's People

Contributors

qinrui-tw avatar qinrui777 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.