Confluence 在线协同文档系统搭建及激活教程

Introduction

Confluence 是由澳大利亚软件公司 Atlassian 出品的一款在线文档协作平台,提供跨平台的移动客户端,可以方便地与 Jira、Google Drive 等平台进行对接,形成一个完整的敏捷开发工作流,被广泛应用于公司内部知识库的构建。作为商用软件,其授权价格不菲,但以 10 美元的价格提供 10 用户的 Starter Package,支持本地部署或云服务,且提供持续一年的维护,对于小团队来说是个很不错的选择。

同类产品有 DokuWiki。作为一款开源免费的文档解决方案,相比于 Confluence 来说界面比较简陋,扩展性也没有那么强,适合仅做内部文档用途的场景。

Installation

Environment

Confluence 版本:6.15.8

1
2
3
4
5
6
7
8
9
10
11
CPU Model      : Intel(R) Xeon(R) E-2176M  CPU @ 2.70GHz
CPU Cores : 4 Cores @ 2712.009 MHz x86_64
CPU Cache : 12288 KB
OS : Ubuntu 18.04.1 LTS (64 Bit) Hyper-V
Kernel : 4.15.0-45-generic
Total Space : 8.8 GB / 125.2 GB
Total RAM : 2740 MB / 4905 MB (1289 MB Buff)
Total SWAP : 26 MB / 2047 MB
Uptime : 0 days 1 hour 49 min
Load Average : 0.00, 0.00, 0.07
TCP CC : cubic

Step 0 Preparation

作为开发者,请支持正版软件!

Step 1 Run Installer

1
2
3
4
5
6
7
8
9
10
# 为二进制包添加可执行权限
[[email protected] ~]# chmod +x atlassian-confluence-6.15.8-x64.bin

# 执行安装
[[email protected] ~]# ./atlassian-confluence-6.15.8-x64.bin
Unpacking JRE ...
Starting Installer ...

This will install Confluence 6.15.8 on your computer.
OK [o, Enter], Cancel [c]

输入字母 o 然后回车,继续安装。

1
2
3
4
5
6
...
Choose the appropriate installation or upgrade option.
Please choose one of the following:
Express Install (uses default settings) [1],
Custom Install (recommended for advanced users) [2, Enter],
Upgrade an existing Confluence installation [3]

输入 1 并回车进行快速安装,或者输入 2 进行自定义安装以手动指定程序安装路径及数据存放目录。

1
2
3
4
5
6
7
...
Configure which ports Confluence will use.
Confluence requires two TCP ports that are not being used by any other
applications on this machine. The HTTP port is where you will access
Confluence through your browser. The Control port is used to Startup and
Shutdown Confluence.
Use default ports (HTTP: 8090, Control: 8000) - Recommended [1, Enter], Set custom value for HTTP and Control ports [2]

默认 HTTP 端口为 8090,Tomcat 管理端口为 8000。关于 Atlassian 产品的端口使用说明可以参考 Ports used by Atlassian

1
2
3
4
5
6
...
Confluence can be run in the background.
You may choose to run Confluence as a service, which means it will start
automatically whenever the computer restarts.
Install Confluence as Service?
Yes [y, Enter], No [n]

回车,继续安装。

1
2
3
4
5
6
7
...
Extracting files ...
Please wait a few moments while we configure Confluence.

Installation of Confluence 6.15.8 is complete
Start Confluence now?
Yes [y, Enter], No [n]

输入 n,暂时不运行 Confluence 服务。

1
2
Installation of Confluence 6.15.8 is complete
Finishing installation ...

当看到上述文字时,Confluence 服务已经安装完成了,接下来需要进行进一步配置与产品激活。

Step 2 Patch

将下载得到的 atlassian-agent.jar 补丁文件上传至服务器的一个固定位置,演示时我将其放在了 /opt/atlassian 目录下。

1
scp atlassian-agent.jar [USER]@[SERVER_HOSTNAME]:/opt/atlassian/

然后修改 Confluence 的启动环境变量文件(位于 Confluence 安装目录下的 bin/setenv.sh),添加一行 CATALINA_OPTS="-javaagent:/opt/atlassian/atlassian-agent.jar ${CATALINA_OPTS}"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
...
# http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html
CATALINA_OPTS="-javaagent:/opt/atlassian/atlassian-agent.jar ${CATALINA_OPTS}" # 这是新增的

CATALINA_OPTS="-XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution ${CATALINA_OPTS}"
CATALINA_OPTS="-Xloggc:$LOGBASEABS/logs/gc-`date +%F_%H-%M-%S`.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M ${CATALINA_OPTS}"
CATALINA_OPTS="-XX:G1ReservePercent=20 ${CATALINA_OPTS}"
CATALINA_OPTS="-Djava.awt.headless=true ${CATALINA_OPTS}"
CATALINA_OPTS="-Datlassian.plugins.enable.wait=300 ${CATALINA_OPTS}"
CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:+UseG1GC ${CATALINA_OPTS}"
CATALINA_OPTS="-Dsynchrony.enable.xhr.fallback=true ${CATALINA_OPTS}"
CATALINA_OPTS="-Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 ${CATALINA_OPTS}"
CATALINA_OPTS="${START_CONFLUENCE_JAVA_OPTS} ${CATALINA_OPTS}"
CATALINA_OPTS="-Dconfluence.context.path=${CONFLUENCE_CONTEXT_PATH} ${CATALINA_OPTS}"
CATALINA_OPTS="-XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing ${CATALINA_OPTS}"

