Confluence docker镜像地址:https://hub.docker.com/r/atlassian/confluence-server ,当前最新tag为7.3.1

安装Postgres

  1. docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=123456 --restart=always postgres

创建数据库:

  1. docker exec -it postgres psql -Upostgres -w -c "CREATE DATABASE confluence WITH OWNER postgres;"

如果是重装,则需要重建数据库:

  1. REVOKE CONNECT ON DATABASE confluence FROM public;
  2. SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname='confluence' AND pid<>pg_backend_pid();
  3. drop database confluence;

Docker安装

官方镜像安装

直接使用官方镜像安装:

  1. docker run -d \
  2. --name confluence \
  3. -p 8090:8090 -p 8091:8091 \
  4. -v /data/docker/confluence:/var/atlassian/application-data/confluence \
  5. --restart=always \
  6. atlassian/confluence-server:7.3.1

参数配置

常用参数配置Confluece:

  • JVM参数:
  • JVM_MINIMUM_MEMORY:默认1024M
  • JVM_MAXIMUM_MEMORY:默认1024M
  • JVM_RESERVED_CODE_CACHE_SIZE:默认256M
  • JVM_SUPPORT_RECOMMENDED_ARGS:额外设置,例如设置证书:-Djavax.net.ssl.trustStore=/var/atlassian/application-data/confluence/cacerts
  • 代理设置:
  • ATL_PROXY_NAME
  • ATL_PROXY_PORT
  • ATL_TOMCAT_PORT
  • ATL_TOMCAT_SCHEME
  • ATL_TOMCAT_SECURE
  • ATL_TOMCAT_CONTEXTPATH
  • ATL_TOMCAT_ACCESS_LOG

    破解

    https://gitee.com/pengzhile/atlassian-agent 下载破解文件,然后将破解文件拷贝到容器:
    1. wget https://github.com/javachen/dockerfiles/raw/master/confluence/atlassian-agent.jar
    2. docker cp atlassian-agent.jar confluence:/opt/atlassian/confluence/
    3. docker exec -it confluence bash
    4. echo 'export CATALINA_OPTS="-Duser.timezone=GMT+08 -javaagent:/opt/atlassian/confluence/atlassian-agent.jar ${CATALINA_OPTS}"' \
    5. >> /opt/atlassian/confluence/bin/setenv.sh
    6. docker restart confluence
    或者直接编译到镜像,Dockerfile:
    1. FROM atlassian/confluence-server:7.3.1
    2. #ADD http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.tar.gz /opt/atlassian/jira/lib/
    3. #COPY mysql-connector-java-5.1.30-bin.jar /opt/atlassian/confluence/confluence/WEB-INF/lib
    4. COPY "atlassian-agent.jar" /opt/atlassian/confluence/
    5. RUN apt-get update && apt-get install tzdata \
    6. && ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo Asia/Shanghai >/etc/timezone \
    7. && dpkg-reconfigure --frontend noninteractive tzdata \
    8. && echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/confluence/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh
    构建镜像:
    1. docker build -t javachen/confluence-server:7.3.1 .
    2. docker push javachen/confluence-server:7.3.1
    获取license:
    1. # Confluence
    2. java -jar atlassian-agent.jar -p conf -m junecloud@163.com -n junecloud \
    3. -o http://javachen.com -s BLYI-OHFJ-KTJN-M6C9
    4. # Confluence Questions
    5. java -jar atlassian-agent.jar -p questions -m junecloud@163.com -n junecloud \
    6. -o http://javachen.com -s BOYX-UEMX-WRLS-MKBW
    7. # 团队日程表
    8. java -jar atlassian-agent.jar -p tc -m junecloud@163.com -n junecloud \
    9. -o http://javachen.com -s BOYX-UEMX-WRLS-MKBW

    安装破解版镜像

    1. docker run -d \
    2. --name confluence \
    3. -p 8090:8090 -p 8091:8091 \
    4. -v /data/docker/confluence:/var/atlassian/application-data/confluence \
    5. --restart=always \
    6. javachen/confluence-server:7.3.1
    检查时区是否设置正确:
    1. $ docker exec -it confluence date
    2. Wed Apr 29 00:43:11 CST 2020

    K8s安装

    创建命名空间和证书:
    1. kubectl create namespace confluence
    2. cat << EOF | kubectl create -f -
    3. apiVersion: cert-manager.io/v1alpha2
    4. kind: Certificate
    5. metadata:
    6. name: confluence-test-wesine-com-cn-cert
    7. namespace: confluence
    8. spec:
    9. secretName: confluence-test-wesine-com-cn-cert
    10. renewBefore: 720h
    11. dnsNames:
    12. - "*.javachen.xyz"
    13. - "*.test.javachen.xyz"
    14. issuerRef:
    15. name: cert-manager-webhook-dnspod-cluster-issuer
    16. kind: ClusterIssuer
    17. EOF
    cert-manager-webhook-dnspod-cluster-issuer是提前创建好的cluster-issuer。
    下载chart文件:
    1. git clone https://github.com/javachen/charts/charts/
    2. cd charts
    创建 confluence-values.yaml文件: ``` cat < confluence-values.yaml image: repository: javachen/confluence-server:7.3.1 ingress: enabled: true annotations: kubernetes.io/ingress.class: nginx nginx.ingress.kubernetes.io/ssl-redirect: “true” nginx.ingress.kubernetes.io/proxy-body-size: 100m hosts:
    • confluence.javachen.xyz
    • confluence.test.javachen.xyz tls:
    • secretName: confluence-test-wesine-com-cn-cert hosts:
      • confluence.javachen.xyz
      • confluence.test.javachen.xyz env:
        • name: TZ value: Asia/Shanghai
        • name: JVM_MINIMUM_MEMORY value: “3072m”
        • name: JVM_MAXIMUM_MEMORY value: “4096m”
        • name: ATL_PROXY_NAME value: confluence.test.javachen.xyz
        • name: ATL_PROXY_PORT value: “443”
        • name: ATL_TOMCAT_SCHEME value: “https”

persistence: enabled: true storageClass: “ceph-rbd” accessMode: ReadWriteOnce size: 20Gi EOF

  1. 使用helm3安装:
  2. ```bash
  3. helm install confluence -n confluence -f confluence-values.yaml ./confluence
  4. helm install confluence -f confluence-values.yaml ./confluence

