zoukankan      html  css  js  c++  java
  • 【部署说明】showdoc文档管理平台

    一、前言

    1、需求来由

    • 内部资料归档混乱,内部归档地址不一,不利于资料查找及工作交接
    • 更新不及时,本地文档更新完,未同步上传到ftp服务器
    • 归档文档多为word或pdf格式,不易于编辑维护
    • 搭配wss任务管理系统使用,每一任务原则上都要求有输出件,以便于对任务做质量管控及绩效考核打分

    综合以上实际存在的痛点,故决定统一部门内部文档管理,搭建文档管理平台,用于管理开发、测试各项任务输出归档。

    2、showdoc说明

    官方说明文档

    showdoc是国内一款开源的文档管理系统,可用于编写API文档、数据字典、说明文档。

    • 采用markdown编辑器,编辑及查阅体验较佳
    • 支持版本历史功能,便于文档回滚恢复
    • 支持回收站功能,删除超过30天以上的文件自动被删除
    • 可按照大项分类,创建目录树状结构,支持全项目文档搜索
    • 支持项目成员权限管控

    二、部署安装

    1、docker安装

    1.1、下载docker离线包,解压缩拷贝到/usr/bin目录下

    wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz --no-proxy
    tar -zxvf docker-19.03.9.tgz
    cp docker/* /usr/bin/
    

    1.2、注册编辑docker服务,添加以下配置信息到/etc/systemd/system/docker.service配置文件内

    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network-online.target firewalld.service
    Wants=network-online.target
    
    [Service]
    Type=notify
    # the default is not to use systemd for cgroups because the delegate issues still
    # exists and systemd currently does not support the cgroup feature set required
    # for containers run by docker
    ExecStart=/usr/bin/dockerd
    ExecReload=/bin/kill -s HUP $MAINPID
    # Having non-zero Limit*s causes performance problems due to accounting overhead
    # in the kernel. We recommend using cgroups to do container-local accounting.
    LimitNOFILE=infinity
    LimitNPROC=infinity
    LimitCORE=infinity
    # Uncomment TasksMax if your systemd version supports it.
    # Only systemd 226 and above support this version.
    #TasksMax=infinity
    TimeoutStartSec=0
    # set delegate yes so that systemd does not reset the cgroups of docker containers
    Delegate=yes
    # kill only the docker process, not all processes in the cgroup
    KillMode=process
    # restart the docker process if it exits prematurely
    Restart=on-failure
    StartLimitBurst=3
    StartLimitInterval=60s
      
    [Install]
    WantedBy=multi-user.target
    

    1.3、赋予/etc/systemd/system/docker.service配置文件执行权限,重新加载配置文件

    chmod +x /etc/systemd/system/docker.service
    systemctl daemon-reload
    

    1.4、启动docker服务,设置开机自启动

    systemctl start docker
    systemctl enable docker
    

    2、showdoc安装

    2.1、关闭selinux

    注:启动容器需要写/proc/self/attr/keycreate配置,启用selinux会导致没有写入权限写入失败,导致启用容器出现write /proc/self/attr/keycreate: permission denied错误

    • 临时关闭selinux
    setenforce 0
    
    • 永久关闭selinux
      修改/etc/selinux/config配置文件,修改配置为SELINUX=disabled

    2.2、拉取showdoc官方镜像,重命名镜像名为star7th/showdoc:latest

    docker pull registry.cn-shenzhen.aliyuncs.com/star7th/showdoc
    docker tag  registry.cn-shenzhen.aliyuncs.com/star7th/showdoc star7th/showdoc
    

    2.3、创建数据存储目录/opt/showdoc_data/html,赋予存储目录最高权限,启动showdoc容器

    mkdir -p /opt/showdoc_data/html
    chmod  -R 777 /opt/showdoc_data
    docker run -d --name showdoc --user=root --privileged=true -p 4999:80 -v /opt/showdoc_data/html:/var/www/html/ star7th/showdoc
    

    2.4、此时web访问http://ip:4999登录showdoc平台

    3、设置开机自启

    查看当前容器ID,设置自动启动

    • 方法一
    docker update --restart=always `docker ps -a -q`
    
    • 方法二
    echo "sleep 3" >> /etc/rc.local 
    echo "docker start `docker ps -a`" >> /etc/rc.local 
    

    三、数据备份

    1、docker镜像备份

    备份当前docker镜像

    [root@node226 ~]# docker images
    REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
    star7th/showdoc                                     latest              29bb506bad96        28 hours ago        392MB
    registry.cn-shenzhen.aliyuncs.com/star7th/showdoc   latest              29bb506bad96        28 hours ago        392MB
    [root@node226 ~]# docker save star7th/showdoc -o showdoc.tar
    

    2、showdoc数据备份

    2.1、编写备份脚本/opt/backup.sh如下

    [root@node227 ~]# cat /opt/backup.sh 
    #!/bin/bash
    #定义备份路径
    path="/mnt/backup"
    #定义数据保存天数
    day=7
    #备份文件
    zip -r $path/showdoc-`date +%Y%m%d%H%M`.zip /showdoc_data/html/
    #定期删除文件
    find $path -type f -mtime +$day -exec rm -f {} ;
    

    2.2、设置crontab定时任务,每天凌晨三点定时执行脚本

    [root@node227 ~]# crontab -l
    0 3 * * * /bin/bash /opt/backup.sh
    

    四、数据恢复

    1、docker镜像恢复

    1.1、参照二、部署安装完成docker环境部署

    1.2、关闭selinux
    修改/etc/selinux/config配置文件,修改配置为SELINUX=disabled

    [root@node134 ~]# setenforce 0
    
    [root@node134 ~]# cat /etc/selinux/config | grep SELINUX=
    SELINUX=disabled
    

    1.3、将docker镜像导入到目标服务器内

    [root@node134 ~]# docker load < showdoc.tar 
    
    [root@node134 ~]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    star7th/showdoc     latest              29bb506bad96        30 hours ago        392MB
    

    1.4、运行容器

    [root@node134 ~]# mkdir -p /opt/showdoc_data/html
    [root@node134 ~]# chmod  -R 777 /opt/showdoc_data
    [root@node134 ~]# docker run -d --name showdoc --restart=always --user=root --privileged=true -p 4999:80 -v /opt/showdoc_data/html:/var/www/html/ star7th/showdoc
    

    2、showdoc数据恢复

    恢复数据库数据Sqlite/showdoc.db.php和附件数据Public/Uploads/.后,重新访问showdoc平台即可

    [root@node134 ~]# unzip showdoc-202011171546.zip
    [root@node134 ~]# cp -r showdoc_data/html/Sqlite/showdoc.db.php /opt/showdoc_data/html/Sqlite/
    [root@node134 ~]# cp -r showdoc_data/html/Public/Uploads/. /opt/showdoc_data/html/Public/Uploads/
    
  • 相关阅读:
    Spring -- 自定义转换器
    Spring乱码问题解决方案
    Spring 声明式事务
    Spring -- IOC
    Spring--入门
    mybatis 二级缓存
    Mybatis 缓存失效的几种情况
    MyBatis深入浅出--入门
    【RF库Collections测试】Get From Dictionary
    【RF库Collections测试】Get Dictionary Values
  • 原文地址:https://www.cnblogs.com/luxf0/p/13995821.html
Copyright © 2011-2022 走看看