1 基础知识
ownCloud是一个基于Linux的开源云项目,允许用户以浏览器或WebDAV方式访问云服务器,进行各项管理工作。ownCloud支持多种设备访问,用户可以很方便地使个人设备与服务器上存储的文件、日程安排、通讯录、书签等重要数据保持同步。
2 最佳实践
2.1 部署前的准备
2.1.1 部署Docker环境
本章使用如下Docker环境部署,参阅本章建议你先搭建以下Docker集群环境并熟悉,
2.1.2 准备owncloud镜像
In docker01
cd /data/docker/images/ docker load -i owncloud-server_10.0.0.tar docker tag owncloud/server:10.0.0 docker01.cmdschool.org:5000/owncloud/server:10.0.0 docker push docker01.cmdschool.org:5000/owncloud/server:10.0.0 docker image rm owncloud/server:10.0.0
另外,安装包的离线下载请在能上网的docker环境的机器上使用如下命令,
docker pull owncloud/server:10.0.0 docker save owncloud/server:10.0.0 -o owncloud-server_10.0.0.tar
另外,其他版本请从以下链接下载,
https://hub.docker.com/r/owncloud/server
2.1.3 准备mariaDB镜像
In docker01
cd /data/docker/images/ docker load -i mariadb_10.5.6.tar docker tag mariadb:10.5.6 docker01.cmdschool.org:5000/mariadb:10.5.6 docker push docker01.cmdschool.org:5000/mariadb:10.5.6 docker image rm mariadb:10.5.6
另外,安装包的离线下载请在能上网的docker环境的机器上使用如下命令,
docker pull mariadb:10.5.6 docker save mariadb:10.5.6 -o mariadb_10.5.6.tar
另外,其他版本请从以下链接下载,
https://hub.docker.com/_/mariadb
2.1.4 准备Redis镜像
In docker01
cd /data/docker/images/ docker load -i webhippie-redis_latest.tar docker tag webhippie/redis:latest docker01.cmdschool.org:5000/webhippie/redis:latest docker push docker01.cmdschool.org:5000/webhippie/redis:latest docker image rm webhippie/redis:latest
另外,安装包的离线下载请在能上网的docker环境的机器上使用如下命令,
docker pull webhippie/redis:latest docker save webhippie/redis:latest -o webhippie-redis_latest.tar
另外,其他版本请从以下链接下载,
https://hub.docker.com/r/webhippie/redis
2.2 部署ownCloud
In docker01
2.2.1 创建服务配置文件
vim /data/docker/yml/owncloud-stack.yml
加入如下配置,
version: '3.0' volumes: files: driver: local mysql: driver: local backup: driver: local redis: driver: local services: owncloud: image: docker01.cmdschool.org:5000/owncloud/server:10.0.0 restart: always ports: - 80:80 - 443:443 deploy: replicas: 1 placement: constraints: [node.labels.owncloud == true] depends_on: - db - redis environment: - TZ=Asia/Shanghai - OWNCLOUD_DOMAIN=owncloud.cmdschool.org - OWNCLOUD_DB_TYPE=mysql - OWNCLOUD_DB_NAME=owncloud - OWNCLOUD_DB_USERNAME=owncloud - OWNCLOUD_DB_PASSWORD=owncloud - OWNCLOUD_DB_HOST=db - OWNCLOUD_ADMIN_USERNAME=admin - OWNCLOUD_ADMIN_PASSWORD=adminpwd - OWNCLOUD_MYSQL_UTF8MB4=true - OWNCLOUD_REDIS_ENABLED=true - OWNCLOUD_REDIS_HOST=redis healthcheck: test: ["CMD", "/usr/bin/healthcheck"] interval: 30s timeout: 10s retries: 5 volumes: - files:/mnt/data db: image: docker01.cmdschool.org:5000/mariadb:10.5.6 restart: always deploy: replicas: 1 placement: constraints: [node.labels.mariadb == true] environment: - TZ=Asia/Shanghai - MYSQL_ROOT_PASSWORD=rootpwd - MYSQL_DATABASE=owncloud - MYSQL_USER=owncloud - MYSQL_PASSWORD=owncloud - MARIADB_MAX_ALLOWED_PACKET=128M - MARIADB_INNODB_LOG_FILE_SIZE=64M #healthcheck: # test: ["CMD", "/usr/bin/healthcheck"] # interval: 30s # timeout: 10s # retries: 5 volumes: - mysql:/var/lib/mysql - backup:/var/lib/backup redis: image: docker01.cmdschool.org:5000/webhippie/redis:latest restart: always deploy: replicas: 1 placement: constraints: [node.labels.redis == true] environment: - TZ=Asia/Shanghai - REDIS_DATABASES=1 healthcheck: test: ["CMD", "/usr/bin/healthcheck"] interval: 30s timeout: 10s retries: 5 volumes: - redis:/var/lib/redis
根据配置的需求设置运行标记,
In docker01
docker node update --label-add owncloud=true docker01.cmdschool.org docker node update --label-add mariadb=true docker02.cmdschool.org docker node update --label-add redis=true docker02.cmdschool.org
2.2.2 部署服务
docker stack deploy -c /data/docker/yml/owncloud-stack.yml owncloud
2.3 配置SSL证书
2.3.1 理解SSL证书存放目录
In docker01
docker exec -it `docker container ls | grep 'owncloud_owncloud' | cut -d" " -f1 ` bash ls /mnt/data/certs/
实际上,我们可以通过如下命令查询卷位于物理机的实际存储路径,
docker volume inspect owncloud_files | grep "Mountpoint"
可见如下显示,
"Mountpoint": "/data/docker/runningdata/volumes/owncloud_files/_data",
2.3.2 申请SSL证书
如果没有证书,请从腾讯云申请免费证书,
https://cloud.tencent.com/product/ssl
注:以上申请后使用Nginx证书即可并保存到目录“/data/docker/certs
2.3.3 配置SSL证书
In docker01
cd /data/docker/certs/ cat 2_owncloud.cmdschool.org.key > /data/docker/runningdata/volumes/owncloud_files/_data/certs/ssl-cert.key cat 1_owncloud.cmdschool.org_bundle.crt > /data/docker/runningdata/volumes/owncloud_files/_data/certs/ssl-cert.crt chmod 400 /data/docker/runningdata/volumes/owncloud_files/_data/certs/ssl-cert.key
部署完成后,你需要使用如下命令从新部署应用,
docker stack deploy -c /data/docker/yml/owncloud-stack.yml owncloud
2.4 镜像的调试
2.4.1 客户端测试
notepad \Windows\System32\drivers\etc\hosts
测试环境可使用host解析代替DNS实现名称解析,
10.168.0.210 owncloud.cmdschool.org
然后,可使用如下域名进行程序调试,
http://owncloud.cmdschool.org/
https://owncloud.cmdschool.org/
2.4.2 排错方法
In docker01
docker exec -it `docker container ls | grep 'owncloud_owncloud' | cut -d" " -f1 ` bash
然后可以如下命令查看Apache的配置,
less /etc/apache2/sites-enabled/000-default.conf
然后可以使用如下命令查看Apache的日志,
tail -f /var/log/apache2/access.log tail -f /var/log/apache2/error.log
然后可以使用如下命令查看Apache的SSL证书路径,
ls /mnt/data/certs/
然后可以使用如下命令查看ownCloud的程序主目录,
ls /var/www/owncloud/
参阅文档
======================
安装方法
———–
https://doc.owncloud.com/server/10.5/admin_manual/installation/docker/
ownCloud gitHub
—————-
https://github.com/owncloud-docker/server
Docker Hub
————
https://hub.docker.com/r/owncloud/server/
没有评论