卸载:

  1. helm del confluence -n confluence

安装个人偏好的插件:RefinedToolki

备份

  1. current_date=`date "+%Y_%m_%d" -d today`
  2. echo $current_date
  3. mkdir -p /data/backup/confluence
  4. #备份数据库
  5. docker exec -it postgres pg_dump -U postgres -d confluence -f confluence-${current_date}.sql
  6. docker cp postgres:/confluence-${current_date}.sql /data/backup/confluence/
  7. #备份confluence
  8. pod=$(kubectl get pod --output=name -n confluence |awk -F '/' '{print $2}')
  9. echo $pod
  10. #kubectl exec -it $pod -n confluence -- bash
  11. kubectl cp confluence/$pod:/var/atlassian/application-data/confluence/backups/backup-${current_date}.zip /data/backup/confluence/backup-${current_date}.zip

其他问题

异常

1、confluence ip变更之后,登陆失败,日志提示异常

  1. ApplicationPermissionException: Forbidden (403) Encountered a "403 - Forbidden" error while loading

参考:https://community.atlassian.com/t5/Confluence-questions/ApplicationPermissionException-Forbidden-403-Encountered-a-quot/qaq-p/667228
解决办法:

  • K8s中,通过env环境变量设置 JVM_MAXIMUM_MEMORY 值为 4096m -Datlassian.recovery.password=admin
  • 改用ldap目录

    Confluenc宏乱码解决

    1、方法1:下载中文编码:

    1. wget https://mirror.shileizcc.com/wiki_Resources/Confluence/chinses.tar.gz
    2. tar zxf chinses.tar.gz

    dockerfile

    1. FROM atlassian/confluence-server:7.5.0-m62-ubuntu
    2. # 将代理破解包加入容器
    3. COPY "atlassian-agent.jar" /opt/atlassian/confluence/
    4. COPY ./chinses/ /usr/share/fonts/truetype/chinses
    5. RUN chmod 644 /usr/share/fonts/truetype/chinese/* \
    6. && fc-cache -fv \
    7. && echo 'CATALINA_OPTS="-Dconfluence.document.conversion.fontpath=/usr/share/fonts/truetype ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh \
    8. && echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/confluence/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh

    2、方法2:

    1. FROM atlassian/confluence-server:7.5.0-m62-ubuntu
    2. # 安装微软字体并设置启动加载代理包
    3. RUN apt-get update \
    4. && apt-get install ttf-mscorefonts-installer \
    5. && echo 'export CATALINA_OPTS="-Dconfluence.document.conversion.fontpath=/usr/share/fonts/truetype/msttcorefonts ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh \
    6. && echo 'export CATALINA_OPTS="-javaagent:/opt/atlassian/confluence/atlassian-agent.jar ${CATALINA_OPTS}"' >> /opt/atlassian/confluence/bin/setenv.sh

    修改忘记密码链接

    参考 https://confluence.atlassian.com/doc/confluence-installation-and-upgrade-guide-214864161.html

    参考文章

  • 使用Docker部署Confluence

  • confluence 安装及破解 install/)
  • https://gitee.com/pengzhile/atlassian-agent