docker部署 Jira


环境介绍


使用 docker-compose 安装 Jira 项目管理系统。


操作系统


CentOS Linux release 7.9.2009 (Core)

资源配置


CPU:2
MEM:4g
DISK:100g

docker 版本


docker 版本不做统一限制,只要能够运行容器即可。

root@localhost(192.168.199.152)~>docker version
Client: Docker Engine - Community
 Version:           25.0.4
 API version:       1.44
 Go version:        go1.21.8
 Git commit:        1a576c5
 Built:             Wed Mar  6 16:33:16 2024
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          25.0.4
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.21.8
  Git commit:       061aa95
  Built:            Wed Mar  6 16:32:11 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.28
  GitCommit:        ae07eda36dd25f8a1b98dfbf587313b99c0190bb
 runc:
  Version:          1.1.12
  GitCommit:        v1.1.12-0-g51d5e94
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
  
root@localhost(192.168.199.152)~>docker-compose version
Docker Compose version v2.24.7

安装过程


记录 jira 整个安装过程。


系统初始化


关闭selinux和firewalld


root@localhost(192.168.199.152)~>sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
root@localhost(192.168.199.152)~>systemctl disable --now firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

修改hosts并声明


root@localhost(192.168.199.152)~>hostnamectl set-hostname --static jira
root@localhost(192.168.199.152)~>echo '192.168.199.152 jira' >> /etc/hosts

退出会话重新登录即可。


校对时间


root@jira(192.168.199.152)~>ntpdate ntp1.aliyun.com

安装docker


root@jira(192.168.199.152)~>yum -y install  docker-ce
root@jira(192.168.199.152)~>echo -e '#!/bin/bash\ndocker-compose $@' > /usr/bin/docker-compose
root@jira(192.168.199.152)~>chmod +x /usr/bin/docker-compose
root@jira(192.168.199.152)~>docker-compose version
Docker Compose version v2.24.7

安装jira


root@jira(192.168.199.152)~>docker pull atlassian/jira-software:8.16.1

为啥采用 8.16.1 , 因为这个版本可以破解。

创建jira运行目录
root@jira(192.168.199.152)/root>mkdir jira
root@jira(192.168.199.152)/root/jira>docker run -d --name jira -p 8080:8080 -v ./jira/data:/var/atlassian/application-data/jira atlassian/jira-software:8.16.1

浏览器访问设置


image-20240321141806348

image-20240321141833031

下一步

image-20240321141944757

到这里需要使用 MySQL ,那就安装MySQL咯。


容器运行MySQL


root@jira(192.168.199.152)/root/jira>docker run -e "MYSQL_ROOT_PASSWORD=123123" -d --name mysql -p 3306:3306 -v ./mysql/data:/var/lib/mysql mysql:8.0.22

创建数据库 jiradb

root@jira(192.168.199.152)/root/jira>docker exec -it mysql bash
root@13a3850562c9:/# mysql -uroot -p123123
mysql> CREATE DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
Query OK, 1 row affected (0.01 sec)

页面继续填写信息

主机:192.168.199.152
端口:3306
数据库:jiradb
用户名:root
密码:123123

image-20240321143521646

jira提示:找不到驱动:com.mysql.cj.jdbc.Driver

需要为jira提供 mysql-connect驱动。


下载mysql-connect驱动


下载地址:https://downloads.mysql.com/archives/c-j/

image-20240321143706822

下载完成后,拷贝到 jira 容器里(临时测试方法)

创建存放mysql-connector 目录
root@jira(192.168.199.152)/root/jira>mkdir lib
root@jira(192.168.199.152)/root/jira>cd lib/

上传mysql-connector 后操作
root@jira(192.168.199.152)/root/jira/lib>docker cp mysql-connector-java-8.0.22.jar jira:/opt/atlassian/jira/lib
Successfully copied 2.39MB to jira:/opt/atlassian/jira/lib

重启jira容器
root@jira(192.168.199.152)/root/jira/lib>docker restart jira

数据库不为空错误处理


再次重新填写并测试

image-20240321144112198

