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
- Download GREG-5.0.0-SNAPSHOT-M6
- Download APIM-2.0.0-SNAPSHOT-M2
- 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;
Setting Up
GREG Server
- Extract and start the server.
- Login to management console [https://localhost:9443/carbon] and navigate to feature-manager menu via Configure->Features option.
- 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.
- 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’.
- Select both ‘Publisher’ and ‘Store’ from listed feature categories and click ‘install’ button.
Continue installing these two feature categories until feature installation successful as shown in below.
- Stop GReg server.
- 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.
In <APIKeyValidator> section;
-- Change the <ServerURL> to match with keymanager servlet transport url.
-- Disable thrift server startup by;
<EnableThriftServer>false</EnableThriftServer>
-- Change RevokeAPIURL;
Eg: <RevokeAPIURL>https://localhost:8246/revoke</RevokeAPIURL>
-- Change RevokeAPIURL;
Eg: <RevokeAPIURL>https://localhost:8246/revoke</RevokeAPIURL>
In <APIGateway> section;
-- Change the <ServerURL> to match with gateway servlet transport url.
-- Change the <GatewayEndpoint> to match with gateway pass-thru transport urls.
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>
|
12. Restart the server with -Dsetup.
APIM- KeyManager node
- 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.
-- 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>
6. Start the server with -Dsetup attribute.
|
APIM- Gateway node
- 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.
-- 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>
_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
Post a Comment