在 CentOS 7 上安装 Openfire XMPP 服务器

从 Ignite Realtime 网站下载最新版本(当前为 Openfire 4.3.2)。

这里有两种 Openfire 变体,例如:有或者没有 JRE 。
我们建议我们下载并安装 Openfire with JRE 。
否则,我们必须在不使用 JRE 的情况下安装 Openfire 之前显式安装 OpenJDK。

[root@openfire-01 ~]# cd /tmp
[root@openfire-01 tmp]# wget -O openfire-4.3.2-1.x86_64.rpm https://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-4.3.2-1.x86_64.rpm

使用 rpm 命令安装 Openfire 软件包。

[root@openfire-01 tmp]# rpm -ivh openfire-4.3.2-1.x86_64.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:openfire-4.3.2-1                 ################################# [100%]
Restarting openfire (via systemctl):                       [  OK  ]

Openfire 服务已经在软件包安装过程中启用,因此,我们只需要启动一次。

[root@openfire-01 tmp]# systemctl is-enabled openfire
openfire.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig openfire --level=5
enabled
[root@openfire-01 tmp]# systemctl start openfire

检查 Openfire 服务的状态。

[root@openfire-01 tmp]# systemctl status openfire

Openfire 服务启动成功。

on  it road.com

为 Openfire Server 创建 MariaDB 数据库

在 MariaDB 服务器中为 Openfire 创建一个数据库。

[root@openfire-01 tmp]# mysql -u root -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE openfire;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON openfire.* to 'openfire'@'localhost' IDENTIFIED BY '123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL ON openfire.* to 'openfire'@'openfire-01.onitroad.com' IDENTIFIED BY '123';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> EXIT
Bye

以 openfire 用户身份连接并使用 Openfire 主目录中提供的脚本在 openfire 数据库中创建数据库模式。

[root@openfire-01 tmp]# mysql -u openfire -p123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> USE openfire;
Database changed
MariaDB [openfire]> SOURCE /opt/openfire/resources/database/openfire_mysql.sql
Query OK, 0 rows affected (0.04 sec)
...
Query OK, 0 rows affected (0.00 sec)

检查 openfire 数据库中的表列表。

MariaDB [openfire]> SHOW TABLES;
+----------------------+
| Tables_in_openfire   |
+----------------------+
| ofExtComponentConf   |
| ofGroup              |
| ofGroupProp          |
| ofGroupUser          |
| ofID                 |
| ofMucAffiliation     |
| ofMucConversationLog |
| ofMucMember          |
| ofMucRoom            |
| ofMucRoomProp        |
| ofMucService         |
| ofMucServiceProp     |
| ofOffline            |
| ofPresence           |
| ofPrivacyList        |
| ofProperty           |
| ofPubsubAffiliation  |
| ofPubsubDefaultConf  |
| ofPubsubItem         |
| ofPubsubNode         |
| ofPubsubNodeGroups   |
| ofPubsubNodeJIDs     |
| ofPubsubSubscription |
| ofRemoteServerConf   |
| ofRoster             |
| ofRosterGroups       |
| ofSASLAuthorized     |
| ofSecurityAuditLog   |
| ofUser               |
| ofUserFlag           |
| ofUserProp           |
| ofVCard              |
| ofVersion            |
+----------------------+
33 rows in set (0.00 sec)
MariaDB [openfire]> EXIT
Bye
在 CentOS 7 上安装 Openfire XMPP 服务器

Openfire是一个用Java开发的基于XMPP/Jabber协议的跨平台实时协作服务器。

Openfire 以前称为 Wildfire 和 Jive Messenger。
它由 Jive Software 开发,由 Ignite Realtime 社区维护。

Openfire 是免费和开源的,并在 Apache License 2.0 下分发。

在本文中,我们将在 CentOS 7 上安装 Openfire XMPP 服务器,然后我们将使用 Spark 客户端连接我们的 Openfire XMPP 服务器。

配置 Linux 防火墙以允许 Openfire 服务端口

在 Linux 防火墙中允许 Openfire 服务端口如下。

[root@openfire-01 tmp]# firewall-cmd --permanent --add-port={9090,5222}/tcp
success
[root@openfire-01 tmp]# firewall-cmd --reload
success

在 CentOS 7 上配置 Openfire 服务器

要启动 Openfire 设置,请在客户端浏览器中浏览 URL http://openfire-01.onitroad.com:9090/。

选择首选语言,然后单击继续。

如上图所示配置服务器设置,然后单击继续。

我们已经为我们的 Openfire 服务器配置了一个 MariaDB 数据库。
因此,在“数据库设置”页面上选择“标准数据库连接”,然后单击“继续”。

根据上面的屏幕截图定义数据库连接设置,然后单击继续。

我们位于“个人资料设置”页面。
接受默认设置并单击继续。

为管理员帐户定义电子邮件地址和密码,然后单击继续。

设置完成。
单击登录到管理控制台以访问 Openfire Web UI。

以管理员用户身份登录。

登录成功后,我们可以进入 Openfire 管理控制台的系统信息页面。

单击“用户/组”以创建用于访问 Openfire 服务的新用户。

创建一个普通用户,就像我们在上面的屏幕截图中创建的那样。

已创建用户 jackli。

我们创建的用户足以证明客户端与 Openfire 服务器的连接,因此,我们在此不创建更多用户。
我们可以从同一页面创建任意数量的用户/组。

在 CentOS 7 上安装 MariaDB 服务器

我们将配置 Openfire 以使用外部数据库以获得最佳性能。
为此,我们使用 yum 命令安装 MariaDB 数据库服务器。

[root@openfire-01 ~]# yum install -y mariadb-server

启用并启动 MariaDB 服务。

[root@openfire-01 ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@openfire-01 ~]# systemctl start mariadb.service

如下配置 MariaDB 实例。

[root@openfire-01 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n] 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? [Y/n] Y
 ... Success!
By default, MariaDB 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? [Y/n] 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? [Y/n] Y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!

MariaDB 已成功安装。

为 Windows 安装 Spark 客户端

我们已经在 CentOS 7 上成功配置了我们的 Openfire XMPP 服务器。
现在,我们需要一个客户端系统和软件来测试我们的配置。

Ignite Realtime 提供 Spark 软件。
它是一个免费的开源 XMPP 客户端。
我们将把它安装在我们基于 Microsoft Windows 的机器上,然后用它来连接我们的 Openfire XMPP 服务器。

从 Ignite Realtime 网站下载 Spark 客户端并将其安装在 MS Windows 上。

我们不会展示 Spark 客户端的安装过程,因为它非常简单,我们应该继续使用默认选项。

安装后,运行 Spark 客户端。

我们可以使用 jackli 用户登录,但我们必须在登录前进行一些另外的设置。

单击高级。

我们必须在这里配置两个设置:

  1. 设置 Openfire 服务器的主机名或者 IP 地址
  2. 接受所有证书以删除用户登录时的证书警告。

单击确定。

点击登录。

我们已使用 Spark 客户端成功登录 CentOS 7 上的 Openfire XMPP 服务器。

日期:2020-09-17 00:16:40 来源:oir作者:oir