How to install all new WSO2 APIM 2.0.0 features to all new WSO2 GREG 5.0.0


Deployment




  • GReg server will act as both a Publisher and a Store server with no offset

            

  • Two APIM servers will run as a gateway and a key-manager server.

            Gateway offset -2

            KeyManager offset-3

Prerequisites




  1. Create the databases for APIM DB and User DB as those two databases will share across all the servers.

Example -  Simply create three databases in local mysql database call apimgtdb and userdb.

CREATE DATABASE apimgtdb;
CREATE DATABASE userdb;

CREATE DATABASE regdb;

Also add the mysql-connector to all the extracted zip files.(this will be explain later)

Setting Up


GREG Server


  1. Extract and start the server.
  2. Login to management console [https://localhost:9443/carbon] and navigate to feature-manager menu via Configure->Features option.
  3. Click on ‘Add Repository’ button in shown UI page and add the hosted APIM p2-repo location[https://svn.wso2.org/repos/wso2/scratch/apim/release-2.0.0/M2/p2-repo/] as shown below.
         p2.png
  1. Then click on ‘Find features’ button and expand the shown feature ‘API Manager 2.0.0-SNAPSHOT’. You’ll notice there are five sub feature(click on ‘+’) categories as ‘Gateway Manager’,’Gateway Worker’,’Key Manager’,’Publisher’ and ’Store’.
  2. Select both ‘Publisher’ and ‘Store’ from listed feature categories and click ‘install’ button.

       p1.png

    Continue installing these two feature categories until feature installation successful as shown in below.

    p3.png

   p4.png

 p5.png
p6.png
  1. Stop GReg server.
  2. From file-system open api-manager.xml located at {GReg}/repository/conf location and change the below configurations accordingly.

          In <AuthManager> section;

         -- Change the <ServerURL> to match with keymanager servlet transport url.

         Eg: <ServerURL>https://localhost:9446/services/</ServerURL>

          In <APIKeyValidator> section;

         --  Change the <ServerURL> to match with keymanager servlet transport url.

          Eg: <ServerURL>https://localhost:9446/services/</ServerURL>
     
        --  Disable thrift server startup by;
      
         <EnableThriftServer>false</EnableThriftServer>

-- Change RevokeAPIURL;

Eg: <RevokeAPIURL>https://localhost:8246/revoke</RevokeAPIURL>

          In <APIGateway> section;

          -- Change the <ServerURL> to match with gateway  servlet transport url.

          Eg: <ServerURL>https://localhost:9445/services/</ServerURL>

         --  Change the <GatewayEndpoint> to match with gateway  pass-thru transport urls.          
Eg: <GatewayEndpoint>http://localhost:8281,https://localhost:8244</GatewayEndpoint>
   


8)  Remove existing ‘WSO2AM_DB’ datasource configuration in master-datasources.xml and add below configuration.
            [Greg/repository/conf/datasources] pointing to above created APIM DB.
            Additionally define new data-sources for the newly created UserDB ,Registry DB in master-datasources.xml file.
      
           For eg:
    
<datasource>
<name>WSO2AM_DB</name>
<description>The datasource used for the API Manager database</description>
<jndiConfig>
  <name>jdbc/WSO2AM_DB</name>
</jndiConfig>
<definition type="RDBMS">
  <configuration>
    <url>jdbc:mysql://localhost:3306/apimgtdb?autoReconnect=true</url>
    <username>user</username>
    <password>password</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>




Add the UserDB section as well to master-datasources.xml.

<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://localhost:3306/userdb?autoReconnect=true</url>
    <username>user</username>
    <password>password</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>

Add the RegDB section as well to master-datasources.xml.

<datasource>
<name>WSO2RegDB</name>
<description>The datasource used by user manager</description>
<jndiConfig>
  <name>jdbc/WSO2REGDB</name>
</jndiConfig>
<definition type="RDBMS">
  <configuration>
    <url>jdbc:mysql://localhost:3306/regdb?autoReconnect=true</url>
    <username>user</username>
    <password>password</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>


9. Open the user-mgt.xml file [Greg/repository/conf] and add or modify the dataSource property of the <UserStoreManager> element as follows:
<configuration>
   <Property name="dataSource">jdbc/WSO2UM_DB</Property>
</configuration>
11.Download and Copy the mysql JDBC connector to Greg/repository/components/lib

12. Restart the server with -Dsetup.

APIM- KeyManager node


  1.    Extract and open api-manager.xml in APIM/repository/conf location and under <APIKeyValidator> config;
    
              --Change the <RevokeAPIURL> to match with gateway  pass-thru https url.
        
                <RevokeAPIURL>https://localhost:8245/revoke</RevokeAPIURL>

             --  Change the <KeyValidatorClientType> config as ‘WSClient’ and set   
                <EnableThriftServer> as false.

              Eg:   <KeyValidatorClientType>WSClient</KeyValidatorClientType>
                      <EnableThriftServer>false</EnableThriftServer>


    2.   Change <offset> configuration in carbon.xml [ [APIM-KeyManager/repository/conf] as 3.
           Eg:  <Offset>3</Offset>

    3.   Change ‘WSO2AM_DB’ datasource configuration in master-datasources.xml
            [APIM-KeyManager/repository/conf/datasources] pointing to above created APIM  DB.             Additionally define a new  data-source for the newly created UserDB  in
           master-datasources.xml file.
      
            For eg:
    
<datasource>
<name>WSO2AM_DB</name>
<description>The datasource used for the API Manager database</description>
<jndiConfig>
  <name>jdbc/WSO2AM_DB</name>
</jndiConfig>
<definition type="RDBMS">
  <configuration>
    <url>jdbc:mysql://localhost:3306/apimgtdb?autoReconnect=true</url>
    <username>user</username>
    <password>password</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://localhost:3306/userdb?autoReconnect=true</url>
    <username>user</username>
    <password>password</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>

4. Open the user-mgt.xml file [APIM/repository/conf] and add or modify the dataSource property of the <UserStoreManager> element as follows:
<configuration>
   <Property name="dataSource">jdbc/WSO2UM_DB</Property>
</configuration>
5. Download and Copy the mysql JDBC connector to APIM-KeyManager/repository/components/lib
6. Start the server with -Dsetup attribute.

APIM- Gateway node


  1.  Extract and open api-manager.xml in APIM-gateway/repository/conf location.
             In <APIKeyValidator> section;

             --  Change the <ServerURL> to match with keymanager servlet transport url.

              Eg: <ServerURL>https://localhost:9446/services/</ServerURL>

            --  Change the <KeyValidatorClientType> config as ‘WSClient’ and set   
                <EnableThriftServer> as false.

              Eg:   <KeyValidatorClientType>WSClient</KeyValidatorClientType>
                      <EnableThriftServer>false</EnableThriftServer>

   2.   Change <offset> configuration in carbon.xml [ [APIM/repository/conf] as 2 .
           Eg:  <Offset>2</Offset>

3.Navigate to APIM-gateway/repository/deployment/server/synapse-configs/default/api directory and change the endpoint url by pointing to APIKeymanager in all three default shipping APIs named as ‘_TokenAPI.xml’,’_RevokeAPI.xml’ and ‘_AuthorizeAPI.xml’

             Eg:
_TokenAPI.xml
              <endpoint>
                    <http uri-template="https://localhost:9446/oauth2/token">
                       <timeout>
                           <duration>60000</duration>
                           <responseAction>fault</responseAction>
                       </timeout>
                   </http>
               </endpoint>

_RevokeAPI.xml
<endpoint>
                   <http uri-template="https://localhost:9446/oauth2/revoke">

_AuthorizeAPI.xml
<endpoint>
                   <http uri-template="https://localhost:9446/oauth2/authorize">



3. Start the server.


Troubleshoot


Note: As per good practice it is good to do below setup to overcome Host name verification failed issue.

Open the axis2.xml file [APIM-gateway and APIM-keymanager /repository/conf/axis2/] and turn off the host name verification as follows:
(<transportSender name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLSender">)
<parameter name="HostnameVerifier">AllowAll</parameter>

Comments