如何部署Tigase Server 8.0.x?

XMPP

1 基础知识

1.1 压缩包命名规则

tigase-server-<version>-SNAPSHOT-b<build>-<type>

范例,

tigase-server-8.0.0-b10083-dist-max.zip

– “version”指代软件的版本
– “build”编译的编号
– “type”安装包的类型,包括以下类型,
— javadoc.jar,仅Javadoc安装程序
— dist.zip,不包含依赖关系的二进制压缩文件
— dist.tar.gz,不包含依赖关系的二进制tar压缩文件
— dist-max.zip,包含所有依赖关系的二进制压缩文件
— dist-max.tar.gz,包含所有依赖关系的二进制tar压缩文件

1.2 安装要求

– Java Development Kit v8或更高版本(建议OpenJDK)
– 使用具有管理员权限的用户安装Tigase Server(不要以root身份运行)

1.3 安装方法

使用Web Installer安装
使用控制台模式安装
Windows环境中安装Tigase
Tigase的网络设置
Tigase XMPP服务器作为服务运行

2 最佳实践

2.1 系统环境

2.1.1 系统环境信息

OS = CentOS 7.3 x86_64
IP Address = 10.168.0.90
Host Name = tigase.cmdschool.org
另外,如果你对基本的系统配置不熟悉,可参阅如下文档,

如何完成CentOS 7.x的基本服务?

2.1.2 安装JDK

由于Tigase基于使用Java技术,你需要先参阅如下文档安装openJDK

如何部署openJDK?


根据笔者不严格的抽选测试结果,以下版本可以运行,
openjdk-9.0.4_linux-x64_bin.tar.gz
openjdk-10.0.2_linux-x64_bin.tar
openjdk-11.0.2_linux-x64_bin.tar.gz(推荐部署版本)
openjdk-12.0.2_linux-x64_bin.tar.gz
以下版本运行会报错,
openjdk-13.0.2_linux-x64_bin.tar.gz
openjdk-14.0.2_linux-x64_bin.tar.gz
openjdk-15.0.2_linux-x64_bin.tar.gz

2.1.3 配置名称解析

echo '10.168.0.90 tigase.cmdschool.org' >> /etc/hosts
echo '10.168.0.90 cmdschool.org' >> /etc/hosts

注:
– 此操作代替DNS解析,如有DNS解析则无需设置
– 此域名解析应该配置当前服务器的hostname

2.2 安装前的准备

2.2.1 下载源代码

yum install -y vim wget unzip net-tools

2.2.2 下载源代码

cd ~
wget https://github.com/tigase/tigase-server/releases/download/tigase-server-8.1.2/tigase-server-8.1.2-b10915-dist-max.tar.gz

另外,以上只是演示,如果不能下载,请使用浏览器从以下链接下载,
https://github.com/tigase/tigase-server/releases

2.2.3 解压软件包

tar -xf tigase-server-8.1.2-b10915-dist-max.tar.gz

2.2.4 预设防火墙端口

firewall-cmd --permanent --add-port 5222-5223/tcp
firewall-cmd --permanent --add-port 5269/tcp
firewall-cmd --permanent --add-port 5280/tcp
firewall-cmd --permanent --add-port 5290/tcp
firewall-cmd --permanent --add-port 8080/tcp
firewall-cmd --reload
firewall-cmd --list-all

2.2.5 关闭SELinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

2.3 部署tigase服务端

2.3.1 创建运行用户

groupadd -g 982 tigase
useradd -u 982 -g 982 -d /usr/tigase -s /bin/bash tigase

2.3.2 部署软件包

mv tigase-server-8.1.2-b10915 /usr/
chown root:tigase -R /usr/tigase-server-8.1.2-b10915
chmod 775 -R /usr/tigase-server-8.1.2-b10915
rm -rf /usr/tigase
ln -s /usr/tigase-server-8.1.2-b10915/ /usr/tigase

2.3.3 配置Tigase XMPP环境变量

echo 'export TIGASE_HOME="/usr/tigase"' > /etc/profile.d/tigase.sh
source /etc/profile

2.3.4 修改启动配置文件

