xwiki 10.11.9 war包方式安装

安装文件列表

序号 文件名称
01 zulu8.42.0.23-ca-jdk8.0.232-linux_x64.tar.gz
02 apache-tomcat-9.0.27.tar.gz
03 xwiki-platform-distribution-war-10.11.9.war
04 mysql-connector-java-5.1.48.tar.gz
05 xwiki-platform-distribution-flavor-xip-10.11.9.xip
06 mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
07 createrepo-0.9.9-28.el7.noarch.rpm

系统配置

配置JDK

  • 将zulu8.42.0.23-ca-jdk8.0.232-linux_x64.tar.gz上传并解压到/root
  • 将zulu8.42.0.23-ca-jdk8.0.232-linux_x64重命名为jdk-8.0.232
  • 在/root/.bash_profile中添加如下内容
    export JAVA_HOME=/root/jdk-8.0.232
    export JRE_HOME=${JAVA_HOME}/jre
    export PATH=${JAVA_HOME}/bin:$PATH:$HOME/bin
    export CLASSPATH=${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
    
  • source /root/.bash_profile
  • 执行java -version测试java
测试Java

配置本地yum源

  • 移除系统repo,cd /etc/yum.repos.d/ && rm -rf *.repo
  • 创建/etc/yum.repos.d/base.repo文件,并增加如下内容源到repo文件中
    [Local_ISO]
    name=Loacal ISO
    baseurl=file:///mnt
    gpgcheck=0
    enabled=1
    
  • 执行mount /dev/sr0 /mnt挂载系统光盘到/mnt目录
  • 上传createrepo-0.9.9-28.el7.noarch.rpm 文件到/root/rpms/中,并执行yum -y localinstall /root/rpms/createrepo-0.9.9-28.el7.noarch.rpm,所需要的两个依赖包可以在系统光盘中找到
  • 在/etc/yum.repos.d/base.repo文件中增加如下内容
    [Local_RPM]
    name=Loacal RPM
    baseurl=http://localhost:10040/rpms
    gpgcheck=0
    enabled=1
    
  • 在/root目录中执行python -m SimpleHTTPServer 10040

创建MySQL库

  • 上传mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar文件到/root/rpms目录中
  • 解压缩mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar文件到/root/rpms目录中,执行
    tar -xf /root/rpms/mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
  • 执行createrepo -d /root/rpms/ && yum clean all
  • 执行yum -y install mysql-community-server mysql-community-client
安装MySQL
  • 修改/etc/my.cnf,参考配置如下
    [mysqld]
    # Remove leading # and set to the amount of RAM for the most important data
    # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
    # innodb_buffer_pool_size = 128M
    #
    # Remove leading # to turn on a very important data integrity option: logging
    # changes to the binary log between backups.
    log_bin=/var/lib/mysql/mysql_binary_log
    #
    # Remove leading # to set options mainly useful for reporting servers.
    # The server defaults are faster for transactions and fast SELECTs.
    # Adjust sizes as needed, experiment to find the optimal values.
    # join_buffer_size = 128M
    # sort_buffer_size = 2M
    # read_rnd_buffer_size = 2M
    datadir=/var/lib/mysql
    socket=/var/lib/mysql/mysql.sock
    transaction-isolation = READ-COMMITTED
    # Disabling symbolic-links is recommended to prevent assorted security risks
    symbolic-links=0
    
    #In later versions of MySQL, if you enable the binary log and do not set
    ##a server_id, MySQL will not start. The server_id must be unique within
    ##the replicating group.
    server_id=1
    
    key_buffer_size = 32M
    max_allowed_packet = 32M
    thread_stack = 256K
    thread_cache_size = 64
    query_cache_limit = 8M
    query_cache_size = 64M
    query_cache_type = 1
    
    max_connections = 250
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    character-set-server=utf8
    
    binlog_format = mixed
    read_buffer_size = 2M
    read_rnd_buffer_size = 16M
    sort_buffer_size = 8M
    join_buffer_size = 8M
    
    # InnoDB settings
    innodb_file_per_table = 1
    innodb_flush_log_at_trx_commit  = 2
    innodb_log_buffer_size = 64M
    innodb_buffer_pool_size = 4G
    innodb_thread_concurrency = 8
    innodb_flush_method = O_DIRECT
    innodb_log_file_size = 512M
    
    [mysqld_safe]
    log-error=/var/log/mysqld.log
    pid-file=/var/run/mysqld/mysqld.pid
    sql_mode=STRICT_ALL_TABLES
    
    [client]
    default-character-set=utf8
    
  • 设置MySQL开机启动并启动MySQL
    systemctl enable mysqld.service
    systemctl start mysqld.service
    systemctl status mysqld.service
    
  • 执行grep password /var/log/mysqld.log获得初始密码
  • 执行mysql_secure_installation对MySQL做基础配置
    Securing the MySQL server deployment.
    
    Enter password for user root: 输入初始密码
    
    The existing password for the user account root has expired. Please set a new password.
    
    New password: 输入新密码Root123!
    
    Re-enter new password: Root123!
    The 'validate_password' plugin is installed on the server.
    The subsequent steps will run with the existing configuration
    of the plugin.
    Using existing password for root.
    
    Estimated strength of the password: 100
    Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
    Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
    By default, a MySQL installation has an anonymous user,
    allowing anyone to log into MySQL without having to have
    a user account created for them. This is intended only for
    testing, and to make the installation go a bit smoother.
    You should remove them before moving into a production
    environment.
    
    Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    
    Normally, root should only be allowed to connect from
    'localhost'. This ensures that someone cannot guess at
    the root password from the network.
    
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    By default, MySQL comes with a database named 'test' that
    anyone can access. This is also intended only for testing,
    and should be removed before moving into a production
    environment.
    
    
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    - Dropping test database...
    Success.
    
    - Removing privileges on test database...
    Success.
    
    Reloading the privilege tables will ensure that all changes
    made so far will take effect immediately.
    
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
    Success.
    
    All done!
    
  • 执行show variables like "%char%"; 检查字符集是否为utf8
检查MySQL字符集
  • 创建数据库
    create database xwiki default character set utf8 collate utf8_bin;
    
  • 创建用户并授权
    grant all privileges on *.* to 'xwiki'@'localhost' identified by 'Xwiki123!';
    grant all privileges on *.* to 'xwiki'@'%' identified by 'Xwiki123!';
    

安装Tomcat

  • 上传apache-tomcat-9.0.27.tar.gz并解压缩至/root目录下
  • 在/root/.bash_profile中新增环境变量export TOMCAT_HOME=/root/apache-tomcat-9.0.27,
  • 执行source /root/.bash_profile生效修改
  • 在${TOMCAT_HOME}/bin/catalina.sh文件中,在cygwin=false之上增加如下语句
    JAVA_OPTS="-Xms1024m -Xmx4096m -Xss1024K"
    
    这是为了给Java配置更多的内存,因为tomcat默认配置的内存对于xwiki太小。
  • 在${TOMCAT_HOME}/conf/server.xml中配置字符集和gzip。在<Connector port="8080" … />中增加如下:
    URIEncoding="UTF-8"
    compression="on"
    compressionMinSize="2048"
    compressableMimeType="text/html,text/xml,text/css,text/javascript,application/x-javascript"
    
  • 在${TOMCAT_HOME}/webapps中创建xwiki目录,并将xwiki-platform-distribution-war-11.9.war解压至该目录
  • 创建/root/xwiki_data目录
  • 打开${TOMCAT_HOME}/webapps/xwiki/WEB-INF/xwiki.properties文件。将environment.permanentDirectory取消注释并配置为/root/xwiki_data
  • 若遇到maximum cache问题,在${TOMCAT_HOME}/conf/context.xml文件中的<Context>之间增加
    <Resources cachingAllowed="true" cacheMaxSize="100000" />
    
  • 在${TOMCAT_HOME}/bin/创建setenv.sh文件,并赋予执行权限
  • 对于没有安装X11库的Linux服务,需要启用headless模式。在${TOMCAT_HOME}/bin/setenv.sh文件中增加如下内容
    #!/bin/bash
    export JAVA_OPTS="${JAVA_OPTS} -Djava.awt.headless=true"
    
  • 创建/root/xwiki_data/extension/repository/目录,将xwiki-platform-distribution-flavor-xip-11.9.xip后缀改为zip并解压至该目录
  • 解压mysql-connector-java-5.1.48.tar.gz,并将mysql-connector-java-5.1.48.jar拷贝至${TOMCAT_HOME}/webapps/xwiki/WEB-INF/lib目录中
  • 在${TOMCAT_HOME}/webapps/xwiki/WEB-INF/hibernate.cfg.xml中注释掉其他数据库的配置,打开MySQL的配置,参考如下:
<property name="connection.url">jdbc:mysql://192.168.100.167/xwiki?useSSL=false</property>
<property name="connection.username">xwiki</property>
<property name="connection.password">Xwiki123!</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>
<property name="dbcp.poolPreparedStatements">true</property>
<property name="dbcp.maxOpenPreparedStatements">20</property>

<property name="hibernate.connection.charSet">UTF-8</property>
<property name="hibernate.connection.useUnicode">true</property>
<property name="hibernate.connection.characterEncoding">utf8</property>

<mapping resource="xwiki.hbm.xml"/>
<mapping resource="feeds.hbm.xml"/>
<mapping resource="activitystream.hbm.xml"/>
<mapping resource="instance.hbm.xml"/>
<mapping resource="notification-filter-preferences.hbm.xml"/>
<mapping resource="mailsender.hbm.xml"/>
  • 执行./bin/startup.sh启动tomcat
  • 在浏览器中输入http://主机ip:8080/xwiki/bin/view/Main/

安装XWiki UI

点击Continue

配置admin用户,密码:admin,然后点击Register and login

点击Continue

选择XWiki Standard Flavor 10.11.9,点击Install this flavor

点击Install进行安装

点击Continue

image.png

点击Continue继续

image.png

点击Continue


进入到首页


备份

备份部分

  • The database
  • The XWiki WAR file
  • The Permanent data (located in the XWiki permanent directory)
  • Log files (optional)

备份数据库

mysqldump --add-drop-database --databases xwiki > xwiki.sql

在多wiki环境中,使用--all-databases替换--databases

It's important that the backup is done with --add-drop-database since when you restore it it's important that tables that might have been created are removed. For example database migrations can create extra tables. If you want to cancel the migration and go back to your clean dump you'll need to have those tables removed as otherwise when you run the migration again later on you might have errors.

备份WAR文件

最安全做法是将tomcat中webapps的xwiki目录整体复制。这里面大部分文件是静态的不会改变的,但其中有些配置文件是确实需要备份的:

  • WEB-INF/hibernate.cfg.xml (Hibernate configuration)
  • WEB-INF/xwiki.cfg (old XWiki configuration file but still used)
  • WEB-INF/xwiki.properties (new XWiki Configuration file)
  • WEB-INF/classes/logback.xml (Logging configuration)
  • WEB-INF/observation/* (Cluster configuration)

恢复这些配置文件,只需将它们拷贝回原来复制的地方。除了上述配置文件,JDBC、extra plugins也要根据实际情况备份。自定义皮肤在webapps/xwiki/skins/目录下,根据实际情况备份。

备份Permanent Data

xwiki产生如下数据

  • Wiki pages (but they're saved in the database)
  • Attachments (when they're saved on the filesystem, otherwise they're saved in the database)
  • Installed extensions
  • Search index files (Lucene, Solr)
  • Logs
  • Mails that failed to be sent
    Backing up this Permanent Directory will backup all files generated by XWiki.

备份日志

Those logs are not needed by XWiki but you may want to save them to review them later on to diagnose issues that happened for example.

位置:TOMCAT_HOME/logs/catalina.out

备份脚本示例

01. #!/bin/bash  
02.   
03. #Space Separated List of Databases to Dump  
04. #DATABASE="xwiki d1 d3"  
05. DATABASE="xwiki"  
06. DBUSER=root  
07. DBPASS=*****  
08.   
09. #XWIKI data folder  
10. DATAFOLDER=/srv/tomcat6/data/  
11. #Where is the webapps folder for your tomcat installation  
12. # SLES 11 is located /srv/tomcat6/webapps  
13. WEBAPPDIR=/srv/tomcat6/webapps  
14. #What context (dir) does your application deploy to  
15. DEPLOYCONTEXT=ROOT  
16.   
17.   
18. ###~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
19. DEPLOYDIR=${WEBAPPDIR}/${DEPLOYCONTEXT}  
20. DATE=$(date '+%Y-%m-%d')  
21. mkdir ./${DATE}  
22.   
23. #backup mysql  
24. echo "Backing up Mysql"  
25. mysqldump -h 127.0.0.1 -u ${DBUSER} --password=${DBPASS} --max_allowed_packet=512m --add-drop-database --databases ${DATABASE} | /bin/gzip  > ./${DATE}/${DATABASE}.sql.gz  
26.  
27. echo "Backing up Data"  
28. #Backup Exteral Data Storage  
29. /bin/tar -C ${DATAFOLDER}/../ -zcf ./${DATE}/data.tar.gz data  
30.   
31. #Backing Java Keystore  
32. /bin/cp /srv/tomcat6/.keystore ./${DATE}/.keystore  
33.   
34. echo "Backing up xwiki configuration"  
35. /bin/cp ${DEPLOYDIR}/WEB-INF/hibernate.cfg.xml ./${DATE}/hibernate.cfg.xml  
36. /bin/cp ${DEPLOYDIR}/WEB-INF/xwiki.cfg ./${DATE}/xwiki.cfg  
37. /bin/cp ${DEPLOYDIR}/WEB-INF/xwiki.properties ./${DATE}/xwiki.properties  
38.   
39. #Backup Deploy Context  
40. echo "Backing UP deploy Context"  
41. /bin/tar -C ${DEPLOYDIR}/../ -zcf ./${DATE}/ROOT.tar.gz ROOT  
42.   
43. echo "DONE"

恢复

  • 禁用约束检查mysql -e "SET FOREIGN_KEY_CHECKS=0;"
  • 删除现有wiki数据库mysql -e "DROP DATABASE xwiki;",删除后最好重启
  • 重建wiki数据库mysql -e "CREATE DATABASE IF NOT EXISTS xwiki DEFAULT CHARACTER SET utf8;".
  • 用dump文件恢复数据mysql xwiki --user=root -p < xwiki.sql
  • 启用约束检查mysql -e "SET FOREIGN_KEY_CHECKS=1;"
  • 恢复用户权限(如果xwiki用户在MySQL中)).
  • 更新hibernate数据库配置信息
  • 重启Tomcat
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,185评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,445评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,684评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,564评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,681评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,874评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,025评论 3 408
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,761评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,217评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,545评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,694评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,351评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,988评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,778评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,007评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,427评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,580评论 2 349