export CATALINA_OPTS

随后将 MySQL JDBC 驱动上传至 Confluence 安装目录的 confluence/WEB-INF/lib/ 路径下。

Step 3 Check

接下来,我们运行 Confluence 服务,并查看补丁是否安装成功。

1
2
3
4
# 启动 Confluence 服务
service confluence start
# 查看 Confluence 日志
tail -f /opt/atlassian/confluence/logs/catalina.out

当在日志中发现 agent working 字段时,即意味着补丁已经正确安装并运行。

1
2
3
29-Aug-2019 13:52:37.568 INFO [Catalina-utility-2] org.springframework.context.support.DefaultLifecycleProcessor.start Starting beans in phase 2147483647
29-Aug-2019 13:52:37.583 INFO [Catalina-utility-2] org.springframework.web.servlet.DispatcherServlet.initServletBean FrameworkServlet 'dispatcher': initialization completed in 860 ms
============================== agent working ==============================

Step 4 Configuration

接下来我们将对 Confluence 进行初始化配置。访问 http://[SERVER_IP]:8090/ 进入安装向导,如果页面语言为英文,可以通过页面右上角下拉框进行切换。当进行至输入 License 步骤时,将页面上方格式为 XXXX-XXXX-XXXX-XXXX 的服务器 ID 复制,随后手动执行补丁以获取序列号。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 查看帮助信息
$ java -jar atlassian-agent.jar

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

KeyGen usage: java -jar /opt/atlassian/atlassian-agent.jar [-d] [-h] -m <arg> [-n <arg>] -o <arg> -p <arg> -s <arg>

-d,--datacenter Data center license[default: false]
-h,--help Print help message
-m,--mail <arg> License email
-n,--name <arg> License name[default: <license email>]
-o,--organisation <arg> License organisation
-p,--product <arg> License product, support:
[crowd: Crowd]
[questions: Questions plugin for Confluence]
[crucible: Crucible]
[capture: Capture plugin for JIRA]
[conf: Confluence]
[training: Training plugin for JIRA]
[*: Third party plugin key, looks like:
com.foo.bar]
[bitbucket: Bitbucket]
[tc: Team Calendars plugin for Confluence]
[bamboo: Bamboo]
[fisheye: FishEye]
[portfolio: Portfolio plugin for JIRA]
[jc: JIRA Core]
[jsd: JIRA Service Desk]
[jira: JIRA Software(common jira)]
-s,--serverid <arg> License server ID

================================================================================

# Crack agent usage: append -javaagent arg to system environment: JAVA_OPTS.
# Example(execute this command or append it to setenv.sh/setenv.bat file):

export JAVA_OPTS="-javaagent:/opt/atlassian/atlassian-agent.jar ${JAVA_OPTS}"

# Then start your confluence/jira server.
1
2
# 生成 Confluence License
java -jar /home/confluence/atlassian/atlassian-agent.jar -p conf -m [EMAIL] -n [NAME] -o [ORGANIZATION] -s [SERVER_ID]

将补丁生成的 License 拷贝,粘贴至页面,即可进行后续的数据库配置步骤。

FAQ

  1. The database collation utf8_general_ci is not supported by Confluence. You need to use utf8_bin.

    Confluence 必须使用 utf8_bin 字符集的 MySQL 数据库,而 MySQL 默认数据库字符集为 utf8_general_ci,可以通过以下命令解决。

    1
    2
    DROP DATABASE [DB_NAME] # 删除之前错误创建的数据库
    CREATE DATABASE [DB_NAME] CHARACTER SET utf8 COLLATE utf8_bin # 创建字符集为 utf8_bin
  2. 新建页面模板的中文字符串显示乱码。

    这是因为 MySQL 默认的字符集为 Latin1,需要将其修改为 utf8。修改 MySQL 配置文件如下,并重启 MySQL 服务即可解决。

    1
    2
    [mysqld]
    character-set-server = utf8 # 指定默认 Server 级字符集为 utf8
  3. Your database must use READ-COMMITTED as the default isolation level.

    Confluence 要求使用 READ-COMMITTED 作为 MySQL 默认的事务隔离级别,修改 MySQL 配置文件如下并重启 MySQL 服务即可。

    1
    2
    [mysqld]
    transaction_isolation = READ-COMMITTED

  1. 1.Confluence 安装及破解 - qinjj 的博客 https://www.qinjj.tech/2019/01/04/confluence%20install/
  2. 2.Confluence 中文乱码解决思路和方法 http://moheqionglin.com/site/blogs/26/detail.html