如何监控

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

例如,如需在管理服务器上启用 JMX,请在编辑器中打开 /opt/apigee/edge-management-server/bin/start。您应该会看到用于启动管理服务器的以下行:

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 

请注意,此行将管理服务器的 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

保存文件,然后重启组件。例如,重启管理服务器:

> /opt/apigee/apigee-service/bin/ apigee-service edge-management-server restart

启用 JMX 身份验证并设置 JMX 密码

Management Server、Message Processor、Qpid 和 Postgres 的监控过程均使用 JMX。JMX 默认处于启用状态,而远程 JMX 访问不需要密码。

要启用 JMX 身份验证,每个组件都有一个 change_jmx_auth 操作,可用于启用/停用身份验证和设置 JMX 凭据。

如需启用 JMX 身份验证,请使用以下命令:

>  /<inst_root>/apigee/apigee-service/bin/apigee-service comp change_jmx_auth optionsOrConfigFile

其中:

  • compedge-management-server、edge-message-processor、Edge-qpid-serveredge-postgres-server
  • 具体选项包括:
    • -u:用户名
    • -p:密码
    • -e:y(启用)或 n(dsiable)
  • 配置文件包含:
    • JMX_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,您可以使用管理服务器(或任何服务器)公开的 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> 是管理服务器(或相应服务器的 IP 地址)的 IP 地址。默认情况下,管理服务器的端口为 1099。

下表显示了一般 JMX 统计信息:

JMX MBean

JMX 属性

内存

HeapMemoryUsage

NonHeapMemoryUsage

用法

注意:属性值将以四个值显示:commit、init、max 和 used。

使用 Edge Application API 检查

您可以通过调用以下 C网址 命令,在管理服务器(或任何服务器)上执行 API 检查:

curl http://<host>:8080/v1/servers/self/up

其中,<host> 是管理服务器的 IP 地址。

此调用会返回“true”和“false”。如果为 true,则表示节点已启动,并且 Java 服务正在运行。

如果您没有收到 HTTP 200 (OK) 响应,则 Edge 无法响应端口 8080 请求。

问题排查

  1. 登录服务器并运行以下命令:
    /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server status
  2. 如果服务未运行,请启动服务:
    /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server start

使用边缘应用 - 用户、组织和部署检查

在每个本地安装中,管理服务器在将所有其他软件包打包在一起方面发挥着至关重要的作用。您可以通过发出以下命令来检查管理服务器上的用户、组织和部署状态:

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

系统应针对所有调用显示“已部署”状态。如果这些失败,请执行以下操作:

  1. 检查管理服务器日志(在 <inst_root>/apigee/var/log/edge-management-server)是否有任何错误。
  2. 对 Management Server 进行调用,以检查其是否正常运行。
  3. 从 ELB 中移除服务器,然后重启管理服务器。
    /<inst_root>/apigee/apigee-service/bin/apigee-service edge-management-server 重启

路由器

您可以通过调用以下 C网址 命令对路由器(或任何服务器)执行 API 检查:

curl http://<host>:8081/v1/servers/self/up

其中,host 是路由器的 IP 地址。

此调用会返回“true”和“false”。如果为 true,则表示节点已启动,路由器服务正在运行。

如果您没有收到 HTTP 200 (OK) 响应,Edge 将无法响应端口 8081 请求。

问题排查

  1. 登录服务器并运行以下命令:
    /<inst_root>/apigee/apigee-service/bin/apigee-service edge-router status
  2. 如果服务未运行,请启动服务
    /<inst_root>/apigee/apigee-service/bin/apigee-service edge-router start
  3. 重启后,检查它是否正常运行
    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 服务器还支持以下 C网址 命令:

curl http://<qpid_IP>:8083/v1/servers/self

Postgres 服务器

使用 JConsole 监控系统健康检查和进程信息

对于管理服务器,请按照上述步骤操作。

注意:请务必使用端口 1103。

使用 Edge Application API 检查

对于管理服务器,请按照上述步骤操作。

注意:请务必使用端口 8084。Postgres Server 还支持以下 C网址 命令:

curl http://<postgres_IP>:8084/v1/servers/self

使用 Edge 应用组织和环境检查

您可以通过发出以下 C网址 命令来检查在 Postgres Server 上初始配置的组织和环境名称:

curl http:// <postgres_IP>:8084/v1/servers/self/organizations

注意:请务必使用端口 8084。

