While creating keys, enterThis page guides you through setting up deployment pattern 1, which is a HA clustered deployment of WSO2 Identity Server. For more information about deployment pattern 1 and its high level architecture, see Deployment Patterns - Pattern 1.
Multiexcerpt
MultiExcerptName
DeploymentIntro
You can install multiple instances of WSO2 products in a cluster to ensure that if one instance becomes unavailable or is experiencing high traffic, another instance will seamlessly handle the requests. For complete information on clustering concepts, see .
Creating a cluster of WSO2 Identity Server instances involves a standard two node cluster for high availability. To ensure that the instances share governance registry artifacts, you must create a JDBC mount.
At a high level, use the following options to cluster Identity Server with a minimum of two nodes. The first section includes instructions on setting up databases. The second section involves setting up a standard two node cluster, the third section involves setting up the Identity Server dashboard in a clustered environment and the third section includes additional configurations if you need to set up a load balancer to front your cluster.
...
Table of Contents
maxLevel
4
minLevel
3
...
Multiexcerpt
MultiExcerptName
DeploymentSteps
Configuring the user store
WSO2 products allow you to configure multiple user stores to store your users and their roles. Your user store can be one of the following:
A Directory Service that can communicate over LDAP protocol like OpenLDAP
Active Directory
A database that can communicate over JDBC
Set up a user store named WSO2UserStore.
Note: The instructions in this tutorial demonstrate configuring a JDBC user store. See for more information on how to set up other types of user stores.
Copy the JDBC driver (in this case MySQL driver) to the <IS_HOME>/repository/component/lib directory of both nodes. To do this, download the MySQL Java connector JAR from here and place it in the <IS_HOME>/repository/components/lib directory.
Point all cluster nodes to the same user store (to share one LDAP directory). By default, WSO2 Identity Server is started with an embedded LDAP which comes with the product. Disable the embedded LDAP of node 2 by modifying embedded-ldap.xml which can be found in the <IS_HOME>/repository/conf/identity directory.
html/xml
Configuring the datasources
Create the databases. See in the WSO2 Administration Guide for db scripts and more information. This tutorial demonstrates deployment with a user management database (WSO2UMDB) and an identity database (IDENTITYDB).
Alternatively, you can create more databases for each type of data to separate the data logically. Note that this will NOT make a difference in performance and is not actually neccessary.
However, if you do wish to separate the data logically into separate databases, see the topic.
Configure the datasource for the databases in both nodes of your cluster in the master-datasources.xml file found in the <IS_HOME>/repository/conf/datasources folder.
The code block below shows a sample configuration of the user mangement database and identity database for a mysql database. For instructions on how to configure the datasource depending on the type of database you created, see in the WSO2 Product Administration Guide.
xmlSample configuration of master-datasources.xmlxmlSample configuration of bps-datasources.xml
Mounting the registry
Mount the governance and configuration registry in the registry.xml file found in the <IS_HOME>/repository/conf folder to share the registry across all nodes in the cluster. The code block below shows a sample configuration.
For more information on mounting the registry, see .
xmlSample configuration of registry.xml
In the registry browser, verify that the governance collection is shown with the symlink icon.
Log in to the management console.
Navigate to Home > Registry > Browse.
Clustering Identity Server for high availability
Follow the instructions below to cluster WSO2 Identity Server.
Install Identity Server on each node.
Do the following changes to the <IS_HOME>/repository/conf/axis2/axis2.xml file for both nodes.
Enable clustering on node 1 and node 2 by setting the clustering element to true: <clustering class="org.wso2.carbon.core.clustering.hazelcast.HazelcastClusteringAgent" enable="true">
Specify the name of the cluster this node will join. <parameter name="domain">wso2.is.domain</parameter>
Use the well knownaddress(WKA) based clustering method. In WKA-based clustering, we need to have a subset of cluster members configured in all the members of the cluster. At least one well knownmemberhasto be operational at all times. <parametername="membershipScheme">wka</parameter>
Configure the localMemberHost and localMemberPort entries. These must be different port values for the two nodes if they are on the same server to prevent any conflicts.
Under the members section, add the hostName and port for each WKA member. As we have only two nodes in our sample cluster configuration, we will configure both nodes as WKA nodes.
xml
Note: You can also use IP address ranges for the hostName. For example, 192.168.1.2-10. This should ensure that the cluster eventually recovers after failures. One shortcoming of doing this is that you can define a range only for the last portion of the IP address. You should also keep in mind that the smaller the range, the faster the time it takes to discover members since each node has to scan a lesser number of potential members.
Configure caching.
From WSO2 Identity Server 5.2.0 onwards, distributed caching is disabled and it is not recommended to use this due to many practical issues that are related to configuring and running distributed caching properly. WSO2 Identity Server employs Hazelcast as the primary method of implementing cluster messages while using distributed caching in a simple setup.
About Clustering
For information on clustering, see .
About Caching
Why caching
Caching is an additional layer on top of databases. It enables to keep the recently used data that are fetched from the database in local memory, so that for subsequent data requests instead of fetching from the database the data can be served from the local memory. Caching has certain advantages and disadvantages that you need to evaluate when deciding on your caching strategy.
Advantages
The load on the underlying database or LDAP is reduced as data is served from already fetched data in memory.
Improved performance due to the reduced number of database calls for repetitive data fetching.
Disadvantages
Coherency problems may occur when the data change is not immediately reflected on cached data if one node or an external system updates the database.
Data in memory can become stale yet be served, e.g., serving data from memory while its corresponding record in the database is deleted.
Caching in WSO2 Identity Server
Historically WSO2 Identity Server used distributed caching to utilize the above-mentioned advantages as well as to minimize the coherence problem. However, in newer deployment patterns where the network is not tightly controlled, distributed caching fail in unexpected ways. Hence, we no longer recommend using distributed caching. Instead, it is recommended to have local caches (if required) and cache invalidation messages (if required) by considering the information given below.
The ForceLocalCache property
When Hazelcast clustering is enabled certain caches act as distributed caches. The ForceLocalCache property within the <cache> section in the carbon.xml file in the <IS_HOME>/repository/conf directory is there to mark that all the caches should act like local caches even in a clustered setup. (This is by default set to true)
Cache invalidation uses Hazelcast messaging to distribute the invalidation message over the cluster and invalidate the caches properly. This is used to minimize the coherence problem in a multi-node setup.
Typical clustered deployment cache scenarios
Scenario
Local Caching
Distributed Caching
Hazelcast Clustering
Distributed Invalidation
Description
1. All caches are local with distributed cache invalidation
Enabled
Not Applicable
Enabled
Enabled
This is the recommended approach.
Hazelcast messaging invalidates the caches.
2. All caches are local without distributed cache invalidation
Enabled
Not Applicable
Disabled
Disabled
Invalidation clears only the caches in specific nodes. Other caches are cleared at cache expiration.
Hazelcast communication is not used.
As the decisions take time to propagate over nodes (default cache timeout is 15 minutes), there is a security risk in this method. To reduce the risk, reduce the default cache timeout period. To learn how to reduce the default cache timeout period, see Configuring Cache Layers - timeout.
3. No caching
Disabled
Disabled
Disabled
Disabled
The data are directly acquired from the database.
Eliminates the security risks caused due to not having cache invalidation.
This method will create a performance degradation due to the lack of caching.
4. Certain caches are disabled while the remaining are local
Enabled for the available local caches
Not Applicable
Enabled
Enabled
To reduce the security risk created in the second scenario and to improve performance in comparison with the third scenario, disable the security-related caches and sustain the performance-related caches as local caches.
This requires identification of these caches depending on the use case.
5. Distributed caching enabled
Disabled—the ForceLocalCache property is set to false.
Enabled
Enabled
Not Applicable
This scenario is only recommended if the network has tight tolerance where the network infrastructure is capable of handling high bandwidth with very low latency.
Typically this applies only when you deploy all the nodes in a single server rack having fiber-optic cables. In any other environments, this implementation will cause cache losses. Thus, this implementation is not recommended for general use.
Configure the following.
Change the datasource name to jdbc/WSO2UserStore in user-mgt.xml (located in <IS_HOME>/repository/conf/). This refers to the user store you configured in the section above.
html/xmluser-mgt.xml
Change the datasource name to jdbc/WSO2IDENTITYDB in identity.xml (located in <IS_HOME>/repository/conf/identity) of both node1 and node2. This refers to the datasource section above.
html/xmlidentity.xml
Changing hostnames and ports
Configure the Identity Server node 1 using the following steps.
Go to the <IS_HOME>/repository/conf/tomcat/catalina-server.xml file and add the proxy port as 443.
xml
In the <IS_HOME>/repository/conf/carbon.xml directory, define the hostname for your server.
html/xml
This hostname is used by the IS cluster. It must be specified in the /etc/hosts file as:
Follow all the configuration steps that were done in node 1 for node 2 as well.
Enabling artifact synchronization
To enable synchronization for runtime artifacts you must have a shared file system. You can use one of the following depending on your environment.
Network File System (NFS): This is one of the most commonly known shared file system and can be used in a linux environment.
Server Message Block (SMB) file system: This can be used in a Windows environment.
Amazon EFS: This can be used in an AWS environment.
Once you have chosen a file system, mount it in the nodes that are participating in the cluster.
Next, create two directories called "Deployment" and "Tenants" in the shared file system.
Create a symlink from the <IS_HOME>/repository/deployment path to the "Deployment" directory of the shared file system that you created in step 2 of this section.
Create a symlink from the <IS_HOME>/repository/tenants path to the "Tenants" directory of the shared file system that you created in step 2 of this section.
Instead of mounting the file system directly to the <IS_HOME>/repository/deployment and <IS_HOME>/repository/tenants paths, a symlink is created to avoid issues that may occur if you delete the product to redeploy it; in which case the file system would get mounted to a non existing path.
Setting up the dashboard
Follow the steps given below to set up the dashboard for the WSO2 Identity Server in a clustered environment.
Change the service provider configuration for the dashboard in the <IS_HOME>/repository/conf/identity/sso-idp-config.xml file.
Configure the proxyHost and proxyHTTPSPort in the <IS_HOME>/repository/deployment/server/jaggeryapps/dashboard/conf/site.json file with your IP or hostname and the port.
Configure the proxyHost and proxyHTTPSPort in the <WSO2IS_HOME>/repository/deployment/server/webapps/shindig/WEB-INF/web.xml file with your IP or hostname and the port.
Optionally, configure the <IS_HOME>repository/conf/datasources/master-datasources.xml file to set up the user dashboard.
Click here to view a sample datasource configuration.
Fronting with a load balancer (Nginx)
If you need to set up the above WSO2 Identity Server cluster with Nginx, you can follow the instructions given below (you must do this after setting up the cluster following the above instructions). When clustering WSO2 Identity Server with a load balancer, make sure to enable sticky sessions. This is required for the management console and the dashboard to work and if we disable temporary session data persistence in the <IS_HOME>/repository/conf/identity/identity.xml file.
Sticky sessions for SSO
Sticky sessions are required to ensure a flawless SSO workflow when temporary session data persistence is disabled. It is recommended to use sticky sessions for SSO in order to have a higher throughput.
For more information on sticky sessions, see . The following is the deployment diagram with the load balancer.
Configuring Nginx
Use the following steps to configure NGINX Plus version 1.7.11 or nginx community version 1.9.2 as the load balancer for WSO2 products. (In these steps, we refer to both versions collectively as "Nginx".)
Install Nginx (NGINX Plus or nginx community) in a server configured in your cluster.
Configure Nginx to direct the HTTP requests to the two worker nodes via the HTTP 80 port using the http://is.wso2.com/<service>. To do this, create a VHost file (is.http.conf) in the /etc/nginx/conf.d directory and add the following configurations into it.
Note: Shown below is a general Nginx configuration. Click this link for more specific configuration with exposing various endpoints:
Nginx configuration with exposing /oauth2, /commonauth, and other endpoints
Nginx configuration with exposing /oauth2, /commonauth, and other endpoints
HTTP configurations
Now that you've configured HTTP requests, you must also configure HTTPS requests. Configure Nginx to direct the HTTPS requests to the two worker nodes via the HTTPS 443 port using https://is.wso2.com/<service>. To do this, create a VHost file (is.https.conf) in the /etc/nginx/conf.d directory and add the following configurations into it.
Note: The configurations for nginx community version and NGINX Plus are different here since the community version does not support the sticky directive.
truenginx Community VersionNGINX Plus
Configure Nginx to access the Management Console as https://mgt.is.wso2.com/carbon via HTTPS 443 port. This is to direct requests to the manager node. To do this, create a VHost file (mgt.as.https.conf) in the /etc/nginx/conf.d directory and add the following configurations into it.
Management Console configurations
Reload the Nginx server. $sudo service nginx reload
If you have made modifications to anything other than the VHost files, you may need to restart the Nginx server instead of reloading:
$sudo service nginx restart
Create SSL certificates
Create SSL certificates for both the manager and worker nodes using the instructions given below.
Execute the following command to import the created certificate file to the client truststore:
Configure the Proxy Port in IS Nodes
By default, WSO2 Identity Server runs on 9443 port. The following steps describe how you can configure a proxy port of 443.
Open <wso2is-5.3.0>/repository/conf/tomcat/catalina-server.xml file and add the proxy port 443 in https connector as follows.
xml
It is not possible to configure proxy port from load balancer itself since there is a post request while authenticating to IS Dashboard. So, If you are planning to use Identity server Dashboard, you must do this configuration. Below configurations are also needed if you are using the dashboard.
Configure proxy port and host in <wso2is-5.3.0> /repository/deployment/server/jaggeryapps/dashboard/conf/site.json file as follows:
xml
Configure proxy port and host in <wso2is-5.3.0>/repository/deployment/server/jaggeryapps/portal/conf/site.json file as follows:
xml
Configure proxy port and host in <wso2is-5.3.0>/repository/deployment/server/webapps/shindig/WEB-INF/web.xml