cp ${TIGASE_HOME}/etc/config.tdsl ${TIGASE_HOME}/etc/config.tdsl.default
cp ${TIGASE_HOME}/etc/tigase.conf ${TIGASE_HOME}/etc/tigase.conf.default
vim ${TIGASE_HOME}/etc/tigase.conf

修改如下参数:

osgiEnabled=false
OSGI=${osgiEnabled}
ENC="-Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8"
JMX_REMOTE_IP="-Djava.rmi.server.hostname=0.0.0.0"
JAVA_HOME="/usr/java/jdk-11.0.2"
CLASSPATH=""
JAVA_XSS=" -Xss228k "
JAVA_DIRECT_MEMORY=" -XX:MaxDirectMemorySize=128m "
JAVA_METASPACE=" -XX:MaxMetaspaceSize=128m "
JAVA_OPTIONS="${GC} ${GC_DEBUG} ${REMOTE_DEBUG} ${EX} ${ENC} ${DRV} ${JMX_REMOTE_IP} -server ${PRODUCTION_HEAP_SETTINGS} ${JAVA_XSS} ${JAVA_DIRECT_MEMORY} ${JAVA_METASPACE} "
TIGASE_HOME="/usr/tigase"
TIGASE_CONSOLE_LOG="/var/log/tigase/tigase-console.log"
TIGASE_CONFIG="/etc/tigase/tigase.xml"
TIGASE_OPTIONS=""
TIGASE_PID="/var/run/tigase/tigase.pid"

需要注意的是,Java家目录位置是“/usr/java/jdk-15.0.2”,然后我们需要根据配置创建以下需要使用的文件夹,

rm -rf /etc/tigase
ln -s ${TIGASE_HOME}/etc/ /etc/tigase
chown tigase:tigase -R ${TIGASE_HOME}/etc/
rm -rf /var/log/tigase
ln -s ${TIGASE_HOME}/logs /var/log/tigase
chown tigase:tigase -R ${TIGASE_HOME}/logs
mkdir -p /var/run/tigase/
chown tigase:tigase /var/run/tigase/

然后,以下配置文件保留默认设置,

cat /etc/tigase/config.tdsl

可见如下配置,

'config-type' = 'setup'

http () {
    setup () {
        'admin-user' = 'admin'
        'admin-password' = 'tigase'
    }
}

需要注意的是,http服务的管理员密码和账号是“admin”和“tigase”,后面需要用到,另外,如果需要改端口,请使用如下配置,

'config-type' = 'setup'

http () {
    setup () {
        'admin-user' = 'admin'
        'admin-password' = 'tigase'
    }
}
httpServer {
    connections {
        8080 (active: false) {}
        7080 () {}
    }
}

2.4 手动测试服务

2.4.1 手动启动服务

sudo -u tigase /usr/tigase/scripts/tigase.sh start /etc/tigase/tigase.conf

然后,可以使用如下命令查看进程信息,

pgrep -u tigase -a java

命令显示如下,

