zoukankan      html  css  js  c++  java
  • 禅道在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        20 hours ago        584MB
    djltomcat                                              latest              d260185f87dc        5 weeks ago         508MB
    ubuntu                                                 16.04               7e87e2b3bf7a        6 weeks ago         117MB
    mysql                                                  latest              102816b1ee7d        2 months ago        486MB
    registry.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 ps
    CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                     NAMES
    0b3bcb6316c4        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:mysqlbackupzentaopro.sql

    mysqldump -uroot -proot123 zentao > D:mysqlbackupzentao.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:xamppzentaomoduleug

    E:xamppzentaomoduleuglang

    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 60
    drwxrwxr-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:xamppzentaowwwdataupload

    docker容器目标路径

    root@0b3bcb6316c4:/app/zentaopms/www/data/upload# pwd
    /app/zentaopms/www/data/upload
    root@0b3bcb6316c4:/app/zentaopms/www/data/upload# ll
    total 4
    drwxrwxrwx.  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 ~]# ls
    50-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            = mysql
    pid-file        = /var/run/mysqld/mysqld.pid
    socket          = /var/run/mysqld/mysqld.sock
    port            = 3306
    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       = 8
    # This replaces the startup script and checks MyISAM tables if needed
    # the first time they are touched
    myisam-recover         = BACKUP
    #max_connections        = 100
    #table_cache            = 64
    #thread_concurrency     = 10
    
    #
    # * 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             = 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.log
    expire_logs_days        = 10
    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 4-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.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 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 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
    1b97eee2741749a286c8b40791f7bfd1ee0e687e8c414edaf5e95cfa218f7883
    [root@localhost ~]#
    [root@localhost ~]#
    [root@localhost ~]# docker ps
    CONTAINER ID        IMAGE                                                  COMMAND                  CREATED             STATUS              PORTS                                          NAMES
    1b97eee27417        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 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 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

  • 相关阅读:
    替换空格-请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。
    cocoapod卡在了analyzing dependencies
    前台技术--div的隐藏与显示
    POJ 3252 Round Numbers(组合数学)
    6. oracle学习入门系列之六 模式
    Python基础教程之第3章 使用字符串
    PHP+FastCGI+Nginx动态请求处理配置
    cocos2d-x cocoStudioUI编辑器导出文件的使用
    分布式系统生成唯一主键
    Android-Volley网络通信框架(二次封装数据请求和图片请求(包含处理请求队列和图片缓存))
  • 原文地址:https://www.cnblogs.com/djlsunshine/p/10515772.html
Copyright © 2011-2022 走看看