系统应显示组织和环境名称。

使用 Edge 应用 axstatus 检查

您可以通过发出以下 C网址 命令来验证分析服务器的状态。

curl -u userEmail:password http://<host>:<port>/v1/organizations/<orgname>/environments/<envname>/provisioning/axstatus

系统应显示所有分析服务器的“成功”状态。上述 C网址 命令的输出如下所示:

{
  "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 上找到。

注意:需要在每个 Postgres 节点中安装脚本 check_postgres.pl。

在运行脚本之前,请执行以下操作:

  1. 确保您已安装 perl-Time-HiRes.x86_64,这是一个用于实现高分辨率闹钟、休眠、gettimeofday 和间隔计时器的 Perl 模块。例如,您可以使用以下命令安装它:
    yum install perl-Time-HiRes.x86_64

使用 check_postgres.pl 脚本的 API 调用的默认输出与 Nagios 兼容。安装脚本后,请进行以下检查:

  1. 数据库大小 - 检查数据库大小:
    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'
  2. 数据库的传入连接 - 检查与数据库的传入连接数,并与允许的连接数上限进行比较:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action 后端
  3. 数据库可用性和性能 - 检查数据库是否正在运行以及是否可用:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action connect
  4. 磁盘可用空间 - 检查磁盘空间:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -actiondisk_space --warning='80%' --Critical='90%'
  5. 已完成初始配置的组织/环境 - 检查在 Postgres 节点中首次加入的组织和环境数量:
    check_postgres.pl -H 10.176.218.202 -db apigee -u apigee -dbpass postgres -action=custom_query --query="select count(*) as results from schema pg_integer'like'alert'%

注意:如果您在使用上述命令方面需要任何帮助,请参阅 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 进程的运行状况

您可以调用以下 C网址 命令,在 postgres 机器上执行 API 检查:

http://<postgres_IP>:8084/v1/servers/self/health/

注意:请务必使用端口 8084。

当 postgres 进程处于活动状态时,它会返回“ACTIVE”状态。如果 postgres 进程未启动并运行,则返回“INACTIVE”状态。

Postgres 资源

Apache Cassandra

使用 JConsole - 监控任务统计信息

使用 JConsole 和以下服务网址监控通过 JMX 提供的 JMX 属性 (MBean)。

service:jmx:rmi:///jndi/rmi://<ip address>:7199/jmxrmi

其中 <ip address> 是 Cassandra 服务器的 IP 地址。

默认情况下,系统会为 Cassandra 启用 JMX,并且通过 JMX 远程访问 Cassandra 时不需要密码。

要启用 JMX 身份验证以添加密码,请执行以下操作:

  1. 修改 /<inst_root>/apigee/customer/application/cassandra.properties。如果该文件不存在,请创建一个。
  2. 将以下内容添加到该文件中:
    conf_cassandra-env_com.sun.management.jmxremote.authenticate=true
  3. 保存文件。
  4. 将以下文件从 $JAVA_HOME 目录复制到 /<inst_root>/apigee/data/apigee-cassandra/:
    cp ${JAVA_HOME}/lib/management/jmxremote.password.template $APIGEE_ROOT/data/apigee-cassandra/jlibmx/remotejmx/remotejmx/remotegmx/remotejremote.password/access.password

  5. 修改 jmxremote.password 并将用户名和密码添加到文件中:
    cassandra password

    其中 password 为 JMX 密码。
  6. 修改 jmxremote.access 并添加以下角色:
    cassandra readwrite
  7. 确保文件归“apigee”所有,并且文件模式为 400:
    > chown apigee:apigee /<inst_root>/apigee/data/apigee-cassandra/jmxremote.*
    > chmod 400 /<inst_root>/apigee/data/apigee-cassandra/jmxremote.*
  8. 在 Cassandra 上运行 configure
    > /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
  9. 重启 Cassandra:
    > /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra restart

稍后停用身份验证:

  1. 修改 /<inst_root>/apigee/customer/application/cassandra.properties
  2. 移除该文件中的以下行:
    conf_cassandra-env_com.sun.management.jmxremote.authenticate=true
  3. 在 Cassandra 上运行配置:
    > /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-cassandra configure
  4. 重启 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

“家庭/审核/审计”列

列家庭/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 集群节点上进行以下调用:

  1. 一般环形信息(也可以适用于单个 Cassandra 节点):查找所有节点的“向上”和“正常”。
    [host]# nodetool -h localhost ring

    7 .25 7 6 .2 7 6.67 MB 72 6.67 MB 7 6.67 正常 1.67 MB 7 7 6 .2 7 5 7 6.2 6.4.2 7.3 3 7.2 6.35.2 7.2 3 6.35.2 7.2 3 3.6 1.68.2 7.23 6.23.2 3.16.23.63.23 MB2.63.25.2 1.6Address DC Rack Status State Load Owns Token
    1 192.168.124.201 dc1 Up Normal 1.67 MB .16% 3.16 1.68.2 1.683 MB16 183 6.6.2 3.6 1.68.2 12.283 16.16.23 MB2.16


  2. 有关节点的一般信息(每个节点的调用)
    nodetool -h localhost info

    上述命令的输出如下所示:
    Token : 0
    Gossip active : true
    加载:1.67 MB
    生成编号:1361968765
    正常运行时间(秒):
    acks:
    ack Exception:7

  3. 旧服务器的状态(服务客户端 API)
    host]# nodetool -h localhost statusthrift

    上述命令的输出显示状态显示为“running”。
  4. 流式传输操作的状态:观察 cassandra 节点的流量
    nodetool -h localhost netstats 192.168.124.203

    上述命令的输出如下所示:
    模式:NORMAL
    没有流式传输到 /192.168.12s/Pooln 命令/192.168.120
    1207