3653 /usr/java/jdk-11.0.2/bin/java -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-8 -Djdbc.drivers=com.mysql.jdbc.Driver:org.postgresql.Driver:org.apache.derby.jdbc.EmbeddedDriver -Djava.rmi.server.hostname=0.0.0.0 -server -Xss228k -XX:MaxDirectMemorySize=128m -XX:MaxMetaspaceSize=128m -Dlogback.configurationFile=/usr/tigase/etc/logback.xml -cp /usr/tigase/jars/activation.jar:/usr/tigase/jars/apns.jar:/usr/tigase/jars/bcpkix-jdk15on.jar:/usr/tigase/jars/bcprov-jdk15on.jar:/usr/tigase/jars/bctls-jdk15on.jar:/usr/tigase/jars/commons-codec.jar:/usr/tigase/jars/commons-httpclient.jar:/usr/tigase/jars/commons-logging.jar:/usr/tigase/jars/derby.jar:/usr/tigase/jars/derbytools.jar:/usr/tigase/jars/groovy.jar:/usr/tigase/jars/groovy-json.jar:/usr/tigase/jars/groovy-jsr223.jar:/usr/tigase/jars/groovy-templates.jar:/usr/tigase/jars/groovy-xml.jar:/usr/tigase/jars/hamcrest-core.jar:/usr/tigase/jars/jackson-annotations.jar:/usr/tigase/jars/jackson-core.jar:/usr/tigase/jars/jackson-databind.jar:/usr/tigase/jars/javax.mail.jar:/usr/tigase/jars/javax.servlet-api.jar:/usr/tigase/jars/jaxmpp-core.jar:/usr/tigase/jars/jaxmpp-j2se.jar:/usr/tigase/jars/jdmkrt.jar:/usr/tigase/jars/jetty-http.jar:/usr/tigase/jars/jetty-io.jar:/usr/tigase/jars/jetty-security.jar:/usr/tigase/jars/jetty-server.jar:/usr/tigase/jars/jetty-servlet.jar:/usr/tigase/jars/jetty-util.jar:/usr/tigase/jars/jmdns.jar:/usr/tigase/jars/jstun.jar:/usr/tigase/jars/jtds.jar:/usr/tigase/jars/jul-to-slf4j.jar:/usr/tigase/jars/licence-lib.jar:/usr/tigase/jars/logback-classic.jar:/usr/tigase/jars/logback-core.jar:/usr/tigase/jars/mongo-java-driver.jar:/usr/tigase/jars/mysql-connector-java.jar:/usr/tigase/jars/org.apache.felix.bundlerepository.jar:/usr/tigase/jars/org.apache.felix.configadmin.jar:/usr/tigase/jars/org.apache.felix.main.jar:/usr/tigase/jars/org.apache.felix.shell.jar:/usr/tigase/jars/org.apache.felix.shell.remote.jar:/usr/tigase/jars/org.osgi.core.jar:/usr/tigase/jars/postgresql.jar:/usr/tigase/jars/slf4j-api.jar:/usr/tigase/jars/smtp.jar:/usr/tigase/jars/tigase-acs.jar:/usr/tigase/jars/tigase-acs-muc.jar:/usr/tigase/jars/tigase-acs-pubsub.jar:/usr/tigase/jars/tigase-acs-workgroup.jar:/usr/tigase/jars/tigase-auditlog.jar:/usr/tigase/jars/tigase-database-migrator.jar:/usr/tigase/jars/tigase-extras-base.jar:/usr/tigase/jars/tigase-extras-bcstarttls.jar:/usr/tigase/jars/tigase-extras-mailer.jar:/usr/tigase/jars/tigase-extras-mailsender.jar:/usr/tigase/jars/tigase-extras-mdns.jar:/usr/tigase/jars/tigase-http-api.jar:/usr/tigase/jars/tigase-http-api-jetty.jar:/usr/tigase/jars/tigase-message-archiving.jar:/usr/tigase/jars/tigase-mongodb.jar:/usr/tigase/jars/tigase-muc.jar:/usr/tigase/jars/tigase-pubsub.jar:/usr/tigase/jars/tigase-push.jar:/usr/tigase/jars/tigase-server-dist.jar:/usr/tigase/jars/tigase-server.jar:/usr/tigase/jars/tigase-socks5.jar:/usr/tigase/jars/tigase-spam.jar:/usr/tigase/jars/tigase-stats-collector-library.jar:/usr/tigase/jars/tigase-stats-collector-provider.jar:/usr/tigase/jars/tigase-stun.jar:/usr/tigase/jars/tigase-unified-archive.jar:/usr/tigase/jars/tigase-utils.jar:/usr/tigase/jars/tigase-workgroupqueues-component.jar:/usr/tigase/jars/tigase-xmltools.jar:/usr/tigase/jars/tigase-server-dist.jar tigase.server.XMPPServer

然后,可以使用如下命令查看倾听的端口,

netstat -antp | grep `pgrep -u tigase java`

命令显示如下,

tcp6       0      0 :::8080                 :::*                    LISTEN      3653/java

2.4.2 查询服务状态

sudo -u tigase /usr/tigase/scripts/tigase.sh status /etc/tigase/tigase.conf

2.4.3 停止服务

sudo -u tigase /usr/tigase/scripts/tigase.sh stop /etc/tigase/tigase.conf

2.5 部署启动脚本

2.5.1 部署启动脚本

