禅道在docker上部署与迁移

一、禅道部署

1、下载地址

禅道开源版:   http://dl.cnezsoft.com/zentao/docker/docker_zentao.zip

数据库用户名: root,默认密码: 123456。运行时,可以设置 MYSQL_ROOT_PASSWORD变量来更改密码。

可挂载目录

/app/zentaopms:该目录为禅道目录,里面包含禅道代码及附件上传目录。

/var/lib/mysql:该目录为数据库的数据目录。

2、安装使用

(1)、准备环境:

注意:需要关闭下selinux

新建禅道目录

# mkdir /home/chandao

创建映射目录

# mkdir /home/chandao/data

# mkdir /home/chandao/www

解压文件

# cd /home/chandao/

# mv /root/docker_zentao.zip .

# unzip docker_zentao.zip

[root@localhost ~]# cd /home/chandao/
[root@localhost chandao]#
[root@localhost chandao]# ls
data docker_zentao www
[root@localhost chandao]# cd docker_zentao/
[root@localhost docker_zentao]#
[root@localhost docker_zentao]# ls
Dockerfile README.md config docker-entrypoint.sh
[root@localhost docker_zentao]#

(2)、构建镜像

执行命令 docker build -t [镜像名称] [Dockerfile所在目录]

# cd /home/chandao/docker_zentao

# docker build -t chandao .

查看构建的镜像

# docker images

[root@localhost docker_zentao]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
chandao latest 98c88f2a1099 hours ago 584MB
djltomcat latest d260185f87dc weeks ago 508MB
ubuntu 16.04 7e87e2b3bf7a weeks ago 117MB
mysql latest 102816b1ee7d months ago 486MB
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g latest 3fa112fd3642 years ago .85GB
[root@localhost docker_zentao]#

(3)、运行镜像

# docker run --name chandao -p 7075:80 -v /home/chandao/www/:/app/zentaopms -v /home/chandao/data/:/var/lib/mysql -e MUSQL_ROOT_PASSWORD=123456 -d chandao:latest

参数说明:

--name(容器名字)

-v(挂着目录)

-e(设置环境变量)

-d(运行容器后不自动进入容器)

查看正在运行的容器

# docker ps