Cassandra 监控(界面)

请参阅 datastax opscenter 网址:http://www.datastax.com/products/opscenter

Cassandra 资源

请参阅以下网址:http://www.datastax.com/docs/1.0/operations/monitoring

Apache ZooKeeper

检查 ZooKeeper 状态

  1. 确保 ZooKeeper 进程正在运行。ZooKeeper 将 PID 文件写入 <inst_root>/apigee/var/run/apigee-zookeeper/apigee-zookeeper.pid
  2. 测试 ZooKeeper 端口,以确保您可以与每个 ZooKeeper 服务器上的端口 2181 和 3888 建立 TCP 连接。
  3. 确保您可以从 ZooKeeper 数据库中读取值。使用 ZooKeeper 客户端库(或 /<inst_root>/apigee/apigee-zookeeper/bin/zkCli.sh)进行连接,并从数据库中读取值。
  4. 请检查状态:
    > /<inst_root>/apigee/apigee-service/bin/apigee-service apigee-zookeeper status

使用 ZooKeeper Four Letter Words

可以通过使用 netcat (nc) 或 telnet 将一小组命令(由四个字母的单词)发送到端口 2181 来监控 ZooKeeper。

如需详细了解 ZooKeeper 命令,请参阅:http://zookeeper.apache.org/doc/r3.1.2/zookeeperAdmin.html#sc_zkCommands

例如:

  • srvr:列出服务器的完整详细信息。
  • stat:列出服务器和连接的客户端的简要详细信息。

可以向 ZooKeeper 端口发出以下命令:

  1. 运行由四个字母组成的命令 ruok 以测试服务器是否在无错误状态下运行。如果响应成功,则返回“imok”。
    echo ruok | nc <host> 2181

    返回:
    imok
  2. 运行由四个字母组成的命令 stat ,以列出服务器性能和已连接客户端的统计信息。
    .
















  3. 如果 netcat (nc) 不可用,可使用 Python 作为替代。创建一个名为 zookeeper.py 的文件,其中包含以下内容:
    import time, socket1,
    sys c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    c.connect((sys.argv[1], 2181))
    c.send(sys.argv[2] print2
    .argv[2] print2
    .1d
    .



OpenLDAP

LDAP 级别测试

您可以监控 OpenLDAP 以查看特定请求是否得到了正确处理。换句话说,检查返回正确结果的特定搜索。

  1. 使用 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 组织密码:













  2. 检查管理服务器是否仍连接到 LDAP 问题:
    curl -u <userEMail>:<password> http://localhost:8080/v1/users/<ADMIN>

    返回:
    {
    "emailId" : <ADMIN>,
    "firstName" : "admin",
    "lastName"
    }

您还可以监控 OpenLDAP 缓存,这有助于减少磁盘访问次数,从而提高系统的性能。在 OpenLDAP 服务器中监控然后调整缓存大小,可能会严重影响目录服务器的性能。您可以查看日志文件 (<inst_root>/apigee/var/log),以获取有关缓存的信息。