临时接到一个任务,某测试环境搭建一套 Jira 项目与事务跟踪工具,决定采用容器方式来部署,数据库对接时遇到好几个坑点,先按避坑的操作步骤介绍,最后部分补充报错及解决方法。
Jira与Confluence一样,都需要用到独立的数据库,数据库部分上次的文章 Docker_Conflunce已经有了,我们接着多建一个库就好,今天主要介绍如何用Docker部署Jira以及对Jira进行破解的操作。
关于数据库官方文档说明:https://confluence.atlassian.com/adminjiraserver/connecting-jira-applications-to-mysql-5-7-966063305.html
官方介绍一定要看,不然就会遇到我遇到的报错:persevering: 我这边参考官方文档修改了 /etc/mysql/conf.d/mysql.cnf文件,增加的字段如下:
[mysqld]
default-storage-engine=INNODB
character_set_server=utf8mb4
innodb_default_row_format=DYNAMIC
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_log_file_size=2G
然后重启mysql生效
2.1.2. jira数据库准备
## 创建jira数据库及授权
CREATE DATABASE jiradb CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
GRANT ALL on jiradb.* TO 'jira'@'%' IDENTIFIED BY 'Jirapassword';
flush privileges;
注意:我昨天使用的数据库版本为 mysql5.7.29,请认真阅读官方文档中给出的不同版本不同的mysql授权命令,以及对应的参数修改,否则下面安装时会失败。
一个比较流行的第三方Jira 镜像地址:cptactionhank/atlassian-jira-software:8.10.0
这里基于该版本 dockefile 做了一些修改,重点是中文注释部分。
FROM openjdk:8-alpine
# Configuration variables.
ENV JIRA_HOME /var/atlassian/jira
ENV JIRA_INSTALL /opt/atlassian/jira
# 采用最新版 8.10.0
ENV JIRA_VERSION 8.10.0
# 加了一个环境时区
ENV JIRA_TYPE=software JAVA_OPTS='-Duser.timezone=GMT+08'
# Install Atlassian JIRA and helper tools and setup initial home
# directory structure.
RUN set -x \
&& apk add --no-cache curl tzdata xmlstarlet bash ttf-dejavu libc6-compat \
&& cp -rfv /usr/share/zoneinfo/${TIMEZONE} /etc/localtime \
&& echo ${TIMEZONE} > /etc/timezone \
&& mkdir -p "${JIRA_HOME}" \
&& mkdir -p "${JIRA_HOME}/caches/indexes" \
&& chmod -R 700 "${JIRA_HOME}" \
&& chown -R daemon:daemon "${JIRA_HOME}" \
&& mkdir -p "${JIRA_INSTALL}/conf/Catalina" \
&& curl -Ls "https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-8.10.0.tar.gz" | tar -xz --directory "${JIRA_INSTALL}" --strip-components=1 --no-same-owner \
&& curl -Ls "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.38.tar.gz" | tar -xz --directory "${JIRA_INSTALL}/lib" --strip-components=1 --no-same-owner "mysql-connector-java-5.1.38/mysql-connector-java-5.1.38-bin.jar" \
&& rm -f "${JIRA_INSTALL}/lib/postgresql-9.1-903.jdbc4-atlassian-hosted.jar" \
&& curl -Ls "https://jdbc.postgresql.org/download/postgresql-42.2.1.jar" -o "${JIRA_INSTALL}/lib/postgresql-42.2.1.jar" \
&& chmod -R 700 "${JIRA_INSTALL}/conf" \
&& chmod -R 700 "${JIRA_INSTALL}/logs" \
&& chmod -R 700 "${JIRA_INSTALL}/temp" \
&& chmod -R 700 "${JIRA_INSTALL}/work" \
&& chown -R daemon:daemon "${JIRA_INSTALL}/conf" \
&& chown -R daemon:daemon "${JIRA_INSTALL}/logs" \
&& chown -R daemon:daemon "${JIRA_INSTALL}/temp" \
&& chown -R daemon:daemon "${JIRA_INSTALL}/work" \
&& sed --in-place "s/java version/openjdk version/g" "${JIRA_INSTALL}/bin/check-java.sh" \
&& echo -e "\njira.home=$JIRA_HOME" >> "${JIRA_INSTALL}/atlassian-jira/WEB-INF/classes/jira-application.properties" \
&& touch -d "@0" "${JIRA_INSTALL}/conf/server.xml"
# Use the default unprivileged account. This could be considered bad practice
# on systems where multiple processes end up being executed by 'daemon' but
# here we only ever run one process anyway.
USER daemon:daemon
# Expose default HTTP connector port.
EXPOSE 8080
# Set volume mount points for installation and home directory. Changes to the
# home directory needs to be persisted as well as parts of the installation
# directory due to eg. logs.
VOLUME ["/var/atlassian/jira", "/opt/atlassian/jira/logs"]
# Set the default working directory as the installation directory.
WORKDIR /var/atlassian/jira
COPY "docker-entrypoint.sh" "/"
# 许可证的破解atlassian-extras-3.2.jar文件
COPY "atlassian-extras-3.2.jar" /opt/atlassian/jira/atlassian-jira/WEB-INF/lib
ENTRYPOINT ["/docker-entrypoint.sh"]
# Run Atlassian JIRA as a foreground process by default.
CMD ["/opt/atlassian/jira/bin/start-jira.sh", "-fg"]
构建镜像,执行命令:
执行如下命令,因为主机的80端口已经被conflunce占用了,这里jira暂时使用8080端口,/var/atlassian/jira 映射到本地,数据持久化
docker run -d --restart=always --link confluence:confluence --link mysql:mysql -p 8080:8080 -v /var/atlassian/jira:/var/atlassian/jira --name jira 10.10.150.105/myapp/jira
开始访问jira界面 http://10.10.10.10:8080/
a) 选择语言(选择适合自己的语言)
b) 配置数据库信息(信息填好,点击下面的测试连接,显示成功即可,否则根据提示去官网文档查看是否修改对mysql应参数)
实际上我差不多一天都卡在前面一个下一步,数据库连接各种报错,翻了官方文档和网上的一些帖子,最终手动按官方的配置,手动生成了一个dbconfig.xml文件才通过。
- 手动生成 dbconfig.xml 文件说明见官网 Using the JIRA application configuration tool 过程简介如下:
bash-4.4#cat /opt/atlassian/jira/bin
bash-4.4# ./config.sh
Loading application properties from /opt/atlassian/jira/atlassian-jira/WEB-INF/classes/jira-application.properties
Reading database configuration from /var/atlassian/jira/dbconfig.xml
2020-06-30 02:55:42,693+0000 main INFO [c.a.j.config.database.DatabaseConfigHandler] Trying to get encrypted password from xml and decrypt it
2020-06-30 02:55:42,754+0000 main INFO [c.a.j.config.database.DatabaseConfigHandler] Database password decryption success!
No graphics display available; using console.
----------------------
JIRA Configurator v1.1
----------------------
--- Main Menu ---
[H] Configure JIRA Home
[D] Database Selection
[W] Web Server (incl. HTTP/HTTPs configuration)
[A] Advanced Settings
[S] Save and Exit
[X] Exit without Saving
配置范例如下:
- 注意第8行最后数据库 jira?之后应该是 useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB&useSSL=false 这样的形式,特别是 &useSSL=false,而不是&
- 第10行,11行,需要是加密后的密码形式 atlassian-password-cipher-provider,加密说明见官网 https://confluence.atlassian.com/adminjiraserver084/basic-encryption-979404294.html
cat /var/atlassian/jira/dbconfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<jira-database-config>
<name>defaultDS</name>
<delegator-name>default</delegator-name>
<database-type>mysql</database-type>
<schema-name>public</schema-name>
<jdbc-datasource>
<url>jdbc:mysql://address=(protocol=tcp)(host=mysql)(port=3306)/jira?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB&useSSL=false</url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<username>jirauser</username>
<atlassian-password-cipher-provider>com.atlassian.db.config.password.ciphers.base64.Base64Cipher</atlassian-password-cipher-provider>
<password>VEZqaXJhcG****=</password>
<pool-min-size>20</pool-min-size>
<pool-max-size>20</pool-max-size>
<pool-max-wait>30000</pool-max-wait>
<pool-max-idle>20</pool-max-idle>
<pool-remove-abandoned>true</pool-remove-abandoned>
<pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
<validation-query>select 1</validation-query>
<min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
<time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
<pool-test-on-borrow>false</pool-test-on-borrow>
<pool-test-while-idle>true</pool-test-while-idle>
</jdbc-datasource>
</jira-database-config>
得到正确的dbconfig.xml 后,连接数据库成功,进入下一个界面。
c) 获取授权码
这里破解跟confluence略有不同,jira破解需要先按照提示去官方获取试用授权码,这样才可以进入系统,然后进行破解包的替换,重启服务即可。
生成试用许可证,这几个图是网上的,自己没来的及截图:)听说授权不贵,这里的破解步骤仅玩票研究用,切记!
选择 Jira software服务器版
生成许可证
生成的许可证填到下一步文本框
c) 查看破解
登陆jira>>右上角设置按钮>>应用程序,即可看到许可证已经到了2033年。
COPY "atlassian-extras-3.2.jar" /opt/atlassian/jira/atlassian-jira/WEB-INF/lib
- Q1,界面提示 database setup is not supporting utf8mb4...
The database setup is not supporting utf8mb4
See our documentation for more information on setting up MySQL 5.7.
- A1,参考前面的 /etc/mysql/conf.d/mysql.cnf 部分,在 [mysqld] 下 增加 character_set_server=utf8mb4 字段即可, 详见
- Q2,日志报错 WARN: Establishing SSL connection without server's identity verification is not recommended....
Mon Jun 29 00:49:07 GMT 2020 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Connection successful!
- A2,参考在dbconfig.xml 文件中最末尾 </url> 结束前,添加&useSSL=false 字段。
- Q3,密码加密问题Database password decryption not performed.
2020-06-28 23:52:08,685+0800 JIRA-Bootstrap INFO [c.a.j.config.database.DatabaseConfigHandler] Trying to get encrypted password from xml and decrypt it
2020-06-28 23:52:08,686+0800 JIRA-Bootstrap INFO [c.a.j.config.database.DatabaseConfigHandler] Database password decryption not performed.
- A3,需要是加密后的密码形式 atlassian-password-cipher-provider,加密说明见官网 https://confluence.atlassian.com/adminjiraserver084/basic-encryption-979404294.html
如本例子
/opt/atlassian/jira/bin $ java -cp "./*" com.atlassian.db.config.password.tools.CipherTool
Enter password:
2020-06-28 15:58:42,255 main DEBUG [db.config.password.DefaultCipherProvider] Initiate cipher provider class: com.atlassian.db.config.password.ciphers.base64.Base64Cipher
2020-06-28 15:58:42,255 main DEBUG [password.ciphers.base64.Base64Cipher] Initiate Base64Cipher
2020-06-28 15:58:42,314 main DEBUG [password.ciphers.base64.Base64Cipher] Encrypting data...
2020-06-28 15:58:42,315 main DEBUG [password.ciphers.base64.Base64Cipher] Encryption done.
Success! Put those lines in database config xml file:
<atlassian-password-cipher-provider>com.atlassian.db.config.password.ciphers.base64.Base64Cipher</atlassian-password-cipher-provider>
<password>VEZqaXJh*******=</password>
and restart the instance.
-
- Q4,日志提示 Startup check failed. Jira will be locked.
- A4,删除 $JIRA_HOME/.jira-home.lock(本例中为/var/atlassian/jira/.jira-home.lock)
文章评论