又出问题了, 被这个问题困扰了许久,在网络上各种搜索都没找到确切的回答。

针对:【您指定的数据库, 不为空, 请指定空数据库。如果您要升级现有的安装】,采用普通用户即可解决。

数据库添加普通用户:

进入容器
root@jira(192.168.199.152)/root/jira/lib>docker exec -it mysql bash

进入mysql
root@13a3850562c9:/# mysql -uroot -p123123

创建用户
mysql> CREATE USER 'jira'@'%' IDENTIFIED BY 'Jira#123';
Query OK, 0 rows affected (0.03 sec)

为该用户赋权jria
mysql> GRANT ALL PRIVILEGES ON jiradb.* TO 'jira'@'%';
Query OK, 0 rows affected (0.01 sec)

然后再使用普通用户测试

image-20240321145058504

OK,测试连接通过了。点击下一步就开始初始化数据库之后就完成了。

image-20240321145647282

点击下一步。


激活Jira


image-20240321145717103

到这里就需要激活了。

激活Jira 分几步:

  1. 拷贝激活工具到 /var/atlassian/application-data/jira 目录,也就是jira挂载目录
  2. /opt/atlassian/jira/bin/setenv.sh 最后添加一行指令,启动加载代理包

激活工具是一个 jar包:atlassian-agent.jar 下载链接:https://files-cdn.cnblogs.com/files/sanduzxcvbnm/atlassian-agent-v1.2.3.zip

解压上传至 lib 目录

直接将激活工具拷贝到容器挂载目录
root@jira(192.168.199.152)/root/jira>docker cp  lib/atlassian-agent.jar jira:/opt/atlassian/jira/

为什么要把激活工具拷贝到容器里,因为容器内直接就有 java 环境,无需在本地安装jdk

设置启动加载代理包

进入容器
root@jira(192.168.199.152)/root/jira>docker exec -it jira bash
root@ffa9e31feeb6:/opt/atlassian/jira/bin# echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/jira/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/jira/bin/setenv.sh

重启容器

root@jira(192.168.199.152)/root/jira>docker restart jira

然后进入容器通过机器码注册:

进入容器
root@jira(192.168.199.152)/root>docker exec -it jira bash
进入目录
root@93ffdce361d7:/var/atlassian/application-data/jira# cd /opt/atlassian/jira/
开始注册
root@93ffdce361d7:/opt/atlassian/jira# java -jar atlassian-agent.jar \
-d -m admin@xajs.com -n Jira \
-p jira -o http://192.168.199.152:8080 \
-s BB75-MAOJ-IUQT-A139

====================================================
=======        Atlassian Crack Agent         =======
=======           https://zhile.io           =======
=======          QQ Group: 30347511          =======
====================================================

