安装OpenFire XMPP服务器以交换消息

以下命令将为部署CentOS 7 Minimal ISO机器做好准备:

  • OpenFire XMPP服务器

  • NFS共享文件系统

备注

本节的先决条件是按本节所述准备CentOS机器 使用WPS远程插件部署和设置地理服务器 .

OpenFire XMPP服务器的设置和配置

XMPP最初名为Jabber,是 可扩展的消息传递和状态协议。 它主要与即时通讯联系在一起。

建立PostgreSQL数据库后端

为了运行一个私有的XMPP通信平台,我们可以安全地使用PostgreSQL 9.2,它是稳定的,默认在CentOS 7中出现。

# as root

$> yum install -y postgresql postgresql-server postgresql-devel postgresql-libs

# After PostgreSQL packages are installed, enable PostgreSQL to start after each reboot.

$> systemctl enable postgresql.service

# Initialize directory structure and postgres system database.

$> postgresql-setup initdb

# And start the service.

$> systemctl start postgresql.service

Postgres安装现在已经启动并运行,让我们继续为OpenFire设置特定的数据库和专用用户,以及身份验证方法和管理密码。

要获得完全的管理权限,请切换到Postgres用户。

su postgres

# as postgres

$> createdb openfire
$> createuser -P openfire

# The '-P' parameter ensures that the shell will explicitly ask for user's password and you will need to type it in. Enter the password twice

   R3m0T3wP5

$> psql -U postgres -d postgres -c "ALTER USER postgres WITH PASSWORD 'R3m0T3wP5';"

Postgres用户使用新密码进行保护。让我们将身份验证方法付诸实践,并强制每个应用程序或shell登录提示输入这些密码。

# as postgres

$> vim /var/lib/pgsql/data/pg_hba.conf

# Scroll down to the bottom of the file and replace all peer and ident strings with md5 string.
# The configuration should look like this:

   # TYPE DATABASE USER CIDR-ADDRESS METHOD

   # "local" is for Unix domain socket connections only

   local      all         all                 md5

   # IPv4 local connections:

   host       all         all 127.0.0.1/32    md5

   # IPv6 local connections:

   host       all         all      ::1/128    md5

从postgres shell(ctrl+d)返回并以root身份重新启动postgresql服务。

# as root

$> systemctl restart postgresql.service

从Ignite实时下载并安装OpenFire

由于OpenFire RPM包不包含在任何主要的RHEL/CentOS/Fedora分发存储库中,因此必须直接从Ignite实时网站下载。

# as root

$> wget http://www.igniterealtime.org/downloadServlet?filename=openfire/openfire-3.10.0-1.i386.rpm -O openfire-3.10.0-1.i386.rpm

# This package come in 32bit version only, so in case we run this installation on x86_64 system, we need to make sure to install corresponding 32bit libraries as well.

$> yum install -y /root/openfire-3.9.3-1.i386.rpm

$> yum install -y glibc.i686

启用OpenFire服务并启动它

# as root

$> chkconfig openfire on

$> systemctl start openfire.service

# We need to open the firewall ports in order to expose the gui to the outside

$> firewall-cmd --permanent --zone=public --add-port=9090/tcp
$> firewall-cmd --permanent --zone=public --add-port=9091/tcp
$> firewall-cmd --reload

Openfire服务器的配置

将浏览器移动到URL

选择合适的语言并点击 Contine

../../_images/openfire001.jpg

将服务器域指定为

geoserver.org

../../_images/openfire002.jpg

选择 标准数据库连接 在下一节

../../_images/openfire003.jpg

在标准连接部分提供PostgreSQL数据库的数据库连接参数。

用户的密码 openfire 与PostgreSQL数据库设置中提供的相同(见上文)。

../../_images/openfire004.jpg

备注

确保 openfire 数据库和用户已在PostgreSQL和提供的密码上正确创建(有关说明,请参阅上文)。

如果没有连接问题,请选择 Default 用户配置文件设置部分的值。

../../_images/openfire005.jpg

创建 管理员 下一节中的帐户。

密码 *must *与中指定的匹配 remoteProcess.properties 文件

R3m0T3wP5

../../_images/openfire006.jpg

初始设置现已完成。使用新创建的 管理员 帐户。

../../_images/openfire007.jpg
../../_images/openfire008.jpg

移到 Server Certificates 剖面图 Server Settings 选项卡面板。

警告