cp ${TIGASE_HOME}/scripts/systemd/tigase-server /etc/default/tigase-server
cp ${TIGASE_HOME}/scripts/systemd/tigase-server.service /usr/lib/systemd/system/tigase-server.service
vim /usr/lib/systemd/system/tigase-server.service

配置修改如下,

[Unit]
Description=Tigase XMPP Server
After=syslog.target network-online.target

[Service]
Type=forking
EnvironmentFile=/etc/default/tigase-server
WorkingDirectory=/usr/tigase
PIDFile=/var/run/tigase/tigase.pid
ExecStartPre=/usr/bin/bash -c "mkdir -p /var/run/tigase; chown tigase:tigase /var/run/tigase"
ExecStart=/usr/bin/sudo -u tigase /usr/tigase/scripts/tigase.sh start /etc/tigase/tigase.conf
ExecStop=/usr/bin/sudo -u tigase /usr/tigase/scripts/tigase.sh stop /etc/tigase/tigase.conf
StandardOutput=syslog
StandardError=syslog
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

编辑完成后,我们需要根据脚本的需求创建如下文件,

touch /etc/default/tigase-server

文件创建后,我们需要使用如下命令重载使服务生效,

systemctl daemon-reload

2.5.2 测试服务脚本

systemctl start tigase-server
systemctl status tigase-server.service
systemctl stop tigase-server

2.5.3 设置服务默认启动

systemctl enable tigase-server

2.6 初始化向导

2.6.1 配置名称解析

notepad \Windows\System32\drivers\etc\hosts

加入如下配置,

10.168.0.90 tigase.cmdschool.org

注:以上配置仅仅用于测试,生产环境请使用DNS代替

2.6.2 登录初始化页面

http://tigase.cmdschool.org:8080/
以上向导需要根据自己的需求配置,本章不再详述,如果你需要集成MongoDB,可参阅以下章节,

如何集成Tigase 8.x与MongoDB?

参阅文档
=================

Tigase下载
—————
https://build.tigase.net/nightlies/dists/#/nightlies/dists/
https://tigase.net/xmpp-server

Tigase安装指南
—————-
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#QuickStart

Tigase源代码
————
https://github.com/tigase/tigase-server/tree/tigase-server-8.0.0

DSL配置文件
———–
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#dslConfig

虚拟服务配置
———–
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#tigase41virtualHosts

数据库配置
———-
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#_recommended_database_versions

JVM设置
————
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#jvm_settings

高负载Linux设置
————–
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#linuxhighload

日志配置
————-
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#customLogging

日志指南
———
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#logs

调试Tigase
———
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#debuggingTigase

离线消息
———
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#offlineMessages

服务器证书
———-
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#ServerCertificates

XMPP 支持的扩展
————-
https://docs.tigase.net/tigase-server/8.0.0/Administration_Guide/html/#features

问题的解决
———–
Unrecognized VM option ‘UseConcMarkSweepGC’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
https://github.com/elastic/elasticsearch/issues/51361
https://stackoverflow.com/questions/65546614/unrecognized-vm-option-useconcmarksweepgc-when-running-sample-project

Unrecognized VM option ‘UseParNewGC’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
https://stackoverflow.com/questions/49962437/unrecognized-vm-option-useparnewgc-error-could-not-create-the-java-virtual

Unrecognized VM option ‘CMSIncrementalMode’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
https://askubuntu.com/questions/943284/jvm-errors-when-running-minecraft

Unrecognized VM option ‘ParallelCMSThreads=2’
Did you mean ‘ParallelGCThreads=’? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
https://aijishu.com/a/1060000000094039

没有评论

发表回复

Bash
如何用Tigase监控postfix smtp服务?

1 前言 一个问题,一篇文章,一出故事。 笔者生产中的smtp服务器最近因为负载均衡器的路由故障而导 …

Bash
如何用Tigase监控Elasticsearch集群?

1 前言 一个问题,一篇文章,一出故事。 笔者生产中有一套Elasticsearch集群,笔者为了能 …

Bash
如何实现监视PostFix的延迟邮件警告?

1 前言 一个问题,一篇文章,一出故事。 笔者生产中有一套PostFix集群,最近经历了一次邮件延迟 …