Linux Centos7.x下部署Jira 8.9.0 和破解方法详述2

介绍

JIRA是Atlassian公司出品的项目与事务跟踪工具,被广泛应用于缺陷跟踪(bug管理)、客户服务、需求收集、流程审批、任务跟踪、项目跟踪和敏捷管理等工作领域。

Confluence 是一个专业的企业知识管理与协同软件,也可以用于构建企业wiki。使用简单,但它强大的编辑和站点管理特征能够帮助团队成员之间共享信息、文档协作、集体讨论,信息推送。

注意:在互联网企业使用 Jira+Confluence 较为常见,而且二者往往都是配套一起部署和使用;

环境

一、安装JDK并配置环境变量

1.安装 JDK,如果你已经安装,此步略过.....
mkdir -p /usr/local/java
tar zxf jdk-8u251-linux-x64.tar.gz -C /usr/local/java
2.配置环境变量。

vim /etc/profile 加入行

export JAVA_HOME=/usr/local/java/jdk1.8.0_251
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH
3.让配置文件立即生效
source /etc/profile
4.检查是否安装成功
java -version

出现以下信息代表安装成功:

java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)

二、 安装 MySQL

1.编译安装MySQL安装方法 https://www.fooher.com/20191225_290.html
rpm -ivh https://repo.mysql.com/mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql-server
systemctl enable mysqld
systemctl start mysqld
2.除此之外,我们还需要修改配置文件,修改密码策略:
cat > /etc/my.cnf << EOF
[client]
port = 3306
socket = /tmp/mysql.sock
default-character-set = utf8mb4

[mysql]
prompt="MySQL [\\d]> "
no-auto-rehash

[mysqld]
port = 3306
user = mysql
socket = /tmp/mysql.sock
character-set-server=utf8mb4        //注意这个不能写成default-character-set=utf8,否则会导致5.7版本mysql无法打开

pid-file = mysql.pid
bind-address = 0.0.0.0
log_error = mysql_error.log

#开启查询缓存
slow_query_log = 1
long_query_time = 1
slow_query_log_file = mysql_slow.log

server-id = 10
binlog_cache_size = 4M
max_binlog_size = 1G
max-binlog-cache-size = 2G
max-relay-log-size = 1G
log_bin = MySQL-Bin
binlog_format = mixed
log_bin_index = Binlog.index
expire_logs_days = 7

default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
#导入大的sql文件的方法
interactive_timeout = 28800
wait_timeout = 28800
connect_timeout = 20
#thread_concurrency = 8

[mysqlhotcopy]
interactive-timeout

[mysqldump]
quick
max_allowed_packet = 500M

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
EOF
2.修改 root 127.0.0.1 密码
mysql -uroot -e "grant all privileges on *.* to root@'127.0.0.1' identified by "转载请注明来源地址,fooher.com" with grant option;"
3.修改 root localhost 密码
mysql -uroot -e "grant all privileges on *.* to root@'localhost' identified by "转载请注明来源地址,fooher.com" with grant option;"
4.添加用户远程访问
mysql -uroot -e "grant all privileges on *.* to jirauser@'%' identified by "转载请注明来源地址,fooher.com" with grant option;"
5.创建 jira 数据库
mysql -uroot -e "create database jira_db default character set utf8mb4 collate utf8mb4_unicode_ci;"
6.授权 jirauser 访问 jira_db 数据库权限
mysql -uroot -e "grant all privileges on jira_db.* to 'jira_login'@'127.0.0.1' identified by "转载请注明来源地址,fooher.com" with grant option;"

注意:MySQL 5.7 使用的权限多了一个 REFERENCES,如果不正确授权会导致打开 Jira 后只能创建 Business 项目,而不能创建 Software 项目,且进入创建后的项目会报错

7.刷新数据库
mysql -uroot -e "flush privileges;"

三、 安装 Jira

1.添加 系统 jira 用户:

JIRA_USER=jira

id -u jira >/dev/null 2>&1
[ $? -ne 0 ] && useradd -M -s /bin/bash ${JIRA_USER} || { [ -z "$(grep ^${JIRA_USER} /etc/passwd | grep '/bin/bash')" ] && usermod -s /bin/bash ${JIRA_USER}; }
2.下载 Jira:

Installing Jira applications on Linux - Atlassian Documentation

