博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
禅道在docker上部署与迁移
阅读量:5347 次
发布时间:2019-06-15

本文共 10891 字,大约阅读时间需要 36 分钟。

一、禅道部署

1、下载地址

禅道开源版:   

数据库用户名: 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]# lsdata  docker_zentao  www[root@localhost chandao]# cd docker_zentao/[root@localhost docker_zentao]#[root@localhost docker_zentao]# lsDockerfile  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 imagesREPOSITORY                                             TAG                 IMAGE ID            CREATED             SIZEchandao                                                latest              98c88f2a1099        20 hours ago        584MBdjltomcat                                              latest              d260185f87dc        5 weeks ago         508MBubuntu                                                 16.04               7e87e2b3bf7a        6 weeks ago         117MBmysql                                                  latest              102816b1ee7d        2 months ago        486MBregistry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g   latest              3fa112fd3642        3 years ago         6.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 psCONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                     NAMES0b3bcb6316c4        chandao:latest                                         "/app/docker-entrypo…"   20 hours ago        Up 20 hours         0.0.0.0:7075->80/tcp      chandao

(4)、安装禅道

浏览器访问:

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

 二、迁移

1、迁移MySQL数据库

(1)、首先备份原库

进入MySQL数据库

mysql -uroot -proot123

查看MySQL库

show databases;

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

退出MySQL数据库

quit

执行备份命令

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

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

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

(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

 

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

docker容器里面的目标路径

root@0b3bcb6316c4:/app/zentaopms/module/bug# pwd/app/zentaopms/module/bugroot@0b3bcb6316c4:/app/zentaopms/module/bug#root@0b3bcb6316c4:/app/zentaopms/module/bug# lltotal 212drwxrwxr-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.phpdrwxrwxr-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.phpdrwxrwxr-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/langroot@0b3bcb6316c4:/app/zentaopms/module/bug/lang# lltotal 60drwxrwxr-x. 2 www-data www-data    54 Mar 12 01:31 ./drwxrwxr-x. 7 www-data www-data   116 Mar 12 01:31 ../-rw-rw-r--. 1 www-data www-data 20113 Feb 28 08:55 en.php-rw-r--r--. 1 root     root     20339 Mar 12 01:15 zh-cn.php-rw-rw-r--. 1 www-data www-data 20383 Feb 28 08:56 zh-tw.php

 3、禅道数据文件的迁移

原路径

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

docker容器目标路径

root@0b3bcb6316c4:/app/zentaopms/www/data/upload# pwd/app/zentaopms/www/data/uploadroot@0b3bcb6316c4:/app/zentaopms/www/data/upload# lltotal 4drwxrwxrwx.  3 www-data www-data   15 Mar 12 02:29 ./drwxrwxrwx.  5 www-data www-data   50 Feb 28 08:56 ../drwxr-xr-x. 23 root     root     4096 Mar 12 02:06 1/

 三、映射禅道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/50-server.cnf /root/[root@localhost ~]#[root@localhost ~]#[root@localhost ~]# ls50-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 50-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            = mysqlpid-file        = /var/run/mysqld/mysqld.pidsocket          = /var/run/mysqld/mysqld.sockport            = 3306basedir         = /usrdatadir         = /var/lib/mysqltmpdir          = /tmplc-messages-dir = /usr/share/mysqlskip-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         = 16Mmax_allowed_packet      = 16Mthread_stack            = 192Kthread_cache_size       = 8# This replaces the startup script and checks MyISAM tables if needed# the first time they are touchedmyisam-recover         = BACKUP#max_connections        = 100#table_cache            = 64#thread_concurrency     = 10## * Query Cache Configuration#query_cache_limit       = 1Mquery_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             = 1## 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 = 10#log_slow_rate_limit    = 1000#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              = 1#log_bin                        = /var/log/mysql/mysql-bin.logexpire_logs_days        = 10max_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 4-byte character set. See also client.cnf#character-set-server  = utf8mb4collation-server      = utf8mb4_general_ci## * Unix socket authentication plugin is built-in since 10.0.22-6## 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 chandaochandao[root@localhost ~]#

删除禅道容器

# docker rm chandao

[root@localhost ~]# docker rm chandaochandao[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 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:latest1b97eee2741749a286c8b40791f7bfd1ee0e687e8c414edaf5e95cfa218f7883[root@localhost ~]#[root@localhost ~]#[root@localhost ~]# docker psCONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                                          NAMES1b97eee27417        chandao:latest                                         "/app/docker-entrypo…"   9 seconds ago       Up 9 seconds        0.0.0.0:7075->80/tcp, 0.0.0.0:3307->3306/tcp   chandao

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

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

5、重新启动禅道容器

# docker restart chandao

[root@localhost ~]# docker cp /root/50-server.cnf chandao:/etc/mysql/mariadb.conf.d/[root@localhost ~]#[root@localhost ~]# docker restart chandaochandao[root@localhost ~]#[root@localhost ~]#[root@localhost ~]#[root@localhost ~]# docker psCONTAINER ID        IMAGE                                                  COMMAND                  CREATED              STATUS              PORTS                                          NAMES1b97eee27417        chandao:latest                                         "/app/docker-entrypo…"   About a minute ago   Up 3 seconds        0.0.0.0:7075->80/tcp, 0.0.0.0:3307->3306/tcp   chandao

四、升级

1、重新构建镜像

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

# 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

转载于:https://www.cnblogs.com/djlsunshine/p/10515772.html

你可能感兴趣的文章
解决VC++6.0 无法打开、无法添加工程文件
查看>>
ORA-01858: a non-numeric character was found where a numeric was expected
查看>>
Structure From Motion(二维运动图像中的三维重建)
查看>>
25复杂链表的复制
查看>>
2 Orchard汉化资源包的使用
查看>>
python3 property
查看>>
自定义控件注意点
查看>>
SSRS 报表 如何匿名查看
查看>>
JVM内存管理机制
查看>>
centos 安装Mysql
查看>>
简单通用Ajax函数
查看>>
【Android】ListView监听上下滑动(判断是否显示返回顶部按钮
查看>>
HBASE的MAPREDUCE任务运行异常解决办法,无需CYGWIN,纯WINDOWS环境
查看>>
禅道在docker上部署与迁移
查看>>
关于继承、封装、多态、抽象和接口
查看>>
c27---typedef
查看>>
android WebViewClient和WebChromeClient
查看>>
div+css清除浮动代码
查看>>
017Python路--解释器
查看>>
idea2019中utf-8乱码问题
查看>>