Downed localhost(127.0.0.1):9162 主机似乎仍处于关闭状态

Downed localhost(127.0.0.1):9162 host still appears to be down

我正在设置 WSO2 API 经理和 WSO2 BAM。我遵循了下面文章中给出的每一个步骤。

http://umeshagunasinghe.blogspot.com/2013/11/how-to-configure-wso2-api-manager-to.html

当我尝试访问统计页面时,我在终端中看到以下错误。

[2015-02-09 15:04:17,418]  WARN {me.prettyprint.cassandra.connection.CassandraHostRetryService} -  Downed localhost(127.0.0.1):9162 host still appears to be down: Unable to open transport to localhost(127.0.0.1):9162 , java.net.ConnectException: Connection refused

conf/datasources/master-datasources.xml

<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">

    <providers>
        <provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
    </providers>

    <datasources>

        <datasource>
            <name>WSO2_CARBON_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
                    <username>wso2carbon</username>
                    <password>wso2carbon</password>
                    <driverClassName>org.h2.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>


<datasource>
          <name>WSO2AM_STATS_DB</name>
          <description>The datasource used for getting statistics to API Manager</description>
   <jndiConfig>
                <name>jdbc/WSO2AM_STATS_DB</name>
            </jndiConfig>
          <definition type="RDBMS">
          <configuration>
                 <!-- JDBC URL to query the database -->
                 <url>jdbc:h2:/opt/wso2bam-2.4.1/repository/database/APIMGTSTATS_DB;AUTO_SERVER=TRUE</url>
                 <username>wso2carbon</username>
                 <password>wso2carbon</password>
                 <driverClassName>org.h2.Driver</driverClassName>
                 <maxActive>50</maxActive>
                 <maxWait>60000</maxWait>
                 <testOnBorrow>true</testOnBorrow>
                 <validationQuery>SELECT 1</validationQuery>
                 <validationInterval>30000</validationInterval>
            </configuration>
         </definition>
  </datasource>


       <datasource>
           <name>WSO2BAM_CASSANDRA_DATASOURCE</name>
           <description>The datasource used for Cassandra data</description>
           <definition type="RDBMS">
               <configuration>
                   <url>jdbc:cassandra://localhost:9161/EVENT_KS</url>
                   <username>admin</username>
                   <password>admin</password>
               </configuration>
           </definition>
       </datasource>


     <datasource>
            <name>WSO2BAM_UTIL_DATASOURCE</name>
            <description>The datasource used for BAM utilities, such as message store etc..</description>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:cassandra://localhost:9161/BAM_UTIL_KS</url>
                    <username>admin</username>
                    <password>admin</password>
                </configuration>
            </definition>
        </datasource>

                <!-- For an explanation of the properties, see: http://people.apache.org/~fhanik/jdbc-pool/jdbc-pool.html -->
        <!--datasource>
            <name>SAMPLE_DATA_SOURCE</name>
            <jndiConfig>
                <name></name>
                <environment>
                    <property name="java.naming.factory.initial"></property>
                    <property name="java.naming.provider.url"></property>
                </environment>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>

                    <defaultAutoCommit></defaultAutoCommit>
                    <defaultReadOnly></defaultReadOnly>
                    <defaultTransactionIsolation>NONE|READ_COMMITTED|READ_UNCOMMITTED|REPEATABLE_READ|SERIALIZABLE</defaultTransactionIsolation>
                    <defaultCatalog></defaultCatalog>
                    <username></username>
                    <password svns:secretAlias="WSO2.DB.Password"></password>
                    <maxActive></maxActive>
                    <maxIdle></maxIdle>
                    <initialSize></initialSize>
                    <maxWait></maxWait>

                    <dataSourceClassName>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</dataSourceClassName>
                    <dataSourceProps>
                        <property name="url">jdbc:mysql://localhost:3306/Test1</property>
                        <property name="user">root</property>
                        <property name="password">123</property>
                    </dataSourceProps>

                </configuration>
            </definition>
        </datasource-->

    </datasources>

</datasources-configuration>

偏移量设置如下,如指南中所述

<Offset>1</Offset>

我该如何解决这个错误?

如果您使用的是 APIM 1.7,请遵循此文档。我试过一段时间了,效果很好。

Publishing API Runtime Statistics

您使用的相关 API-M 和 BAM 版本是什么?上述文章仅与博客中提到的 API-M 和 BAM 的特定版本相关。最新版本的配置不同。请参考以下 documentation 了解最新的 BAM 和 API-M 集成步骤。

在使用端口偏移时,BAM 2.4(我是 运行 BAM 2.5.0)及以上版本的文档似乎不正确。我首先按照文档发现我的日志一直在尝试连接到我的配置中无效的 cassandra 端口。我使用的偏移量为 1,这会使端口成为 9161。在我的 BAM 日志中,我一直看到它试图连接到端口 9162 的消息。我将 /repository/conf/etc/hector-config.xml 更改回它的默认端口和一切都很好。

https://docs.wso2.com/display/AM180/Publishing+API+Runtime+Statistics

所以在 BAM 2.4.0 及更高版本中,代码似乎考虑了端口偏移量。通过省略上述文档中的步骤 5,我能够正确获取 BAM 运行。