JIRA 7.13.0 實踐筆記
JIRA 7.13.0 實踐筆記
jira有以下幾種安裝方式:
-
Docker容器部署
-
K8s helm部署
-
k8s 部署
-
直接安裝
其中helm安裝:ofollow,noindex" target="_blank">helm安裝 ,下面詳細介紹容器部署。
映象構建配置
Jira容器構建準備
破解檔案下載:jira7.2_hack.zip
git clone https://github.com/cptactionhank/docker-atlassian-jira-software cd docker-atlassian-jira-software cp atlassian-extras-3.2.jar atlassian-universal-plugin-manager-plugin-2.22.9.jar ./
定義 setenv.sh
修改預設使用jvm記憶體(將記憶體引數以變數傳遞給容器外部呼叫): vim setenv.sh
# # One way to set the JIRA HOME path is here via this variable.Simply uncomment it and set a valid path like /jira/home.You can of course set it outside in the command terminal.That will also work. # #JIRA_HOME="" # #Occasionally Atlassian Support may recommend that you set some specific JVM arguments.You can use this variable below to do that. # JVM_SUPPORT_RECOMMENDED_ARGS="" # # The following 2 settings control the minimum and maximum given to the JIRA Java virtual machine.In larger JIRA instances, the maximum amount will need to be increased. # JVM_MINIMUM_MEMORY=${JVM_XMS:-384m} JVM_MAXIMUM_MEMORY=${JVM_XMX:-768m} # # The following setting configures the size of JVM code cache.A high value of reserved size allows Jira to work with more installed apps. # JVM_CODE_CACHE_ARGS='-XX:InitialCodeCacheSize=32m -XX:ReservedCodeCacheSize=512m' # # The following are the required arguments for JIRA. # JVM_REQUIRED_ARGS='-Djava.awt.headless=true -Datlassian.standalone=JIRA -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dmail.mime.decodeparameters=true -Dorg.dom4j.factory=com.atlassian.core.xml.InterningDocumentFactory' # Uncomment this setting if you want to import data without notifications # #DISABLE_NOTIFICATIONS=" -Datlassian.mail.senddisabled=true -Datlassian.mail.fetchdisabled=true -Datlassian.mail.popdisabled=true" #----------------------------------------------------------------------------------- # # In general don't make changes below here # #----------------------------------------------------------------------------------- #----------------------------------------------------------------------------------- # Prevents the JVM from suppressing stack traces if a given type of exception # occurs frequently, which could make it harder for support to diagnose a problem. #----------------------------------------------------------------------------------- JVM_EXTRA_ARGS="-XX:-OmitStackTraceInFastThrow" PRGDIR=`dirname "$0"` cat "${PRGDIR}"/jirabanner.txt JIRA_HOME_MINUSD="" if [ "$JIRA_HOME" != "" ]; then echo $JIRA_HOME | grep -q " " if [ $? -eq 0 ]; then echo "" echo "--------------------------------------------------------------------------------------------------------------------" echo "WARNING : You cannot have a JIRA_HOME environment variable set with spaces in it.This variable is being ignored" echo "--------------------------------------------------------------------------------------------------------------------" else JIRA_HOME_MINUSD=-Djira.home=$JIRA_HOME fi fi JAVA_OPTS="-Xms${JVM_MINIMUM_MEMORY} -Xmx${JVM_MAXIMUM_MEMORY} ${JVM_CODE_CACHE_ARGS} ${JAVA_OPTS} ${JVM_REQUIRED_ARGS} ${DISABLE_NOTIFICATIONS} ${JVM_SUPPORT_RECOMMENDED_ARGS} ${JVM_EXTRA_ARGS} ${JIRA_HOME_MINUSD} ${START_JIRA_JAVA_OPTS}" export JAVA_OPTS # DO NOT remove the following line # !INSTALLER SET JAVA_HOME echo "" echo "If you encounter issues starting or stopping JIRA, please see the Troubleshooting guide at http://confluence.atlassian.com/display/JIRA/Installation+Troubleshooting+Guide" echo "" if [ "$JIRA_HOME_MINUSD" != "" ]; then echo "Using JIRA_HOME:$JIRA_HOME" fi # set the location of the pid file if [ -z "$CATALINA_PID" ] ; then if [ -n "$CATALINA_BASE" ] ; then CATALINA_PID="$CATALINA_BASE"/work/catalina.pid elif [ -n "$CATALINA_HOME" ] ; then CATALINA_PID="$CATALINA_HOME"/work/catalina.pid fi fi export CATALINA_PID if [ -z "$CATALINA_BASE" ]; then if [ -z "$CATALINA_HOME" ]; then LOGBASE=$PRGDIR LOGTAIL=.. else LOGBASE=$CATALINA_HOME LOGTAIL=. fi else LOGBASE=$CATALINA_BASE LOGTAIL=. fi PUSHED_DIR=`pwd` cd $LOGBASE cd $LOGTAIL LOGBASEABS=`pwd` cd $PUSHED_DIR echo "" echo "Server startup logs are located in $LOGBASEABS/logs/catalina.out" # Set the JVM arguments used to start JIRA. For a description of the options, see # http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html #----------------------------------------------------------------------------------- # This allows us to actually debug GC related issues by correlating timestamps # with other parts of the application logs. #----------------------------------------------------------------------------------- GC_JVM_PARAMETERS="" GC_JVM_PARAMETERS="-XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintGCCause ${GC_JVM_PARAMETERS}" GC_JVM_PARAMETERS="-Xloggc:$LOGBASEABS/logs/atlassian-jira-gc-%t.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=20M ${GC_JVM_PARAMETERS}" CATALINA_OPTS="${GC_JVM_PARAMETERS} ${CATALINA_OPTS}" export CATALINA_OPTS
定義Dockerfile
FROM openjdk:8-alpine # Configuration variables. ENV JIRA_HOME/var/atlassian/jira ENV JIRA_INSTALL/opt/atlassian/jira ENV JIRA_VERSION7.13.0 # Install Atlassian JIRA and helper tools and setup initial home # directory structure. RUN set -x \ && apk add --no-cache curl xmlstarlet bash ttf-dejavu libc6-compat \ && mkdir -p"${JIRA_HOME}" \ && mkdir -p"${JIRA_HOME}/caches/indexes" \ && chmod -R 700"${JIRA_HOME}" \ && mkdir -p"${JIRA_INSTALL}/conf/Catalina" \ && curl -Ls"https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-7.13.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" \ && 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" "/" COPY atlassian-extras-3.2.jar ${JIRA_INSTALL}/atlassian-jira/WEB-INF/lib/atlassian-extras-3.2.jar COPY atlassian-universal-plugin-manager-plugin-2.22.9.jar ${JIRA_INSTALL}/atlassian-jira/WEB-INF/atlassian-bundled-plugins/atlassian-universal-plugin-manager-plugin-2.22.9.jar COPY setenv.sh ${JIRA_INSTALL}/bin/setenv.sh COPY server.xml ${JIRA_INSTALL}/conf/server.xml ENTRYPOINT ["/docker-entrypoint.sh"] # Run Atlassian JIRA as a foreground process by default. CMD ["/opt/atlassian/jira/bin/start-jira.sh", "-fg"]
定義 server.xml
自定義server.xml檔案,需求後續可以配置https訪問
<?xml version="1.0" encoding="utf-8"?> <Server port="8005" shutdown="SHUTDOWN"> <Listener className="org.apache.catalina.startup.VersionLoggerListener"/> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on"/> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/> <Service name="Catalina"> <Connector port="8080" relaxedPathChars="[]|" relaxedQueryChars="[]|{}^\`"<>" maxThreads="150" minSpareThreads="25" connectionTimeout="20000" enableLookups="false" maxHttpHeaderSize="8192" protocol="HTTP/1.1" useBodyEncodingForURI="true" redirectPort="8443" acceptCount="100" disableUploadTimeout="true" bindOnInit="false"/> <Engine name="Catalina" defaultHost="localhost"> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="${catalina.home}/atlassian-jira" reloadable="false" useHttpOnly="true"> <Resource name="UserTransaction" auth="Container" type="javax.transaction.UserTransaction" factory="org.objectweb.jotm.UserTransactionFactory" jotm.timeout="60"/> <Manager pathname=""/> <JarScanner scanManifest="false"/> </Context> </Host> <Valve className="org.apache.catalina.valves.AccessLogValve" pattern="%a %{jira.request.id}r %{jira.request.username}r %t "%m %U%q %H" %s %b %D "%{Referer}i" "%{User-Agent}i" "%{jira.request.assession.id}r""/> </Engine> </Service> </Server>
構建映象
docker build -t jira:7.13.0 .
Mysql本地安裝
yum 部署mysql
curl -LO http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm yum localinstall mysql57-community-release-el7-11.noarch.rpm yum install mysql-community-server systemctl enable mysqld systemctl start mysqld systemctl status mysqld # 檢視密碼 grep 'temporary password' /var/log/mysqld.log # 登入 SQL/">MySQL 並修改密碼 mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
配置mysql資料庫:
建立資料庫: mysql> CREATE DATABASE jiraDEFAULT CHARACTER SET utf8 COLLATE utf8_bin; 授連線次資料庫的許可權: mysql>grant all privileges on jira.* to jira@'.%' identified by 'jira'; mysql> flush privileges;
注意: jira7.13.0版本不支援utf8_general_ci的校驗規則,因此建立資料庫時必須指明utf8_bin校驗規則!!
部署映象
Docker 本地部署
docker run --publish 8080:8080 --name jira -d local-jira:7.3.8
使用docker-compose方式
構建docker-compose.yml
jira: image: jira:7.13.0 restart: always environment: - JVM_XMX=2048m - JVM_XMS=1024m ports: - '8080:8080' links: - db volumes: - ./data/jira:/var/atlassian/jira - ./data/logs:/opt/atlassian/jira/logs db: image: mysql:5.7 restart: always environment: - MYSQL_USER=jira - MYSQL_PASSWORD=jira - MYSQL_DATABASE=jira - MYSQL_ROOT_PASSWORD=jira volumes: - ./data/mysql:/var/lib/mysql
採用k8s叢集方式執行
此環境在阿里雲K8s容器平臺部署
建立pv
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: hangzhou-b-ssd parameters: cachingmode: None kind: Managed storageaccounttype: Standard_LRS provisioner: kubernetes.io/azure-disk reclaimPolicy: Delete volumeBindingMode: Immediate allowVolumeExpansion: true
建立pvc
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: jira-data spec: accessModes: - "ReadWriteOnce" resources: requests: storage: "100Gi" storageClassName: "hangzhou-b-ssd"
建立service
apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/alicloud-loadbalancer-cert-id: "cert-id" service.beta.kubernetes.io/alicloud-loadbalancer-protocol-port: "https:443,http:80" name: jira-svc namespace: default spec: ports: - port: 443 protocol: TCP targetPort: 8080 selector: app: jira-svc sessionAffinity: None type: LoadBalancer
這裡採用阿里自帶負載均衡方式部署,然後域名解析到負載均衡外網ip
建立Deployment
apiVersion: apps/v1 kind: Deployment metadata: name: jira-deployment namespace: default spec: replicas: 1 selector: matchLabels: app: jira-svc template: metadata: labels: app: jira-svc spec: containers: - name: jira-svc image: jira:7.13.0 imagePullPolicy: Always env: - name: JVM_XMX value: "2048m" - name: JVM_XMS value: "1024m" ports: - containerPort: 8080 volumeMounts: - mountPath: "/var/atlassian/jira" name: jira-data volumes: - name: jira-data persistentVolumeClaim: claimName: jira-data
部署
kubectl apply -f .
破解
首先按照安裝步驟一步一步進行,到證書授權的時候,點選申請證書,然後得到許可證,填入即可,最後在應用程式–版本和許可證,可看到技術伺服器截止日期 08/二月/33,即破解成功!(外掛破解:免費試用–獲取申請碼—填入申請碼—破解成功)
注意的問題
注意:jira外掛管理中,atlassian-universal-plugin-manager-plugin外掛絕對不要更新,否則外掛破解會失效。
補充說明:
1、外掛破解原理:
atlassian-universal-plugin-manager-plugin外掛是進行外掛管理的,只需要破解了這個外掛,剩下的所有外掛都自動破解完成了
2、如果破解不成功、外掛管理版本高於2.22.4、或者不小心更新了atlassian-universal-plugin-manager-plugin這個外掛怎麼辦?
遇到這種情況,需要到jira的安裝目錄和資料目錄下,替換掉atlassian-universal-plugin-manager-plugin相關的所有檔案。
具體操作步驟:
(1)到jira安裝目錄和資料目錄下find出所有相關檔案: (2)替換、刪除相關檔案,保險起見,可在刪除前對資料進行備份。 (3)重啟jira (4)到外掛管理中心檢視外掛授權期限,變為2099年
如何修改記憶體?
vim /opt/atlassian/jira/bin/setenv.sh
JVM_MINIMUM_MEMORY=${JVM_XMS:-384m} JVM_MAXIMUM_MEMORY=${JVM_XMX:-768m}
如何解決mysql ssl報錯?
vim /var/atlassian/jira/dbconfig.xml
<url>jdbc:mysql://address=(protocol=tcp)(host=mysql_hostname)(port=mysql_port)/jira?useUnicode=true&characterEncoding=UTF8&sessionVariables=default_storage_engine=InnoDB&useSSL=false</url>