OpenFire 4.0+上不需要此通道。至少证书的管理有些不同。有关详细信息,请参阅特定的OpenFire文档。

../../_images/openfire009.jpg

确保已正确生成自签名证书,然后单击 here 以便重新启动服务器

警告

OpenFire 4.0+上不需要此通道。至少证书的管理有些不同。有关详细信息,请参阅特定的OpenFire文档。

../../_images/openfire010.jpg

同一部分现在显示服务器证书,除非再次生成证书,否则不会要求重新启动。

更新 Security Settings 以便允许服务器接受安全连接上的自签名证书。

警告

OpenFire 4.0+上不需要此通道。至少证书的管理有些不同。有关详细信息,请参阅特定的OpenFire文档。

../../_images/openfire011.jpg

创建 default 通道如下图所示。

../../_images/openfire012.jpg

创建 management 通道如下图所示。注意 Room Options 并指定频道的密码

R3m0T3wP5

../../_images/openfire013.jpg

再次检查通道是否已正确创建,并且它们出现在 Group Chat Rooms .

../../_images/openfire014.jpg

重新启动geoserver

# as root

$> systemctl restart geoserver

成功重新启动GeoServer后,请使用 admin 资格证书。

它是 *very *重要的是用户显示为 Authenticated .

../../_images/openfire015.jpg

还要检查用户是否已注册到上面创建的XMPP通道。

../../_images/openfire016.jpg

XMPP端口的防火墙规则

默认情况下,XMPP服务器监听传入连接的TCP端口是对外关闭的。因此,有必要至少为Openfire默认安全端口启用防火墙规则 5223 除非在服务器安装过程中被用户更改。

为此,发出以下命令:

# as root

# We need to open the firewall ports in order to expose the gui to the outside

$> firewall-cmd --permanent --zone=public --add-port=5222/tcp
$> firewall-cmd --permanent --zone=public --add-port=5223/tcp

$> firewall-cmd --reload

将代理转发到Apache httpd服务器

本节描述的过程允许通过httpd通过apache httpd服务器公开geoserver。

这些步骤不是强制性的,程序可能会随着生产系统的最终部署而相应更改。

要安装Apache httpd服务器,请执行以下操作:

# as root

$> yum -y install httpd mod_ssl

$> vi /etc/httpd/conf.d/forward-proxy.conf

   ProxyRequests Off

   ProxyPass /geoserver ajp://localhost:8009/geoserver
   ProxyPassReverse /geoserver ajp://localhost:8009/geoserver

$> systemctl enable httpd.service

$> service httpd restart

香叶菊 ,默认情况下启用,需要指示允许http网络连接。这可以通过运行以下命令来完成:

# as root

$> /usr/sbin/setsebool -P httpd_can_network_connect 1

通过NFS协议共享文件夹

下一步介绍如何设置系统以公开共享网络文件夹,该文件夹将用于存储远程处理的结果。

以下过程不是必需的,生产系统上的最终部署可以配置为使用不同的协议和框架来公开共享文件系统。

可以通过以下步骤完成NFS包的设置和初始配置:

# as root

$> yum -y install nfs-utils

$> vi /etc/idmapd.conf

   # The following should be set to the local NFSv4 domain name

   # The default is the host's DNS domain name.
   Domain = geoserver.org

备注

根据最终系统部署和生产环境设置,上面指定的域可能不同。

可以通过以下步骤创建和公开共享文件夹:

  1. 作为根

  2. 创建要通过网络文件系统公开的物理文件夹结构

$> mkdir /share
$> mkdir /share/xmpp_data
$> mkdir /share/xmpp_data/output
$> mkdir /share/xmpp_data/resource_dir
  1. 修改权限以允许

    $> chmod -Rf 777 /share
    
  1. 物理文件夹准备就绪后,必须通过 exports

$> vi /etc/exports
  1. NFS导出的写入设置

/share host_ip/24(rw,no_root_squash)
  1. 重新启动NFS服务

$> systemctl start rpcbind nfs-server

$> systemctl enable rpcbind nfs-server

备注

这个 host_ip 必须是公开共享文件夹的主机之一。

香叶菊 ,默认情况下启用,需要指示允许NFS连接。这可以通过运行以下命令来完成:

# as root

$> setsebool -P httpd_use_nfs=1

$> setsebool -P samba_share_nfs=1

$> setsebool -P samba_export_all_ro=1

$> setsebool -P samba_export_all_rw=1