首先將線上環境中的 confluence 安裝目錄、數據目錄以及數據庫進行備份,相關信息以下:html
具體升級過程以下:java
因爲公司 confluence 服務 4.2 版本安裝時,將應用程序目錄移動至 webapps 目錄下,致使升級時會沒法識別到安裝路徑,因此須要修改應用程序路徑,步驟以下:mysql
首先中止 confluence 服務,將 webapps 目錄下的 wiki 目錄移動到安裝目錄的根目錄下,並重命名爲 confluence:nginx
mv /opt/atlassian/confluence/webapps/wiki /opt/atlassian/confluence/confluence
修改 server.xml 文件,將 docBase 修改成以下內容:web
<Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true">
修改完成後從新啓動 confluence 服務驗證訪問,此時直接輸入 IP:端口 便可sql
/opt/atlassian/confluence/bin/startup.sh
因爲公司當前使用的 confluence 服務的數據庫字符集爲 utf8,而且未指定排序方式。爲了保證後面跨版本升級時新的數據庫結構可以正常同步,首先須要對數據庫中的默認字符集和排序方式進行修改,修改步驟以下:數據庫
SET FOREIGN_KEY_CHECKS=0;
ALTER DATABASE confluence_smc CHARACTER SET utf8 COLLATE utf8_bin;
SELECT CONCAT('ALTER TABLE `', table_name, '` CHARACTER SET utf8 COLLATE utf8_bin;') FROM information_schema.TABLES AS T, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY` AS C WHERE C.collation_name = T.table_collation AND T.table_schema = 'confluence_smc' AND ( C.CHARACTER_SET_NAME != 'utf8' OR C.COLLATION_NAME != 'utf8_bin' );
上面的命令執行完成後會生成修改全部表的 sql 語句,將這些 sql 複製到數據庫內執行便可完成修改apache
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, '(', CHARACTER_MAXIMUM_LENGTH, ') CHARACTER SET utf8 COLLATE utf8_bin', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';') FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'confluence_smc' AND DATA_TYPE = 'varchar' AND ( CHARACTER_SET_NAME != 'utf8' OR COLLATION_NAME != 'utf8_bin' );
上面的命令執行完成後會生成修改全部相關字段的 sql 語句,將這些 sql 複製到數據庫內執行便可完成修改tomcat
SELECT CONCAT('ALTER TABLE `', table_name, '` MODIFY `', column_name, '` ', DATA_TYPE, ' CHARACTER SET utf8 COLLATE utf8_bin', (CASE WHEN IS_NULLABLE = 'NO' THEN ' NOT NULL' ELSE '' END), ';') FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = 'confluence_smc' AND DATA_TYPE != 'varchar' AND ( CHARACTER_SET_NAME != 'utf8' OR COLLATION_NAME != 'utf8_bin' );
上面的命令執行完成後會生成修改全部相關字段的 sql 語句,將這些 sql 複製到數據庫內執行便可完成修改bash
SET FOREIGN_KEY_CHECKS=1;
檢查數據庫的配置文件,在 [mysqld] 下面添加以下配置項:
character-set-server=utf8 collation-server=utf8_bin default-storage-engine=INNODB max_allowed_packet=256M max_connections=1000 innodb_log_file_size=2GB transaction-isolation=READ-COMMITTED binlog_format=row
若是當前數據庫中只有 confluence 一個業務,能夠參考如上配置,若是有其餘業務共用,爲了不影響其餘業務,能夠考慮將字符集和引擎設置忽略(可在程序鏈接數據庫時在 jdbc 鏈接中指定)。
若是數據庫配置文件中有以下配置,須要將其刪除,不然會引起報錯。若是還開啓了其餘的 sql_mode ,只須要刪除 NO_AUTO_VALUE_ON_ZERO 便可:
sql_mode = NO_AUTO_VALUE_ON_ZERO
若是開啓了 NO_AUTO_VALUE_ON_ZERO
則會引起以下報錯內容:
2020-08-14 09:26:06,520 ERROR [http-8090-4] [atlassian.event.internal.EventPublisherImpl] invokeListeners There was an exception thrown trying to dispatch event 'com.atlassian.confluence.event.events.content.comment.CommentCreateEvent[source=com.atlassian.confluence.pages.DefaultCommentManager@4b077b33]' from the invoker 'com.atlassian.event.internal.SingleParameterMethodListenerInvoker@25695aa2'. -- url: /rest/tinymce/1/content/524379/comment | userName: admin| referer: http://<confluence-url>/pages/viewpage.action?pageId=524379 java.lang.RuntimeException: java.lang.reflect.UndeclaredThrowableException at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:50) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$2.run(AsynchronousAbleEventDispatcher.java:60) at com.atlassian.event.internal.AsynchronousAbleEventDispatcher$1.execute(AsynchronousAbleEventDispatcher.java:28) ..... Caused by: java.lang.reflect.UndeclaredThrowableException at $Proxy943.createOrUpdate(Unknown Source) at sun.reflect.GeneratedMethodAccessor1033.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ..... Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.GeneratedMethodAccessor1033.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at com.atlassian.mywork.client.service.ServiceSelectorImpl$3.invoke(ServiceSelectorImpl.java:144) ... 235 more Caused by: java.lang.NullPointerException at net.java.ao.EntityManager$CacheKey.hashCode(EntityManager.java:1070) at java.util.HashMap.getEntry(Unknown Source) at java.util.LinkedHashMap.get(Unknown Source) at net.java.ao.EntityManager.getFromCache(EntityManager.java:247) at net.java.ao.EntityManager.peer(EntityManager.java:234) at net.java.ao.EntityManager.peer(EntityManager.java:299) at net.java.ao.EntityManager.create(EntityManager.java:411) ......
配置完成後重啓數據庫服務。
confluence 數據庫配置文件存儲在 confluence 家目錄下,文件名稱爲 confluence.cfg.xml,將其中的 hibernate.connection.url 配置項進行修改:
<property name="hibernate.connection.url">jdbc:mysql://IP:3306/confluence_smc?sessionVariables=storage_engine%3DInnoDB</property> <!-- 將以上內容修改成以下( 添加&useUnicode=true&characterEncoding=utf8 )--> <!-- 添加這部份內容是因爲數據庫中字符集和排序已經修改成 utf8,若是不添加這部分配置會致使升級 5.x 版本時沒法同步新的數據庫結構,致使表缺失 --> <property name="hibernate.connection.url">jdbc:mysql://IP:3306/confluence_smc?sessionVariables=storage_engine%3DInnoDB&useUnicode=true&characterEncoding=utf8</property>
須要注意的是,若是使用 mysql 5.7 版本,也須要將其中的 storage_engine 修改成 default_storage_engine
confluence 4.X 中能升級的最大版本是 v4.3.7,因此先將 wiki 升級至 4.3.7 版本,步驟以下:
將原 wiki 服務進程中止,下載 4.3.7 版本安裝包至 /opt 目錄下,下載連接:https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-4.3.7-x64.bin
執行該二進制文件進行升級:
[root@localhost opt]# ./atlassian-confluence-4.3.7-x64.bin Unpacking JRE ... Starting Installer ... This will install Confluence 4.3.7 on your computer. OK [o, Enter], Cancel [c] 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], Upgrade an existing Confluence installation [3, Enter] # 選擇升級 confluence Existing installation directory: [/opt/atlassian/confluence] # 指定 confluence 的安裝路徑 Back Up Confluence Home The upgrade process will automatically back up your Confluence Installation Directory. You can also choose to back up your existing Confluence Home Directory. Both directories are backed up as zip archive files in their respective parent directory locations. We strongly recommend choosing this option in the unlikely event that you experience problems with the upgrade and may require these backups to restore your existing Confluence installation. If you have many attachments in your Confluence Home Directory, the zip archive of this directory may consume a significant amount of disk space. Back up Confluence home ? Yes [y, Enter], No [n] # 備份 confluence 的家目錄,若是此前已經作過備份,此處可選擇 No n Checking for local modifications. List of modifications made within Confluence directories. The following provides a list of file modifications within the confluence directory. Modified files: confluence/WEB-INF/lib/atlassian-extras-2.4.jar Removed files: (none) Added files: (none) [Enter] Checking if your instance of Confluence is running Upgrade Check List Back up your external database We strongly recommend you back up your Confluence database if you have not already done so. Please refer to the following URL for back up guidelines: http://docs.atlassian.com/confluence/docs-43/Production+Backup+Strategy Check plugin compatibility Check that your non-bundled plugins are compatible with Confluence 4.3.7. For more information see our documentation at the following URL: http://docs.atlassian.com/confluence/docs-43/Installing+and+Configuring+Plugins+using+the+Universal+Plugin+Manager Please ensure you have read the above checklist before upgrading. Your existing Confluence installation is about to be upgraded! Do you want to proceed? Upgrade [u, Enter], Exit [e] Your instance of Confluence is currently being upgraded. Checking if Confluence has been shutdown... Backing up the Confluence installation directory Deleting the previous Confluence installation directory... Extracting files ... Please wait a few moments while Confluence starts up. Launching Confluence ... Installation of Confluence 4.3.7 is complete Your installation of Confluence 4.3.7 is now ready and can be accessed via your browser. Custom modifications Your previous Confluence installation contains customisations that must be manually transferred. Refer to our documentation more information: http://docs.atlassian.com/confluence/docs-43/Upgrading+Confluence#UpgradingConfluence-custommodifications Confluence 4.3.7 can be accessed at http://localhost:8090 Confluence 4.3.7 may take several minutes to load on first start up. Finishing installation ...
啓動完成後訪問頁面,若是頁面正常訪問且數據完整,則升級完成(在啓動以前其實還涉及到激活的過程,這部分以前在博文寫了,可是爲了不引發沒必要要的麻煩已經刪除,有須要的朋友能夠給我留言)。
升級至 4.3.7 版本後,就能夠直接升級至 5.10.9 版本,5.10.9 版本下載連接:https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-5.10.9-x64.bin
將下載後的安裝包上傳到 /opt 目錄下,中止 wiki 服務,按照升級 4.3.7 的方式執行升級程序。
若是在執行升級程序時,報以下錯誤:
Could not display the GUI. This application needs access to an X Server.
這表明系統中缺乏 dejavu-sans-fonts 軟件包,使用以下命令安裝便可:
yum install -y dejavu-sans-fonts
啓動完成後訪問頁面,若是頁面正常訪問且數據完整,則升級完成(在啓動以前其實還涉及到激活的過程,這部分以前在博文寫了,可是爲了不引發沒必要要的麻煩已經刪除,有須要的朋友能夠給我留言)。
6.15.9 版本下載連接:https://www.atlassian.com/software/confluence/downloads/binary/atlassian-confluence-6.15.9-x64.bin
將下載後的安裝包上傳到 /opt 目錄下,中止 wiki 服務,按照升級 5.10.9 的方式執行升級程序。
啓動完成後訪問頁面,若是頁面正常訪問且數據完整,則升級完成(在啓動以前其實還涉及到激活的過程,這部分以前在博文寫了,可是爲了不引發沒必要要的麻煩已經刪除,有須要的朋友能夠給我留言)。
原 confluence 將程序主目錄放置在 /opt/atlassian/confluence/webapps 目錄下,而新的 confluence 服務的程序主目錄是在 /opt/atlassian/confluence 目錄下,因此爲了確保升級前的連接地址能夠正常訪問升級後的服務,須要作以下修改:
將 /opt/atlassian/confluence 目錄下的 confluence 主程序目錄移動至 /opt/atlassian/confluence/webapps 目錄下,並重命名爲 wiki
修改 /opt/atlassian/confluence/conf 目錄下的 server.xml 文件,將其中指定程序主目錄的配置進行修改:
<Context path="" docBase="../confluence" debug="0" reloadable="false" useHttpOnly="true"> <!-- 將上面的配置修改成以下內容 --> <Context path="" docBase="" debug="0" reloadable="false" useHttpOnly="true"> <!-- 配置 docBase 部分爲空,tomcat 啓動時會自動到 webapps 目錄下尋找項目啓動 -->
confluence 6 版本添加了文件預覽的功能,若是系統中缺乏字符集,預覽的時候會顯示亂碼,解決辦法以下:
首先在操做系統中建立以下目錄(CentOS 系統):
mkdir -p /usr/share/fonts/msttcore/
找一臺 Windows 系統的電腦,將 C:\Windows\Fonts 目錄下的全部字體文件打包,上傳到 /usr/share/fonts/msttcore 目錄下。
在 /opt/atlassian/confluence/bin 目錄下(安裝目錄),編輯 setenv.sh 腳本,在 CATALINA_OPTS 部分添加以下內容:
CATALINA_OPTS="-Dconfluence.document.conversion.fontpath=/usr/share/fonts/msttcore/ ${CATALINA_OPTS}"
在 /opt/confluencedata 目錄下刪除以下內容(數據目錄):
rm -rf /opt/confluencedata/viewfile/* rm -rf /opt/confluencedata/thumbnails/* rm -rf /opt/confluencedata/shared-home/dcl-document/* rm -rf /opt/confluencedata/shared-home/dcl-document_hd/* rm -rf /opt/confluencedata/shared-home/dcl-thumbnail/*
重啓 confluence 服務便可。
confluence 默認在登陸失敗超過 3 次就會開啓驗證碼認證,若是出現驗證碼徹底不顯示,有多是字符編碼的問題,通常日誌中會有以下報錯:
2020-09-05 15:01:27,053 ERROR [http-8090-1] [[Standalone].[localhost].[/].[jcaptcha]] log Servlet.service() for servlet jcaptcha threw exception com.octo.captcha.CaptchaException: word is too tall: try to use less letters, smaller font or bigger background: text bounds = {text=tasble
在 /opt/atlassian/confluence/bin 目錄下(安裝目錄),編輯 setenv.sh 腳本,在 CATALINA_OPTS 部分添加以下內容:
CATALINA_OPTS="-Dfile.encoding=UTF-8"
在系統中安裝以下軟件(通常狀況下都是默認安裝好的):
yum -y install deja*
重啓 confluence 便可。
若是隻是部分驗證碼不顯示(刷新屢次,偶現驗證不顯示的狀況),多是因爲缺失字體致使的,暫未找到解決辦法,能夠先關閉驗證碼功能。
官方處理文檔:
confluence 升級至 6.15.10 版本後,建立空間或頁面會顯示以下報錯:
該文件的加載時間比平時要長。請稍等片刻,而後嘗試刷新
頁面會一直卡在刷新的界面中,通過排查,能夠肯定是因爲 confluence 新增的協同編輯功能致使的。
協同編輯是經過 Synchrony 進行的,Synchrony 在默認的狀況下是運行在 8091 端口的。這個可以實時的同步數據。Synchrony 是一個可執行的進程,這個進程是在 Confluence 以外運行的,可是又是由 Confluence 自動進行管理的。
若是沒有在 confluence 中使用反向代理 ,那麼會經過 Confluence 的內部 Synchrony 代理鏈接到 Synchrony。
若是 confluence 是運行在一個反向代理的後面的,那麼就須要在反向代理中添加針對 Synchrony 服務 ws 請求的代理配置。例如當前使用 NGINX 做爲反向代理,那麼在 NGINX 中添加以下配置(與 confluence 在同一個 server 段):
location /synchrony { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://IP:8091/synchrony; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; }
接下來修改 /opt/atlassian/confluence/conf 目錄下的 server.xml 文件,在其中配置 tomcat 鏈接器:
<Connector port="8090" connectionTimeout="20000" redirectPort="8443" maxThreads="48" minSpareThreads="10" enableLookups="false" acceptCount="10" debug="0" URIEncoding="UTF-8" protocol="org.apache.coyote.http11.Http11NioProtocol" proxyName="ops.wiki.com" proxyPort="80" schema="http"/>
修改完成後重啓 confluence 服務便可。
或者直接在 confluence 的設置中將協同編輯功能關閉,也能夠解決該問題。