[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
0b3bcb6316c4 chandao:latest "/app/docker-entrypo…" hours ago Up hours 0.0.0.0:->/tcp chandao

(4)、安装禅道

浏览器访问:

http://服务器IP地址:端口号

二、迁移

1、迁移MySQL数据库

(1)、首先备份原库

进入MySQL数据库

mysql -uroot -proot123

查看MySQL库

show databases;

只需要对以下两个库进行备份

禅道在docker上部署与迁移

退出MySQL数据库

quit

执行备份命令

mysqldump -uroot -proot123 zentaopro > D:\mysqlbackup\zentaopro.sql

mysqldump -uroot -proot123 zentao > D:\mysqlbackup\zentao.sql

禅道在docker上部署与迁移

到D:\mysqlbackup\路径下找备份文件,拷贝到要还原的系统中

禅道在docker上部署与迁移

(2)、数据还原

进入容器

# docker exec -it chandao bash

进入MySQL数据库

mysql -uroot -p123456

查看MySQL库

show databases;

如没有还原数据库,可先创建

create database 数据库名;

进入库

use 数据库名;

还原数据文件

source /var/lib/mysql/zentaopro.sql

source /var/lib/mysql/zentao.sql

2、由于公司修改了某些PHP文件,所以还需要进行文件替换

注意:根据需求来

原路径

E:\xampp\zentao\module\bug

禅道在docker上部署与迁移

E:\xampp\zentao\module\bug\lang

禅道在docker上部署与迁移

docker容器里面的目标路径

root@0b3bcb6316c4:/app/zentaopms/module/bug# pwd
/app/zentaopms/module/bug
root@0b3bcb6316c4:/app/zentaopms/module/bug#
root@0b3bcb6316c4:/app/zentaopms/module/bug# ll
total 212
drwxrwxr-x. 7 www-data www-data 116 Mar 12 01:31 ./
drwxrwxrwx. 55 www-data www-data 4096 Feb 28 08:56 ../
-rw-r--r--. 1 root root 20368 Mar 12 01:16 config.php
-rw-rw-r--. 1 www-data www-data 72027 Feb 28 08:55 control.php
drwxrwxr-x. 2 www-data www-data 273 Feb 28 08:55 css/
drwxrwxrwx. 2 www-data www-data 6 Feb 28 08:56 ext/
drwxrwxr-x. 2 www-data www-data 223 Feb 28 08:55 js/
drwxrwxr-x. 2 www-data www-data 54 Mar 12 01:31 lang/
-rw-r--r--. 1 root root 111985 Mar 12 01:15 model.php
drwxrwxr-x. 2 www-data www-data 4096 Feb 28 08:55 view/

lang文件夹下

root@0b3bcb6316c4:/app/zentaopms/module/bug# cd lang/
root@0b3bcb6316c4:/app/zentaopms/module/bug/lang# pwd
/app/zentaopms/module/bug/lang
root@0b3bcb6316c4:/app/zentaopms/module/bug/lang# ll
total
drwxrwxr-x. www-data www-data Mar : ./
drwxrwxr-x. www-data www-data Mar : ../
-rw-rw-r--. www-data www-data Feb : en.php
-rw-r--r--. 1 root root 20339 Mar 12 01:15 zh-cn.php
-rw-rw-r--. www-data www-data Feb : zh-tw.php

3、禅道数据文件的迁移

原路径

E:\xampp\zentao\www\data\upload

禅道在docker上部署与迁移

docker容器目标路径

root@0b3bcb6316c4:/app/zentaopms/www/data/upload# pwd
/app/zentaopms/www/data/upload
root@0b3bcb6316c4:/app/zentaopms/www/data/upload# ll
total
drwxrwxrwx. www-data www-data Mar : ./
drwxrwxrwx. www-data www-data Feb : ../
drwxr-xr-x. root root Mar : /

三、映射禅道MySQL数据库的问题

由于业务需求,需要映射禅道MySQL数据库通过客户端访问连接。

注意:映射端口之后需要修改MySQL允许远程登陆连接,确认下mysql服务,是否允许非本机的其他机器访问?

这需要修改/etc/mysql/mariadb.conf.d/50-server.cnf

1、拷贝禅道MySQL配置文件进行外部修改

# docker cp chandao:/etc/mysql/mariadb.conf.d/50-server.cnf /root/

[root@localhost ~]# docker cp chandao:/etc/mysql/mariadb.conf.d/-server.cnf /root/
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# ls
-server.cnf
[root@localhost ~]#

2、修改my.ini中的bind-address参数

# cat 50-server.cnf.bak

删除bind-address参数或者修改为bind-address=0.0.0.0

[root@localhost ~]# cat -server.cnf.bak
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
# # this is read by the standalone daemon and embedded servers
[server] # this is only for the mysqld standalone daemon
[mysqld] #
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port =
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking # Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1 #
# * Fine Tuning
#
key_buffer_size = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size =
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover = BACKUP
#max_connections =
#table_cache =
#thread_concurrency = #
# * Query Cache Configuration
#
query_cache_limit = 1M
query_cache_size = 16M #
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log =
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file = /var/log/mysql/mariadb-slow.log
#long_query_time =
#log_slow_rate_limit =
#log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id =
#log_bin = /var/log/mysql/mysql-bin.log
expire_logs_days =
max_binlog_size = 100M
#binlog_do_db = include_database_name
#binlog_ignore_db = include_database_name #
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many! #
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem #
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 -byte character set. See also client.cnf
#
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci #
# * Unix socket authentication plugin is built-in since 10.0.-
#
# Needed so the root database user can authenticate without a password but
# only when running as the unix root user.
#
# Also available for other users if required.
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/ # this is only for embedded server
[embedded] # This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb] # This group is only read by MariaDB-10.0 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.0]
[root@localhost ~]#

停止禅道容器

# docker stop chandao

[root@localhost ~]# docker stop chandao
chandao
[root@localhost ~]#

删除禅道容器

# docker rm chandao

[root@localhost ~]# docker rm chandao
chandao
[root@localhost ~]#

3、重新创建禅道容器,增加MySQL端口

# docker run --name chandao -p 7075:80 -p 3307:3306 -v /home/chandao/www/:/app/zentaopms -v /home/chandao/data/:/var/lib/mysql -e MUSQL_ROOT_PASSWORD=123456 -d chandao:latest

[root@localhost ~]# docker run --name chandao -p : -p : -v /home/chandao/www/:/app/zentaopms -v /home/chandao/data/:/var/lib/mysql -e MUSQL_ROOT_PASSWORD= -d chandao:latest
1b97eee2741749a286c8b40791f7bfd1ee0e687e8c414edaf5e95cfa218f7883
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b97eee27417 chandao:latest "/app/docker-entrypo…" seconds ago Up seconds 0.0.0.0:->/tcp, 0.0.0.0:->/tcp chandao

4、替换禅道容器中的数据库配置文件

# docker cp /root/50-server.cnf chandao:/etc/mysql/mariadb.conf.d/

5、重新启动禅道容器

# docker restart chandao

[root@localhost ~]# docker cp /root/-server.cnf chandao:/etc/mysql/mariadb.conf.d/
[root@localhost ~]#
[root@localhost ~]# docker restart chandao
chandao
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b97eee27417 chandao:latest "/app/docker-entrypo…" About a minute ago Up seconds 0.0.0.0:->/tcp, 0.0.0.0:->/tcp chandao

四、升级

1、重新构建镜像

重新修改Dockerfile,重新运行构建镜像命令

禅道在docker上部署与迁移

# docker build -t chandao:v2 .

2、备份数据库(zentao)和data数据

3、用新镜像运行容器

如果升级失败需要如下操作

4、删除所有表 然后再还原备份

5、然后重新升级一下禅道

升级时会提示验证操作,按照提示要求,在 [主机代码目录] 的 www 目录创建 ok.txt。

创建后,点击 继续更新即可。

参考网站:

https://www.zentao.net/download/80098.html

请先阅读官网文档,多数使用问题都可以在文档内找到答案

http://www.zentao.net/book/zentaopmshelp.html

技术支持:

http://www.zentao.net/book/zentaopmshelp/70.html

上一篇:k8s 平台部署java网站项目


下一篇:图像处理------基于Otsu阈值二值化