Your license code(Don't copy this line!!!):

AAABpQ0ODAoPeJyNkk9vozAQxe98CqQ9Q22aFIhkaVPgQAXJdkN6d8ikuAKDxibb7KdfE9jd/omiS
r7Ymvf8mzfzrah6O+doe9Qm/oLeLWa+vS0i2yPezHpGAFm1XQfoZqIEqaA4dbDiDbBonefJzyhdZ
laEwLVoZcw1sEHokFvHo9YVSQyqRNENKraVtWiEhr1djwJ7d7IrrTu1uLn5XYkaXNFaORdSg+Syh
OS1E3iafgtCh/jmWC8C+V/KZC9G61WW5mmRxNaqb3aA68NWASrm/IO74tVhu+9L7Q4XR7UH/Ysju
J+MrtTyUosjMI09vMvy7fsVuaHiEZiucSyd4nkyHw/Nedam3/2P8VySHHndn4fBDrxWk/1HozU+c
ynUWDckbYKmoefSu8ClYejSubcISECsqJXawCYm/JrxfSPk91f+otyybUbny2l8sb+N5jgwjaTTQ
NKYZWm8SVZORn1KCZnPiB947+d7aaU2gEdAI7+/9+dOvlw/OOn2sXCW9Da8tMmfd+RHj2XFFXzc4
7fic4odCjW1Z0DZBdgpuDPjgwH/A5XLKKIwLQIUWij1U5+pRMIXWta3uH2hb9oacB0CFQCK1rQvV
mldN/vR3uiEdEOPmzUBpQ==X02kc

将上面的连续的随机串复制到页面文本框中。

image-20240321151755294

点击下一步,等待完成就好了。


docker-compose启动


将上面所有步骤整合起来,写成 docker-compose 方式i启动


编写 .env 变量申明文件


root@jira(192.168.199.152)~/jira>cat .env
MYSQL_ROOT_PASSWORD=123123
MYSQL_ROOT_HOST=%

编写docker-compose


vim docker-compose.yml

version: "3.7"
services:
  mysql:
    container_name: mysql
    image: mysql:8.0.22
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_ROOT_HOST=${MYSQL_ROOT_HOST}
      - TZ=Asia/Shanghai
    restart: always
    volumes:
    - ./data/mysql:/var/lib/mysql
    command: --lower_case_table_names=1 --skip-name-resolve --max-connections=1000 --server-id=1 --log-bin=mysql-bin
    healthcheck:
      test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost", "-uroot", "-p${MYSQL_ROOT_PASSWORD}"]
      interval: 5s
      timeout: 1s
      retries: 10
    network_mode: "host"

  jira:
    container_name: jira
    build: 
      context: jira
      dockerfile: Dockerfile
    image: atlassian/jira-software:8.16.1
    environment:
    - TZ=Asia/Shanghai
    restart: always
    volumes:
    - ./data/jira:/var/atlassian/jira
    network_mode: "host"

启动完成后,进入mysql容器创建用户及数据库

root@jira(192.168.199.152)~/jira>docker exec -it mysql bash
root@jira:/# mysql -uroot -p123123
mysql> CREATE DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
mysql> CREATE USER 'jira'@'%' IDENTIFIED BY 'Jira#123';
mysql> GRANT ALL PRIVILEGES ON jiradb.* TO 'jira'@'%';

最后通过机器码注册

root@jira(192.168.199.152)~/jira>docker exec -it jira bash
root@jira:/var/atlassian/application-data/jira# cd /opt/atlassian/jira/
root@jira:/opt/atlassian/jira# java -jar atlassian-agent.jar \
-d -m admin@xajs.com -n Jira \
-p jira -o http://192.168.199.152:8080 \
-s BF3T-Z4GM-0KL1-ZZE0

下载直接使用


下载链接:链接:https://pan.baidu.com/s/1HfT6_S_52fxXXBjXRp2Faw?pwd=hkey 
提取码:hkey 

博客园文章共享目录 / 程序部署 / jira-docker-compose / jira-docker-compose.tar.gz
  1. 导入基础镜像
root@jira(192.168.199.152)~>tar xf jira-docker-compose.tar.gz
root@jira(192.168.199.152)~>cd jira-docker-compose/
root@jira(192.168.199.152)~/jira-docker-compose>/usr/bin/ls images/* | xargs -i docker load -i {}
  1. 启动
root@jira(192.168.199.152)~/jira-docker-compose>docker-compose up -d
  1. 进入mysql容器创建用户及数据库
root@jira(192.168.199.152)~/jira>docker exec -it mysql bash
root@jira:/# mysql -uroot -p123123
CREATE DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
CREATE USER 'jira'@'%' IDENTIFIED BY 'Jira#123';
GRANT ALL PRIVILEGES ON jiradb.* TO 'jira'@'%';
  1. 最后通过机器码注册
root@jira(192.168.199.152)~/jira>docker exec -it jira bash
root@jira:/var/atlassian/application-data/jira# cd /opt/atlassian/jira/
root@jira:/opt/atlassian/jira# java -jar atlassian-agent.jar \
-d -m admin@xajs.com -n Jira \
-p jira -o http://192.168.199.152:8080 \
-s BF3T-Z4GM-0KL1-ZZE0


--- EOF ---
posted @ 2024-03-21 17:55  hukey  阅读(1127)  评论(0编辑  收藏  举报