Edge for Private Cloud v. 4.16.09
本文档介绍了 Apigee Edge 的本地部署支持的组件监控技术。
启用 JMX
默认情况下,Cassandra 会启用 JMX,而所有其他 Edge 组件会停用 JMX。因此,您必须为每个组件单独启用 JMX。
每个组件都支持在不同的端口上使用 JMX。下表列出了 JMX 端口以及您要修改以在该端口上启用 JMX 的文件:
| 组件 | JMX 端口 | 文件 |
|---|---|---|
| 管理服务器 | 1099 | /opt/apigee/edge-management-server/bin/start |
| 消息处理器 | 1101 | /opt/apigee/edge-mesage-processor/bin/start |
| Qpid | 1102 | /opt/apigee/edge-qpid-server/bin/start |
| Postgres | 1103 | /opt/apigee/edge-postgres-server/bin/start |
例如,如需在 Management Server 上启用 JMX,请在编辑器中打开 /opt/apigee/edge-management-server/bin/start。您应该会看到以下用于启动 Management Server 的行:
exec $JAVA -classpath "$classpath" -Xms$min_mem -Xmx$max_mem $xx_opts -Djava.security.auth.login.config=$conf_path/jaas.config -Dinstallation.dir=$install_dir $sys_props -Dconf.dir=$conf_path -Ddata.dir=$data_dir $* $debug_options com.apigee.kernel.MicroKernel
修改此行,添加以下内容:
-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
请注意,此行将 Management Server 的 JMX 端口号指定为 1099。按照上表中的定义,为每个组件设置端口号。例如:
exec $JAVA -classpath "$classpath" -Xms$min_mem -Xmx$max_mem $xx_opts -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.security.auth.login.config=$conf_path/jaas.config -Dinstallation.dir=$install_dir $sys_props -Dconf.dir=$conf_path -Ddata.dir=$data_dir $* $debug_options com.apigee.kernel.MicroKernel
保存文件,然后重启组件。例如,如需重启 Management Server,请运行以下命令:
> /opt/apigee/apigee-service/bin/ apigee-service edge-management-server restart
启用 JMX 身份验证并设置 JMX 密码
管理服务器、消息处理器、Qpid 和 Postgres 的监控过程都使用 JMX。JMX 默认处于启用状态,远程 JMX 访问不需要密码。
如需启用 JMX 身份验证,每个组件都有一个 change_jmx_auth 操作,您可以使用该操作启用/停用身份验证并设置 JMX 凭据。
如需启用 JMX 身份验证,请使用以下命令:
> /<inst_root>/apigee/apigee-service/bin/apigee-service comp change_jmx_auth optionsOrConfigFile
其中:
- comp 是 edge-management-server、edge-message-processor、edge-qpid-server 或 edge-postgres-server。
- 选项如下:
- -u:用户名
- -p:密码
- -e:y(启用)或 n(停用)
- 配置文件包含:
- JMX_USERNAME=username
- JMX_ENABLED=y/n
- JMX_PASSWORD=password(如果未设置或未使用 -p 传入,系统会提示您输入)
例如,如需在命令行中使用选项,请运行以下命令:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -u foo -p bar -e y
如果您有配置文件:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -f configFile
如果您在多个节点上运行 Edge,请在所有节点上运行此命令,并指定相同的用户名和密码。
如需在以后停用 JMX 身份验证,请使用以下命令:
> /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server change_jmx_auth -e n
管理服务器
使用 JConsole 监控系统健康检查和进程信息
使用 JConsole(一种符合 JMX 标准的工具)来管理和监控健康检查和进程统计信息。 使用 JConsole,您可以获取 Management Server(或任何服务器)公开的 JMX 统计信息,并在图形界面中显示这些信息。如需详细了解 JConsole 的用法,请参阅 http://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html。
使用 JConsole 和以下服务网址监控通过 JMX 提供的 JMX 属性 (MBean)。
service:jmx:rmi:///jndi/rmi://<ip address>:<port>/platform
其中 <ip address> 是 Management Server(或相应服务器)的 IP 地址。默认情况下,管理服务器的端口为 1099。
下表显示了通用 JMX 统计信息:
|
JMX MBean |
JMX 属性 |
|---|---|
|
内存 |
HeapMemoryUsage |
|
NonHeapMemoryUsage |
|
|
用法 |
|
|
注意:属性值将显示为四个值:committed、init、max 和 used。 |
|
使用 Edge Application API 检查
您可以通过调用以下 CURL 命令对管理服务器(或任何服务器)执行 API 检查:
curl http://<host>:8080/v1/servers/self/up
其中,<host> 是管理服务器的 IP 地址。
此调用会返回“true”和“false”。如果为 true,则表示节点已启动且 Java 服务正在运行。
如果您未收到 HTTP 200 (OK) 响应,则 Edge 无法响应端口 8080 请求。
问题排查
- 登录服务器并运行以下命令:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server status - 如果服务未运行,请启动服务:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server start
使用 Edge 应用 - 用户、组织和部署检查
Management Server 在每个本地安装中将所有其他 Parcel 整合在一起,发挥着至关重要的作用。您可以通过发出以下命令来检查管理服务器上的用户、组织和部署状态:
curl -u userEmail:password http://localhost:8080/v1/users curl -u userEmail:password http://localhost:8080/v1/organizations curl -u userEmail:password http://localhost:8080/v1/organizations/orgname/deployments
系统应针对所有调用显示“已部署”状态。如果这些操作失败,请执行以下操作:
- 检查 Management Server 日志(位于 <inst_root>/apigee/var/log/edge-management-server)中是否存在任何错误。
- 对管理服务器进行调用,以检查其是否正常运行。
- 从 ELB 中移除服务器,然后重启 Management Server。
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server restart
路由器
您可以通过调用以下 CURL 命令对路由器(或任何服务器)执行 API 检查:
curl http://<host>:8081/v1/servers/self/up
其中,host 是路由器的 IP 地址。
此调用会返回“true”和“false”。如果为 true,则表示节点已启动且路由器服务正在运行。
如果您没有收到 HTTP 200 (OK) 响应,则 Edge 无法响应端口 8081 请求。
问题排查
- 登录服务器并运行以下命令:
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-router status - 如果服务未运行,请启动服务
/<inst_root>/apigee/apigee-service/bin/apigee-service edge-router start - 重启后,检查其是否正常运行
curl -v http://localhost:port/v1/servers/self/up
其中,port 对于路由器为 8081,对于消息处理器为 8082。
消息处理器
使用 JConsole 监控系统健康检查和进程信息
按照上述管理服务器的操作说明进行操作。
注意:请确保使用端口 1101。
使用 Edge Application API 检查
按照上述针对路由器的说明进行操作。
注意:请确保使用端口 8082。
使用 JMX 消息流检查
按照上述管理服务器的操作说明进行操作。
注意:请确保使用端口 1101。
Qpid 服务器
使用 JConsole 监控系统健康检查和进程信息
按照上述管理服务器的操作说明进行操作。
注意:请务必使用端口 1102。
使用 Edge Application API 检查
按照上述管理服务器的操作说明进行操作。
注意:请确保使用端口 8083。Qpid Server 还支持以下 CURL 命令:
curl http://<qpid_IP>:8083/v1/servers/self
Postgres 服务器
使用 JConsole 监控系统健康检查和进程信息
按照上述管理服务器的操作说明进行操作。
注意:请确保使用端口 1103。
使用 Edge Application API 检查
按照上述管理服务器的操作说明进行操作。
注意:请确保使用端口 8084。Postgres Server 还支持以下 CURL 命令:
curl http://<postgres_IP>:8084/v1/servers/self
使用 Edge Application 组织和环境检查
您可以通过发出以下 CURL 命令来检查在 Postgres 服务器上初始配置的组织和环境名称:
curl http:// <postgres_IP>:8084/v1/servers/self/organizations
注意:请确保使用端口 8084。
系统应显示组织和环境名称。
使用 Edge Application axstatus 检查
您可以通过发出以下 CURL 命令来验证分析服务器的状态。
curl -u userEmail:password http://<host>:<port>/v1/organizations/<orgname>/environments/<envname>/provisioning/axstatus
系统应为所有分析服务器显示 SUCCESS 状态。上述 CURL 命令的输出如下所示:
{
"environments" : [ {
"components" : [ {
"message" : "success at Thu Feb 28 10:27:38 CET 2013",
"name" : "pg",
"status" : "SUCCESS",
"uuid" : "[c678d16c-7990-4a5a-ae19-a99f925fcb93]"
}, {
"message" : "success at Thu Feb 28 10:29:03 CET 2013",
"name" : "qs",
"status" : "SUCCESS",
"uuid" : "[ee9f0db7-a9d3-4d21-96c5-1a15b0bf0adf]"
} ],
"message" : "",
"name" : "prod"
} ],
"organization" : "acme",
"status" : "SUCCESS"
}PostgreSQL 数据库
使用 check_postgres.pl 脚本
如需监控 PostgreSQL 数据库,您可以使用标准监控脚本 check_postgres.pl,该脚本可在 http://bucardo.org/wiki/Check_postgres 上找到。
注意:脚本 check_postgres.pl 需要安装在每个 Postgres 节点中。
运行脚本之前:
- 确保您已安装 perl-Time-HiRes.x86_64,这是一个 Perl 模块,可实现高分辨率闹钟、休眠、gettimeofday 和间隔计时器。例如,您可以使用以下命令进行安装:
yum install perl-Time-HiRes.x86_64
使用脚本 check_postgres.pl 的 API 调用的默认输出与 Nagios 兼容。安装脚本后,请执行以下检查:
- 数据库大小 - 检查数据库大小:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -include=apigee -action database_size --warning='800 GB' --critical='900 GB' - 数据库的传入连接 - 检查数据库的传入连接数,并与允许的最大连接数进行比较:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action backends - 数据库可用性和性能 - 检查数据库是否正在运行且可用:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action connection - 磁盘可用空间 - 检查磁盘可用空间:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action disk_space --warning='80%' --critical='90%' - 已初始化的组织/环境 - 检查 Postgres 节点中初始化的组织和环境的数量:
check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action=custom_query --query="select count(*) as result from pg_tables where schemaname='analytics' and tablename like '%fact'" --warning='80' --critical='90' --valtype=integer
注意:如果您在使用上述命令时需要任何帮助,请参阅 http://bucardo.org/check_postgres/check_postgres.pl.html。
数据库检查
您可以验证是否已在 PostgreSQL 数据库中创建了正确的表。使用以下命令登录 PostgreSQL 数据库:
psql -h /opt/apigee/var/run/apigee-postgresql/ -U apigee -d apigee
然后运行:
\d analytics."<org>.<env>.fact"
检查 postgres 进程的运行状况
您可以通过调用以下 CURL 命令在 Postgres 机器上执行 API 检查:
http://<postgres_IP>:8084/v1/servers/self/health/
注意:请确保使用端口 8084。
当 postgres 进程处于活跃状态时,它会返回“ACTIVE”状态。如果 postgres 进程未启动并运行,则会返回“INACTIVE”状态。
Postgres 资源
- http://www.postgresql.org/docs/9.0/static/monitoring.html
- http://www.postgresql.org/docs/9.0/static/diskusage.html
- http://bucardo.org/check_postgres/check_postgres.pl.html
Apache Cassandra
使用 JConsole - 监控任务统计信息
使用 JConsole 和以下服务网址监控通过 JMX 提供的 JMX 属性 (MBean)。
service:jmx:rmi:///jndi/rmi://<ip address>:7199/jmxrmi
其中 <ip address> 是 Cassandra 服务器的 IP。
默认情况下,Cassandra 会启用 JMX,并且对 Cassandra 的远程 JMX 访问不需要密码。
如需启用 JMX 身份验证以添加密码,请执行以下操作:
- 修改 /<inst_root>/apigee/customer/application/cassandra.properties。 如果该文件不存在,请创建它。
- 将以下内容添加到该文件中:
conf_cassandra-env_com.sun.management.jmxremote.authenticate=true - 保存文件。
- 将以下文件从 $JAVA_HOME 目录复制到 /<inst_root>/apigee/data/apigee-cassandra/:
cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/data/apigee-cassandra/jmxremote.password
cp ${JAVA_HOME}/lib/management/jmxremote.access $APIGEE_ROOT/data/apigee-cassandra/jmxremote.access - 修改 jmxremote.password 并将用户名和密码添加到该文件:
cassandra password
其中 password 是 JMX 密码。 - 修改 jmxremote.access 并添加以下角色:
cassandra readwrite - 确保这些文件归“apigee”所有,并且文件模式为 400:
> chown apigee:apigee /<inst_root>/apigee/data/apigee-cassandra/jmxremote.*
> chmod 400 /<inst_root>/apigee/data/apigee-cassandra/jmxremote.* - 在 Cassandra 上运行 configure:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure - 重启 Cassandra:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
如需在日后停用身份验证,请执行以下操作:
- 修改 /<inst_root>/apigee/customer/application/cassandra.properties。
- 移除文件中的以下行:
conf_cassandra-env_com.sun.management.jmxremote.authenticate=true - 在 Cassandra 上运行配置:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure - 重启 Cassandra:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra restart
Cassandra JMX 统计信息
|
JMX MBean |
JMX 属性 |
|---|---|
|
ColumnFamilies/apprepo/environments ColumnFamilies/apprepo/organizations ColumnFamilies/apprepo/apiproxy_revisions ColumnFamilies/apprepo/apiproxies ColumnFamilies/audit/audits ColumnFamilies/audit/audits_ref |
PendingTasks |
|
MemtableColumnsCount |
|
|
MemtableDataSize |
|
|
ReadCount |
|
|
RecentReadLatencyMicros |
|
|
TotalReadLatencyMicros |
|
|
WriteCount |
|
|
RecentWriteLatencyMicros |
|
|
TotalWriteLatencyMicros |
|
|
TotalDiskSpaceUsed |
|
|
LiveDiskSpaceUsed |
|
|
LiveSSTableCount |
|
|
BloomFilterFalsePositives |
|
|
RecentBloomFilterFalseRatio |
|
|
BloomFilterFalseRatio |
使用 nodetool 实用程序管理集群节点
nodetool 实用程序是 Cassandra 的命令行界面,用于管理集群节点。该实用程序位于 <inst_root>/apigee/apigee-cassandra/bin。
如需详细了解 nodetool 实用程序,请参阅 http://www.datastax.com/docs/1.0/references/nodetool。
可以在所有 Cassandra 集群节点上进行以下调用:
- 常规环信息(也适用于单个 Cassandra 节点):查找所有节点的“Up”和“Normal”。
[host]# nodetool -h localhost ring
上述命令的输出如下所示:
Address DC Rack Status State Load Owns Token
192.168.124.201 dc1 ra1 Up Normal 1.67 MB 33,33% 0
192.168.124.202 dc1 ra1 Up Normal 1.68 MB 33,33% 56713727820156410577229101238628035242
192.168.124.203 dc1 ra1 Up Normal 1.67 MB 33,33% 113427455640312821154458202477256070484 - 节点的一般信息(每个节点调用一次)
nodetool -h localhost info
上述命令的输出如下所示:
令牌 : 0
Gossip active : true
Load : 1.67 MB
Generation No : 1361968765
正常运行时间 (seconds) : 78108
堆内存 (MB) : 46,80 / 772,00
数据中心 : dc1
Rack : ra1
异常 : 0 - Thrift 服务器的状态(服务客户端 API)
host]# nodetool -h localhost statusthrift
上述命令的输出会将状态显示为“正在运行”。 - 数据流式传输操作的状态:观察 Cassandra 节点的流量
nodetool -h localhost netstats 192.168.124.203
上述命令的输出如下所示:
Mode: NORMAL
Nothing streaming to /192.168.124.203
Nothing streaming from /192.168.124.203
Pool Name Active Pending Completed
Commands n/a 0 1688
Responses n/a 0 292277
Cassandra 监控(界面)
请参阅 datastax opscenter 网址:http://www.datastax.com/products/opscenter。
Cassandra 资源
请参阅以下网址:http://www.datastax.com/docs/1.0/operations/monitoring。
Apache ZooKeeper
正在检查 ZooKeeper 状态
- 确保 ZooKeeper 进程正在运行。ZooKeeper 会将 PID 文件写入 <inst_root>/apigee/var/run/apigee-zookeeper/apigee-zookeeper.pid。
- 测试 ZooKeeper 端口,确保您可以与每个 ZooKeeper 服务器上的端口 2181 和 3888 建立 TCP 连接。
- 确保您可以从 ZooKeeper 数据库中读取值。使用 ZooKeeper 客户端库(或 /<inst_root>/apigee/apigee-zookeeper/bin/zkCli.sh)进行连接,并从数据库中读取值。
- 检查状态:
> /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-zookeeper status
使用 ZooKeeper 四字母单词
您可以通过使用 netcat (nc) 或 telnet 发送到端口 2181 的一小组命令(四个字母的字词)来监控 ZooKeeper。
如需详细了解 ZooKeeper 命令,请参阅:http://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands。
例如:
- srvr:列出服务器的完整详细信息。
- stat:列出服务器和已连接客户端的简要详细信息。
可以向 ZooKeeper 端口发出以下命令:
- 运行四字母命令 ruok,测试服务器是否在无错误状态下运行。成功的响应会返回“imok”。
echo ruok | nc <host> 2181
返回:
imok - 运行四字母命令 stat,列出服务器性能和已连接客户端的统计信息。
echo stat | nc <host> 2181
返回:
Zookeeper version: 3.4.5-1392090, built on 09/30/2012 17:52 GMT
Clients:
/0:0:0:0:0:0:0:1:33467[0](queued=0,recved=1,sent=0)
/192.168.124.201:42388[1](queued=0,recved=8433,sent=8433)
/192.168.124.202:42185[1](queued=0,recved=1339,sent=1347)
/192.168.124.204:39296[1](queued=0,recved=7688,sent=7692)
Latency min/avg/max: 0/0/128
Received: 26144
Sent: 26160
Connections: 4
Outstanding: 0
Zxid: 0x2000002c2
Mode: follower
Node count: 283
注意:有时,查看 ZooKeeper 是处于 leader、follower 还是 observer 模式非常重要。 - 如果 netcat (nc) 不可用,您可以使用 python 作为替代方案。 创建一个名为 zookeeper.py 的文件,其中包含以下内容:
import time, socket,
sys c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
c.connect((sys.argv[1], 2181))
c.send(sys.argv[2])
time.sleep(0.1)
print c.recv(512)
现在运行以下 Python 行:
python zookeeper.py 192.168.124.201 ruok
python zookeeper.py 192.168.124.201 stat
OpenLDAP
LDAP 级别测试
您可以监控 OpenLDAP,查看特定请求是否得到正确处理。换句话说,检查特定搜索是否返回正确的结果。
- 使用 ldapsearch (yum install openldap-clients) 查询系统管理员的条目。此条目用于对所有 API 调用进行身份验证。
ldapsearch -b "uid=admin,ou=users,ou=global,dc=apigee,dc=com" -x -W -D "cn=manager,dc=apigee,dc=com" -H ldap://localhost:10389 -LLL
然后,系统会提示您输入 LDAP 管理员密码:
Enter LDAP Password:
输入密码后,您会看到以下形式的响应:
dn: uid=admin,ou=users,ou=global,dc=apigee,dc=com
objectClass: organizationalPerson
objectClass: person
objectClass: inetOrgPerson
objectClass: top
uid: admin
cn: admin
sn: admin
userPassword:: e1NTSEF9bS9xbS9RbVNXSFFtUWVsU1F0c3BGL3BQMkhObFp2eDFKUytmZVE9PQ=
=
mail: opdk@apigee.com - 检查管理服务器是否仍连接到 LDAP 问题:
curl -u <userEMail>:<password> http://localhost:8080/v1/users/<ADMIN>
返回:
{
"emailId" : <ADMIN>,
"firstName" : "admin",
"lastName" : "admin"
}
您还可以监控 OpenLDAP 缓存,这有助于减少磁盘访问次数,从而提高系统性能。监控并调整 OpenLDAP 服务器中的缓存大小可能会严重影响目录服务器的性能。您可以查看日志文件 (<inst_root>/apigee/var/log) 以获取有关缓存的信息。