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。在中增加如下:
    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文件中的之间增加
    
    
  • 在${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的配置,参考如下:
jdbc:mysql://192.168.100.167/xwiki?useSSL=false
xwiki
Xwiki123!
com.mysql.jdbc.Driver
org.hibernate.dialect.MySQL5InnoDBDialect
true
20

UTF-8
true
utf8







  • 执行./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

你可能感兴趣的:(xwiki 10.11.9 war包方式安装)