wget https://product-downloads.atlassian.com/software/jira/downloads/atlassian-jira-software-8.9.1.tar.gz
3.解压安装 Jira:
tar xzf atlassian-jira-software-8.9.0.tar.gz -C /usr/local/
cd /usr/local
/bin/mv atlassian-jira-software-8.9.0-standalone/ jira
4.下载 MySQL Connector 驱动

在安装过程中如果选择使用 MySQL,连接测试时会提示 Could not find driver with class name: com.mysql.jdbc.Driver,

需要安装驱动 MySQL :: Download Connector/J

wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.49.tar.gz
/bin/cp mysql-connector-java-5.1.49/ysql-connector-java-5.1.49.jar /usr/local/jira/atlassian-jira/WEB-INF/lib/
rm -rf mysql-connector-java-5.1.49/
5.复制破解文件,这里暂时不提供破解补丁文件
/bin/cp atlassian-agent.jar /usr/local/jira/atlassian-agent.jar
sed -i 's@export JAVA_OPTS@export JAVA_OPTS="-javaagent:/usr/local/jira/atlassian-agent.jar ${JAVA_OPTS}"@' /usr/local/jira/bin/setenv.sh
6.优化配置 jira 文件
rm -rf /usr/local/jira/{NOTICE,licenses,README.html,README.md,README.txt,BUILDING.txt,tomcat-docs,CONTRIBUTING.md}
rm -rf /usr/local/jira/bin/{*.bat,tomcat8.exe,tomcat8.exe.x64,tomcat8w.exe}
chmod +x /usr/local/jira/bin/*.sh
/bin/cp /usr/local/jira/conf/server.xml{,_bk}
7.server.xml
cat > /usr/local/jira/conf/tomcat.xml << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!-- 优化配置 -->
<Server port="28005" shutdown="SHUTDOWN">
    <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
    <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
    <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
    <Listener className="org.apache.catalina.core.AprLifecycleListener" />

    <!-- <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="8081"
         rmiServerPortPlatform="8082" />
    -->

    <GlobalNamingResources>
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved"
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                  pathname="conf/tomcat-users.xml" />
    </GlobalNamingResources>

    <!--<Connector port="8081" 两个tomcat-->
    <!--connectionTimeout="20000"-->
    <!--processorCache="1000"-->
    <!--acceptCount="5000"-->
    <!--acceptorThreadCount="8"#根据实际cpu核数配置-->
    <!--maxThreads="2000"-->
    <!--minSpareThreads="100"-->
    <!--socket.appReadBufSize="1024"-->
    <!--socket.appWriteBufSize="1024"-->
    <!--socket.bufferPool="1000"-->
    <!--catalina.sh  tomcat启动文件,根据实际情况做调整,-XX:NewRatio用于配置老生代与新生代的比例-->
    <!--增加JAVA_OPTS="-server -Xms1048m -Xmx3072m -Xss1024K -XX:PermSize=64m -XX:MaxPermSize=128m XX:NewRatio=4"-->
    <!--compression="on"设置TOMCAT启用GZIP压缩-->
    <!--compressionMinSize="60" 启用压缩的输出内容大小,默认为2KB -->
    <!--noCompressionUserAgents="gozilla, traviata" 对于以下的浏览器,不启用压缩 -->
    <!--compressableMimeType="text/html,text/xml,text/plain,application/x-javascript,text/css,text/javascript,application/json" 哪些资源类型需要压缩-->

    <Service name="Catalina">
        <Connector port="8080" protocol="org.apache.coyote.http11.Http11AprProtocol"
                   server="nginx/1.1.18"
                   connectionTimeout="30000"
                   redirectPort="20443"
                   maxThreads="1024"
                   minSpareThreads="512"
                   maxHttpHeaderSize="65536"
                   maxSpareThreads="1024"
                   useBodyEncodingForURI="true"
                   enableLookups="false"
                   acceptCount="1000"
                   disableUploadTimeout="true"
                   compression="on"
                   compressionMinSize="2048"
                   debug="0" processorCache="1000"
                   {#tomcat8中URI不支持特殊字符解决#}
                   relaxedPathChars='[]|'
                   relaxedQueryChars='[]:|{}^\`"<>'
                   noCompressionUserAgents="gozilla, traviata"
                   compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain,application/json"
                   URIEncoding="UTF-8" />

        <Engine name="Catalina" defaultHost="localhost">
            <Realm className="org.apache.catalina.realm.LockOutRealm">
                <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                       resourceName="UserDatabase"/>
            </Realm>

            <!--unpackWARs="false" autoDeploy="false" 默认Tomcat 关闭对war包的热部署-->
            <Host name="localhost"  appBase="webapps"
                  unpackWARs="true" autoDeploy="true">
                <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                       prefix="localhost_access_log" suffix=".log"
                       pattern="%h %l %u %t "%r" %s %b" />
                <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For"
                       protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https" />
            </Host>

        </Engine>
    </Service>
</Server>
8. tomcat-users.xml
cat > /usr/local/jira/conf/tomcat-users.xml << EOF
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users xmlns="http://tomcat.apache.org/xml"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://tomcat.apache.org/xml tomcat-users.xsd"
              version="1.0">
    <role rolename="admin-gui"/>
    <role rolename="admin-script"/>
    <role rolename="manager-gui"/>
    <role rolename="manager-status"/>
    <role rolename="manager-script"/>
    <role rolename="manager-jms"/>
    <user username="admin" password="ad97b335c5" roles="admin-gui,admin-script,manager-gui,manager-status,manager-script,manager-jms"/>
</tomcat-users>
EOF
9.修改数据存放目录,请根据自己实际情况修改
mkdir -p /data/logs/jiralogs /data/jira       # 设置权限
chown jira.jira -R /data/logs/jiralogs /data/jira
sed -i "s@^jira.home =.*@jira.home = /data/jira@" /usr/local/jira/atlassian-jira/WEB-INF/classes/jira-application.properties
10.修改 jira 默认日志 catalina.out 的路径 215 行
sed -i "s#AsyncFileHandler.directory = .*#AsyncFileHandler.directory = /data/logs/jiralogs#g" /usr/local/jira/conf/logging.properties
11.隐藏tomcat版本信息
cd /usr/local/jira/lib/
/bin/cp ../catalina.jar ../catalina.jar_bak
sed -i 's@^server.info=.*@server.info=Openresty@' org/apache/catalina/util/ServerInfo.properties
sed -i 's@^server.number=.*@server.number=1.15.8.3@' org/apache/catalina/util/ServerInfo.properties
sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties
jar cf ../catalina.jar ./*
12.修改 Tomcat Connector 运行模式为 Apr
wget http://archive.apache.org/dist/apr/apr-1.7.0.tar.gz
tar xzf apr-1.7.0.tar.gz > /dev/null
pushd apr-1.7.0 > /dev/null
./configure --prefix=/usr/local/apr
make -j 2 && make install
popd > /dev/null
rm -rf apr-1.7.0

pushd /usr/local/jira/bin > /dev/null 2>&1
tar xzf tomcat-native.tar.gz
pushd tomcat-native-*-src/native > /dev/null 2>&1
./configure --with-apr=${arp_install_dir}

四、 启动&关闭 JIRA

使用普通用户jira启动和停止
cd /usr/local/jira/
启动:
[jira_home]/bin/start-jira.sh
停止:
[jira_home]/bin/stop-jira.sh
防火墙
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload

img

1.验证是否配置成功

执⾏行行类似命令: ps aux|grep java 找到对应的进程看看-javaagent 参数是否正确附上

ps -aux|grep javaagent

img

2.查看启动日志

catclina.out 日志内应该能找到下面显示内容,确认已经配置好 agent

img

五、 使用反向代理访问 Jira

在安装完 Nginx 后,可以增加以下配置:

server {
    listen       80;
    server_name  jira.fooher.com;
    client_max_body_size 60M;
    client_body_buffer_size 512k;
    location / {
        proxy_pass
        http://127.0.0.1:8080;
        proxy_redirect   off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

使用 systemctl restart nginx 重启 Nginx 查看结果,配置完成后可以直接省略端口

六、 使用 http://jira.fooher.com 访问

1.安装jira

img

img

img

点击测试数据库连接, 查看是否能连接数据库, 如果连接成功,需要您多等1到3分钟,大约需要创建255表
img

img

img

2.使⽤用KeyGen

当你试着执⾏行行java -jar /path/to/atlassian-agent.jar 时应该可以看到输出的KeyGen参数帮助。
请仔细看看每个参数的作⽤用,特别是-p 参数的取值范围。
第三⽅方插件将其应⽤用密钥作为-p 参数。如: -p com.gliffy.integration.confluence
在Atlassian服务安装时你应该能看到类似: AAAA-BBBB-CCCC-DDDD 的 server id,请留留意。
提供了了正确的参数运⾏行行KeyGen会在终端输出计算好的激活码。
将⽣生成的激活码复制出来去激活你要使⽤用的服务。

Jira8.x版本破解生成密钥方法:

java -jar atlassian-agent.jar -p jira -m service@fooher.com -n jirfan -o http://jira.fooher.com -s B60H-6CE7-0HUL-H9NM

img

img

img

img

img

img

img

img

img

img

img

七、备份

注意:xml备份时不保证XML备份一致,因为在备份过程中可能会更新数据库。当生成具有不一致性的XML备份时,Jira不会报告任何警告或错误消息,并且此类XML备份将在还原过程中失败。在Jira处于活动状态时,本机数据库备份工具提供了更加一致和可靠的存储(和恢复)数据的方法。
jira的xml备份和confluence不同,不是完整备份
我目前采用的是【xml备份不包含附件】+【附件备份+数据库备份+家目录备份】两种方式共同使用。

#!/bin/bash

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
clear
webserver_dir=$(dirname "`readlink -f $0`")
pushd ${webserver_dir} > /dev/null
# jira备份脚本
remote_IP=192.168.20.200
LogFile=/data/logs/jiralogs/jira-backup.log

##jira将xml备份(不包含附件)到 200 远程机器上,并将log输出到 /data/logs/jiralogs/jira-backup.log中
jira_dir=/data/jira/export
jira_remote=/backup/atlassian/jira/
jiraBegin=`date +"%Y-%m-%d %H:%M:%S"`
/usr/bin/rsync -avz --progress $jira_dir root@$remote_IP:$jira_remote
jiraEnd=`date +"$%Y-%m-%d %H:%M:%S"`
echo jira_backup_start:$jiraBegin end:$jiraEnd  >> $LogFile

##jira 将附件备份到 200 远程机器上,并将log输出到 jira-backup.log中
jira_dir_a=/data/jira/data/attachments
jira_remote_a=/backup/attachments/jira/
jira_a_Begin=`date +"%Y-%m-%d %H:%M:%S"`
/usr/bin/rsync -avz --progress $jira_dir_a root@$remote_IP:$jira_remote_a
jira_a_End=`date +"$%Y-%m-%d %H:%M:%S"`
echo jira_backup_start:$jira_a_Begin end:$jira_a_End  >> $LogFile

##jira将数据库备份到 200 远程机器上,并将log输出到jira-backup.log中
jira_dir_pg=/backup/pgBackup/jira/
jira_remote_pg=/backup/database/jira/
jira_pg_Begin=`date +"%Y-%m-%d %H:%M:%S"`
/usr/bin/rsync -avz --progress $jira_dir_pg root@$remote_IP:$jira_remote_pg
jira_pg_End=`date +"$%Y-%m-%d %H:%M:%S"`
echo wiki_backup_start:$jira_pg_Begin end:$jira_pg_End  >> $LogFile

九、备份找回JIRA中管理员密码

JIRA 忘记 admin 密码的恢复方法-- 更改密码为 123456789

mysql -uroot -p"转载请注明来源地址,fooher.com" -e "update cwd_user set credential='x6KBlJr12zeLIvjpb7URV7gMIEjnMO6wJ48UOn7d4D2tc8bbKx/3zkKO7H7v4Nsg' where user_name='admin';"

十、配置好jira的邮件

Jira首次登陆后,同样要配置好jira的邮件发送功能,用于创建用户/邀请用户、发送通知等。
依次点击右上角设置图标的"系统"->"电邮"->"外发邮件"
img

img

img

img

img

img

接着还可以再设置"接收邮件"功能

img

img

img

这样邮件功能就设置完成了,然后就可以使用邮件方式邀请用户或创建用户以及分享、通知等。
---------------------------------------------------------------------------------------------

到此 jira8 软件的安装破解工作就已经基本完成了,后续再介绍confluence连接jira,及其对接LDAP的操作记录。

*** 当你发现自己的才华撑不起野心时,就请安静下来学习吧!**