标签:linux key 数据恢复 perm test doc having dir one
综合以上实际存在的痛点,故决定统一部门内部文档管理,搭建文档管理平台,用于管理开发、测试各项任务输出归档。
showdoc是国内一款开源的文档管理系统,可用于编写API文档、数据字典、说明文档。
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.1、关闭selinux
注:启动容器需要写
/proc/self/attr/keycreate
配置,启用selinux会导致没有写入权限写入失败,导致启用容器出现write /proc/self/attr/keycreate: permission denied
错误
setenforce 0
/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平台
查看当前容器ID,设置自动启动
docker update --restart=always `docker ps -a -q`
echo "sleep 3" >> /etc/rc.local
echo "docker start `docker ps -a`" >> /etc/rc.local
备份当前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.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.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
恢复数据库数据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/
标签:linux key 数据恢复 perm test doc having dir one
原文地址:https://www.cnblogs.com/luxf0/p/13995757.html