WSO2-AM:API 商店调用在重启后失败

WSO2-AM: API calls in store fail after restart

我们已经安装了最新版本的

在 kubernetes 集群上的单独 pods 中(我们使用现有脚本作为创建 docker 图像的基础),所有共享相关的 MySQL 数据库托管在另一个pod 在同一个集群上。经过大量配置后,一切都按预期工作,我们可以添加 users/roles、create/publish/invoke API 并收集对这些调用的分析。然而,我们面临的最后一个问题是,一旦 API 发布,就可以在商店中调用它。一旦 API-manager pod 重新启动(例如通过扩展相关部署 down/up,而不是使用 carbon 仪表板),一旦 API-Manager 启动并且 运行 在这样的(硬)重启之后,已发布的 API 仍然在商店中可见,但是,如果有人试图调用其中一个(以前工作的)端点,则会出现 404 消息返回并且 API-manager 记录以下错误:

INFO {org.apache.synapse.mediators.builtin.LogMediator} - STATUS = Message dispatched to the main sequence. Invalid URL, RESOURCE = /"context"/"endpoint being called"

其中 "context" 是给定 API 在发布时设置的上下文,"endpoint being called" 是应该接收调用的服务的 REST 端点。此外,如果我们尝试对发布者中的 API 进行更改(即重新发布它),似乎有 50/50 的机会它可以工作并修复所有问题,直到下一次重新启动 pod或者第一步点击"Next: Implement"按钮报错,已经记录了here(虽然说在之前的版本中已经解决了)

剩下的设置如下:

Users/Roles

数据库

摘自大师-datasources.xml 来自上午:

        <datasource>
             <name>WSO2_CARBON_DB</name>
             <description>The datasource used by the registry</description>
             <jndiConfig>
               <name>jdbc/WSO2CarbonDB</name>
             </jndiConfig>
             <definition type="RDBMS">
               <configuration>
                 <url>jdbc:mysql://mysql-apimdb:3306/amcarbondb?autoReconnect=true&amp;useSSL=false</url>
                 <username>wso2carbon</username>
                 <password>abc</password>
                 <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                 <maxActive>50</maxActive>
                 <maxWait>60000</maxWait>
                 <testOnBorrow>true</testOnBorrow>
                 <validationQuery>SELECT 1</validationQuery>
                 <validationInterval>30000</validationInterval>
               </configuration>
             </definition>
        </datasource> 

        <datasource>
            <name>WSO2AM_DB</name>
            <description>The datasource used for API Manager database</description>
            <jndiConfig>
                <name>jdbc/WSO2AM_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:mysql://mysql-apimdb:3306/apimgtdb?autoReconnect=true&amp;useSSL=false</url>
                    <username>wso2carbon</username>
                    <password>abc</password>
                    <defaultAutoCommit>false</defaultAutoCommit>
                    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

        <datasource>
             <name>WSO2UM_DB</name>
             <description>The datasource used by user manager</description>
             <jndiConfig>
               <name>jdbc/WSO2UM_DB</name>
             </jndiConfig>
             <definition type="RDBMS">
               <configuration>
                 <url>jdbc:mysql://mysql-apimdb:3306/userdb?autoReconnect=true&amp;useSSL=false</url>
                 <username>wso2carbon</username>
                 <password>abc</password>
                 <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                 <maxActive>50</maxActive>
                 <maxWait>60000</maxWait>
                 <testOnBorrow>true</testOnBorrow>
                 <validationQuery>SELECT 1</validationQuery>
                 <validationInterval>30000</validationInterval>
               </configuration>
             </definition>
        </datasource>

        <datasource>
            <name>WSO2REG_DB</name>
            <description>The datasource used for registry</description>
            <jndiConfig>
                <name>jdbc/WSO2REG_DB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:mysql://mysql-apimdb:3306/regdb?autoReconnect=true&amp;useSSL=false</url>
                    <username>wso2carbon</username>
                    <password>abc</password>
                    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

所有这些数据库都在使用时填充,并使用来自不同产品的 DBscripts 进行初始化以进行初始设置。此外,registry.xml 配置如下(仅显示更改,文件的其余部分是默认配置的):

<currentDBConfig>wso2registry</currentDBConfig>
<readOnly>false</readOnly>
<enableCache>false</enableCache>
<registryRoot>/</registryRoot>

<dbConfig name="wso2registry">
    <dataSource>jdbc/WSO2CarbonDB</dataSource>
</dbConfig>
<dbConfig name="govregistry">
    <dataSource>jdbc/WSO2REG_DB</dataSource>
</dbConfig>

<remoteInstance url="https://localhost:9943/registry"> 
   <id>gov</id>
   <dbConfig>govregistry</dbConfig>
   <cacheId>wso2carbon@jdbc:mysql://mysql-apimdb:3306/regdb</cacheId>
   <readOnly>false</readOnly>
   <enableCache>false</enableCache>
   <registryRoot>/</registryRoot>
</remoteInstance>

<mount path="/_system/governance" overwrite="true">
       <instanceId>gov</instanceId>
       <targetPath>/_system/governance</targetPath>
</mount>

<mount path="/_system/config" overwrite="true">
       <instanceId>gov</instanceId>
       <targetPath>/_system/config</targetPath>
</mount>

最后,这似乎是一个问题,因为 am pod 上的内存不是持久的,所以重启时一些数据会丢失,因为我们已经将所有数据库移动到另一个 pod 上的持久存储,但是,这应该这会是个问题——除非我们错过了什么。是否还有另一个 registry/data 来源需要 added/changed?上面未显示的所有其他默认数据源(STATS、MB_STORE、METRICS)也设置为使用 MySQL 服务器,因此除非数据源文件夹中提供的数据源以外的其他内容,否则所有数据应保留在相应的 MySQL 数据库中。

我猜您还没有为 API 管理器使用任何持久存储。当您创建 API 时,API 工件会在文件系统中创建并存储在 wso2am-2.1.0/repository/deployment/server/synapse-configs/de‌ fault/api 位置。您需要为 'wso2am-2.1.0/repository/deployment/server/' 提供持久存储。在你的情况下,在重新启动期间,你没有相关数据,因为你有一个新包。

这可以通过移动到以下文件夹的持久卷来解决: 正如建议的那样: /repository/deployment/server

但是,在多租户安装的情况下,还需要持久化: /repository/tenants