Get a WSO2 API Manager pack (latest API Manager 1.8.0)
You can download it from here.
Extract the archive file to a preferred location as a folder for API Manager.
I will be referring to it as <APIM_HOME> in this post.
Using MySQL as the database
So that we should copy MySQL JDBC driver to <APIM_HOME>/repository/components/lib directory
Need to point WSO2AM_DB to a MySQL DB
For that you need to change the DB details accordingly in master-datasources.xml which is inside
<APIM_HOME>/repository/conf/datasources
ex :
<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:h2:repository/database
/WSO2AM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
<username>wso2carbon</username>
<password>wso2carbon</password>
<defaultAutoCommit>false</defaultAutoCommit>
<driverClassName>org.h2.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
</configuration>
</definition>
</datasource-->
This is the normal block you get in the API Manager pack. But to point to the MySQL DB the bellow lines need to be changed.
<url>jdbc:mysql://DBlocationIP:Port/DBname?autoReconnect=true</url>
<username>username</username>
<password>password</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
Create a WSO2AM_DB database
Run the mysql.sql (<APIM_HOME>/dbscripts/apimgt) script which is relevant to this DB to create the relevant table
Similar way create 2 DBs for User stores (ex: US1_DB, US2_DB) and run the sql DB scripts (<APIM_HOME>/dbscripts) relevant to them
Start API Manager using the terminal
sh <APIM_HOME>/bin/wso2server.sh
Or you can go inside the <APIM_HOME>/bin and execute the command.
sh wso2server.sh
Or if you did not run the DB scripts you can execute the bellow command. But it is always good to run the relevant DB script parallel to the created DB.
wso2server.sh -Dsetup
Log in to the Management Console using the admin user and click Add New Tenant under Configure menu.
Create the Tenants you need, providing relevant details.
Log in to the Management Console from Tenant 1
Navigate to Configure > User Store Management > Click Add Secondary User Store
Create a user store manager providing relevant details
ex: creating a JDBC User Store Manager
Domain Name : kala1.com
Driver Name : com.mysql.jdbc.Driver
Connection URL : jdbc:mysql://DBlocationIP:Port/US1_DB?autoReconnect=true
Connection Name : MySQLusername
Connection Password : MySQLpassword
Follow the same steps for Tenant 2 pointing the created US2_DB
Then followed the steps in [1]
*To create the IDN_OAUTH2_ACCESS_TOKEN_A and IDN_OAUTH2_ACCESS_TOKEN_B tables added blocks same as CREATE TABLE IDN_OAUTH2_ACCESS_TOKEN in to mysql.sql file inside <APIM_HOME>/dbscripts/apimgt
Restart the server
Log in from the created Tenants to the API Publisher and Store
Create/Publish APIs
Subscribe and generate access tokens
Created tokens should store separately in IDN_OAUTH2_ACCESS_TOKEN_A and IDN_OAUTH2_ACCESS_TOKEN_B tables
[1] - https://docs.wso2.com/display/AM180/Saving+Access+Tokens+in+Separate+Tables
Nice and simple. It is very easy to follow. Keep it up!
ReplyDeleteThank you :)
Delete