24.9.3. 配置 ISAPI Connector to Balance Client Requests Across 多 JBoss EAP 服务器
此配置在您指定的 JBoss EAP 服务器之间平衡客户端请求。此配置在 IIS 服务器上完成,并且假定您已将 JBoss EAP 配置为接受来自外部 Web 服务器的请求。您还需要对 IIS 服务器的完整管理员访问权限,并将 IIS 配置为使用 ISAPI 连接器。
在客户端请求多个服务器之间取得平衡
创建用于存储日志、属性文件和锁定文件的目录。
此流程的其余部分假定您为此使用了目录
C:\connectors\
。如果您使用不同的目录,请相应地修改说明。创建
isapi_redirect.properties
文件。创建名为
C:\connectors\isapi_redirect.properties
的新文件。将以下内容复制到 文件。# Configuration file for the ISAPI Connector # Extension uri definition extension_uri=/jboss/isapi_redirect.dll # Full path to the log file for the ISAPI Connector log_file=c:\connectors\isapi_redirect.log # Log level (debug, info, warn, error or trace) log_level=info # Full path to the workers.properties file worker_file=c:\connectors\workers.properties # Full path to the uriworkermap.properties file worker_mount_file=c:\connectors\uriworkermap.properties #OPTIONAL: Full path to the rewrite.properties file rewrite_rule_file=c:\connectors\rewrite.properties
如果您不想使用
rewrite.properties
文件,请在行首加上#
字符来注释掉最后一行。创建
uriworkermap.properties
文件。uriworkermap.properties
文件包含已部署应用程序 URL 之间的映射,以及哪个 worker 处理向它们的请求。以下示例文件显示了 文件的语法,以及负载均衡配置。通配符(*
)字符将各种 URL 子目录的所有请求发送到名为 router 的负载均衡器。下一步中介绍了负载平衡器的配置。将您的
uriworkermap.properties
文件放在C:\connectors\
中。# images, css files, path /status and /web-console will be # provided by nodes defined in the load-balancer called "router" /css/*=router /images/*=router /status=router /web-console|/*=router # Example of exclusion from mapping, logo.gif won't be displayed # !/web-console/images/logo.gif=* # Requests to /app-01 and /app-02 will be routed to nodes defined # in the load-balancer called "router" /app-01|/*=router /app-02|/*=router # mapping for management console, nodes in cluster can be enabled or disabled here /jkmanager|/*=status
创建
workers.properties
文件。Worker
.properties
文件包含 worker 标签和服务器实例之间的映射定义。此文件遵循用于 Apache mod_jk 工作程序属性配置的同一文件的语法。以下是
workers.properties 文件的示例
:负载均衡器在文件的末尾配置,组成worker worker01
和worker02
。这些工作程序名称必须与 JBoss EAPundertow
子系统中配置的instance-id
相匹配。将此文件放入
C:\connectors\
目录中。# The advanced router LB worker worker.list=router,status # First EAP server definition, port 8009 is standard port for AJP in EAP # # lbfactor defines how much the worker will be used. # The higher the number, the more requests are served # lbfactor is useful when one machine is more powerful # ping_mode=A – all possible probes will be used to determine that # connections are still working worker.worker01.port=8009 worker.worker01.host=127.0.0.1 worker.worker01.type=ajp13 worker.worker01.ping_mode=A worker.worker01.socket_timeout=10 worker.worker01.lbfactor=3 # Second EAP server definition worker.worker02.port=8009 worker.worker02.host=127.0.0.100 worker.worker02.type=ajp13 worker.worker02.ping_mode=A worker.worker02.socket_timeout=10 worker.worker02.lbfactor=1 # Define the LB worker worker.router.type=lb worker.router.balance_workers=worker01,worker02 # Define the status worker for jkmanager worker.status.type=status
创建
rewrite.properties
文件。rewrite.properties
文件包含为特定应用重写规则的简单 URL。重写路径使用名称值对来指定,如下例所示。将此文件放入C:\connectors\
目录中。#Simple example # Images are accessible under abc path /app-01/abc/=/app-01/images/ Restart the IIS server. Restart your IIS server by using the net stop and net start commands. C:\> net stop was /Y C:\> net start w3svc
IIS 服务器配置为将客户端请求发送到 workers.properties
文件中引用的 JBoss EAP 服务器,以 1:3
比例在服务器之间分散负载。这一比例派生自分配给每台服务器的负载平衡因子( lbfactor
)。