Kaganapan
Mar 17, 9 PM - Mar 21, 10 AM
Sumali sa serye ng meetup upang bumuo ng mga scalable AI solusyon batay sa mga kaso ng paggamit ng tunay na mundo sa mga kapwa developer at eksperto.
Magparehistro naHindi na suportado ang browser na ito.
Mag-upgrade sa Microsoft Edge para samantalahin ang mga pinakabagong tampok, update sa seguridad, at teknikal na suporta.
This tutorial shows you a simple and effective way to implement high availability and disaster recovery (HA/DR) for Java using WebSphere Application Server on Azure Virtual Machines (VMs). The solution illustrates how to achieve a low Recovery Time Objective (RTO) and Recovery Point Objective (RPO) using a simple database-driven Jakarta EE application running on WebSphere Application Server. HA/DR is a complex topic, with many possible solutions. The best solution depends on your unique requirements. For other ways to implement HA/DR, see the resources at the end of this article.
In this tutorial, you learn how to:
The following diagram illustrates the architecture you build:
Azure Traffic Manager checks the health of your regions and routes the traffic accordingly to the application tier. The primary region has a full deployment of the WebSphere cluster. After the primary region is protected by Azure Site Recovery, you can restore the secondary region during the failover. As a result, the primary region is actively servicing network requests from the users, while the secondary region is passive and activated to receive traffic only when the primary region experiences a service disruption.
Azure Traffic Manager detects the health of the app deployed in the IBM HTTP Server to implement the conditional routing. The geo-failover RTO of the application tier depends on the time for shutting down the primary cluster, restoring the secondary cluster, starting VMs, and running the secondary WebSphere cluster. The RPO depends on the replication policy of Azure Site Recovery and Azure SQL Database. This dependency is because the cluster data is stored and replicated in the local storage of the VMs and the application data is persisted and replicated in the Azure SQL Database failover group.
The preceding diagram shows Primary region and Secondary region as the two regions comprising the HA/DR architecture. These regions need to be Azure paired regions. For more information on paired regions, see Azure cross-region replication. The article uses East US and West US as the two regions, but they can be any paired regions that make sense for your scenario. For the list of region pairings, see the Azure paired regions section of Azure cross-region replication.
The database tier consists of an Azure SQL Database failover group with a primary server and a secondary server. The read/write listener endpoint always points to the primary server and is connected to the WebSphere cluster in each region. A geo-failover switches all secondary databases in the group to the primary role. For geo-failover RPO and RTO of Azure SQL Database, see Overview of business continuity with Azure SQL Database.
This tutorial was written with Azure Site Recovery and the Azure SQL Database service because the tutorial relies on the HA features of these services. Other database choices are possible, but you must consider the HA features of whatever database you choose.
Contributor
role in the subscription. You can verify the assignment by following the steps in List Azure role assignments using the Azure portal.In this section, you create an Azure SQL Database failover group in paired regions for use with your WebSphere clusters and app. In a later section, you configure WebSphere to store its session data to this database. This practice references Creating a table for session persistence.
First, create the primary Azure SQL Database by following the Azure portal steps in Quickstart: Create a single database - Azure SQL Database. Follow the steps up to, but not including, the "Clean up resources" section. Use the following directions as you go through the article, then return to this article after you create and configure the Azure SQL Database:
When you reach the section Create a single database, use the following steps:
myResourceGroup
.mySampleDatabase
.sqlserverprimary-mjg022624
.azureuser
.When you reach the section Query the database, use the following steps:
In step 3, enter your SQL authentication server admin sign-in information to sign in.
Note
If sign-in fails with an error message similar to Client with IP address 'xx.xx.xx.xx' is not allowed to access the server, select Allowlist IP xx.xx.xx.xx on server <your-sqlserver-name> at the end of the error message. Wait until the server firewall rules complete updating, then select OK again.
After you run the sample query in step 5, clear the editor and enter the following query, then select Run again:
CREATE TABLE sessions (
ID VARCHAR(128) NOT NULL,
PROPID VARCHAR(128) NOT NULL,
APPNAME VARCHAR(128) NOT NULL,
LISTENERCNT SMALLINT,
LASTACCESS BIGINT,
CREATIONTIME BIGINT,
MAXINACTIVETIME INT,
USERNAME VARCHAR(256),
SMALL VARBINARY(MAX),
MEDIUM VARCHAR(MAX),
LARGE VARBINARY(MAX)
);
After a successful run, you should see the message Query succeeded: Affected rows: 0.
The database table sessions
is used for storing session data for your WebSphere app. The WebSphere cluster data including transaction logs is persisted to local storage of VMs where the cluster is deployed.
Then, create an Azure SQL Database failover group by following the Azure portal steps in Configure a failover group for Azure SQL Database. You just need the following sections: Create failover group and Test planned failover. Use the following steps as you go through the article, then return to this article after you create and configure the Azure SQL Database failover group:
In the section Create failover group, use the following steps:
failovergroup-mjg022624
.sqlserversecondary-mjg022624
.mySampleDatabase
.After you complete all the steps in the section Test planned failover, keep the failover group page open and use it for the failover test of the WebSphere clusters later.
Note
This article guides you to create an Azure SQL Database single database with SQL authentication. A more secure practice is to use Microsoft Entra authentication for Azure SQL for authenticating the database server connection. SQL authentication is required for the WebSphere cluster to connect to the database for session persistence later. For more information, see Configuring for database session persistence.
In this section, you create the primary WebSphere clusters on Azure VMs using the IBM WebSphere Application Server Cluster on Azure VMs offer. The secondary cluster is restored from the primary cluster during the failover using Azure Site Recovery later.
First, open the IBM WebSphere Application Server Cluster on Azure VMs offer in your browser and select Create. You should see the Basics pane of the offer.
Use the following steps to fill out the Basics pane:
was-cluster-eastus-mjg022624
.Use the following steps to fill out the Cluster configuration pane:
Use the following steps to fill out the Load balancer pane:
You should see all fields prepopulated with the defaults in the Networking pane. Select Next to go to the Database pane.
The following steps show you how to fill out the Database pane:
jdbc:sqlserver://failovergroup-mjg022624.database.windows.net:1433;database=mySampleDatabase
.azureuser@failovergroup-mjg022624
.
Note
Be extra careful to use the correct database server hostname and database username for the failover group, instead of the server hostname and username from the primary or backup database. By using the values from the failover group, you are, in effect, telling WebSphere to talk to the failover group. However, ss far as WebSphere is concerned, it's just a normal database connection.
Note
This article guides you to connect to an Azure SQL Database with SQL authentication. A more secure practice is to use Microsoft Entra authentication for Azure SQL for authenticating the database server connection. SQL authentication is required for the WebSphere cluster to connect to the database for session persistence later. For more information, see Configuring for database session persistence.
After a while, you should see the Deployment page where Deployment is in progress is displayed.
Note
If you see any problems during Running final validation..., fix them and try again.
Depending on network conditions and other activity in your selected region, the deployment can take up to 25 minutes to complete. After that, you should see the text Your deployment is complete displayed on the deployment page.
You deployed an IBM HTTP Server (IHS) and a WebSphere Deployment Manager (Dmgr) in the cluster. The IHS acts as load balancer for all application servers in the cluster. The Dmgr provides a web console for cluster configuration.
Use the following steps to verify whether the IHS and Dmgr console work before moving to next step:
Return to the Deployment page, then select Outputs.
Copy the value of the property ihsConsole. Open that URL in a new browser tab. Note that we don't use https
for the IHS in this example. You should see a welcome page of the IHS without any error message. If you don't, you must troubleshoot and resolve the issue before you continue. Keep the console open and use it for verifying the app deployment of the cluster later.
Copy and save aside the value of the property adminSecuredConsole. Open it in a new browser tab. Accept the browser warning for the self-signed TLS certificate. Don't go to production using a self-signed TLS certificate.
You should see the sign-in page of the WebSphere Integrated Solutions Console. Sign in to the console with the user name and password for WebSphere administrator you saved aside previously. If you aren't able to sign in, you must troubleshoot and resolve the issue before you continue. Keep the console open and use it for further configuration of the WebSphere cluster later.
Use the following steps to get the name of the public IP address of the IHS. You use it when you set up the Azure Traffic Manager later.
ihs
, then copy and save aside its name.First, use the following steps to enable the option Synchronize changes with Nodes so that any configuration can be automatically synchronized to all application servers:
Then, use the following steps to configure database distributed sessions for all application servers:
MyCluster
.azureuser@failovergroup-mjg022624
.MyCluster
listed. Select the checkbox next to MyCluster.Keep the console open and use it for app deployment later.
This section shows you how to deploy and run a sample CRUD Java/Jakarta EE application on a WebSphere cluster for disaster recovery failover test later.
You configured application servers to use the datasource jdbc/WebSphereCafeDB
to store session data previously, which enables failover and load balancing across a cluster of WebSphere application servers. The sample app also configures a persistence schema to persist application data coffee
in the same datasource jdbc/WebSphereCafeDB
.
First, use the following commands to download, build, and package the sample:
git clone https://github.com/Azure-Samples/websphere-cafe
cd websphere-cafe
git checkout 20240326
mvn clean package
If you see a message about being in a Detached HEAD
state, this message is safe to ignore.
The package should be successfully generated and located at <parent-path-to-your-local-clone>/websphere-cafe/websphere-cafe-application/target/websphere-cafe.ear. If you don't see the package, you must troubleshoot and resolve the issue before you continue.
Then, use the following steps to deploy the sample app to the cluster:
websphere-cafe
, and then select Start. Wait until you see messages indicating application successfully started. If you aren't able to see the successful message, you must troubleshoot and resolve the issue before you continue.Now, use the following steps to verify that the app is running as expected:
Switch back to the IHS console. Append the context root /websphere-cafe/
of the deployed app to the address bar - for example, http://ihs70685e.eastus.cloudapp.azure.com/websphere-cafe/
, and then press Enter. You should see the welcome page of the sample app.
Create a new coffee with a name and price - for example, Coffee 1 with price $10 - which is persisted into both the application data table and the session table of the database. The UI that you see should be similar to the following screenshot:
If your UI doesn't look similar, troubleshoot and resolve the issue you continue.
In this section, you set up disaster recovery for Azure VMs in the primary cluster using Azure Site Recovery, by following the steps in Tutorial: Set up disaster recovery for Azure VMs. You just need the following sections: Create a Recovery Services vault and Enable replication. Pay attention to the following steps as you go through the article, then return to this article after the primary cluster is protected:
In the section Create a Recovery Services vault, use the following steps:
In step 5 for Resource group, create a new resource group with a unique name in your subscription - for example, was-cluster-westus-mjg022624
.
In step 6 for Vault name, provide a vault name - for example, recovery-service-vault-westus-mjg022624
.
In step 7 for Region, select West US.
Before you select Review + create in step 8, select Next: Redundancy. In the Redundancy pane, select Geo-redundant for Backup Storage Redundancy and Enable for Cross Region Restore.
Note
Make sure you select Geo-redundant for Backup Storage Redundancy and Enable for Cross Region Restore in the Redundancy pane. Otherwise the storage of the primary cluster can't be replicated to the secondary region.
Enable Site Recovery by following the steps in the section Enable Site Recovery.
When you reach the section Enable replication, use the following steps:
For Region, select East US.
For Resource group, select the resource where the primary cluster is deployed - for example, was-cluster-eastus-mjg022624
.
Note
If the desired resource group is not listed, you can select West US for the region first, and then switch back to East US.
Leave the defaults for other fields. Select Next.
was-cluster-westus-mjg022624
.After selecting Enable replication, notice the message Creating Azure resources. Don't close this blade. displayed at the bottom of the page. Do nothing and wait until the pane is closed automatically. You're redirected to the Site Recovery page.
Under Protected items, select Replicated items. Initially, there are no items listed because the replication is still in progress. The replication takes about one hour to complete. Refresh the page periodically until you see that all the VMs are in the Protected state, as shown in the following example screenshot:
Next, create a recovery plan to include all replicated items so that they can fail over together. Use the instructions in Create a recovery plan, with the following customizations:
recovery-plan-mjg022624
.Next, you create a recovery plan. Keep the page open so you can use it for failover testing later.
You also need further network configuration to enable and protect external access to the secondary region in a failover event. Use the following steps for this configuration:
Create a public IP address for Dmgr in the secondary region by following the instructions in Quickstart: Create a public IP address using the Azure portal, with the following customizations:
was-cluster-westus-mjg022624
.dmgr-public-ip-westus-mjg022624
.dmgrmjg022624
.Create another public IP address for IHS in the secondary region by following the same guide, with the following customizations:
was-cluster-westus-mjg022624
.ihs-public-ip-westus-mjg022624
. Write it down.ihsmjg022624
.Create a network security group in the secondary region by following the instructions in the Create a network security group section of Create, change, or delete a network security group, with the following customizations:
was-cluster-westus-mjg022624
.nsg-westus-mjg022624
.Create an inbound security rule for the network security group by following the instructions in the Create a security rule section of the same article, with the following customizations:
nsg-westus-mjg022624
.Associate the network security group with a subnet by following the instructions in the Associate or dissociate a network security group to or from a subnet section of the same article, with the following customizations:
nsg-westus-mjg022624
.In this section, you create an Azure Traffic Manager for distributing traffic to your public facing applications across the global Azure regions. The primary endpoint points to the public IP address of the IHS in the primary region. The secondary endpoint points to the public IP address of the IHS in the secondary region.
Create an Azure Traffic Manager profile by following the instructions in Quickstart: Create a Traffic Manager profile using the Azure portal. You just need the following sections: Create a Traffic Manager profile and Add Traffic Manager endpoints. You must skip the sections where you're directed to create App Service resources. Use the following steps as you go through these sections, then return to this article after you create and configure the Azure Traffic Manager.
In the section Create a Traffic Manager profile, in step 2, for Create Traffic Manager profile, use the following steps:
tmprofile-mjg022624
.myResourceGroupTM1
.When you reach the section Add Traffic Manager endpoints, use the following steps:
myPrimaryEndpoint
, use the following steps:
myFailoverEndpoint
, use the following steps:
myPrimaryEndpoint
is Online and Monitor status for endpoint myFailoverEndpoint
is Degraded.Next, use the following steps to verify that the sample app deployed to the primary WebSphere cluster is accessible from the Traffic Manager profile:
Select Overview for the Traffic Manager profile you created.
Select and copy the domain name system (DNS) name of the Traffic Manager profile, then append it with /websphere-cafe/
- for example, http://tmprofile-mjg022624.trafficmanager.net/websphere-cafe/
.
Open the URL in a new tab of the browser. You should see the coffee you created previously listed on the page.
Create another coffee with a different name and price - for example, Coffee 2 with price 20 - which is persisted into both application data table and session table of the database. The UI that you see should be similar to the following screenshot:
If your UI doesn't look similar, troubleshoot and resolve the issue before you continue. Keep the console open and use it for failover test later.
Now you set up the Traffic Manager profile. Keep the page open and you use it for monitoring the endpoint status change in a failover event later.
To test failover, you manually failover your Azure SQL Database server and cluster, and then fail back using the Azure portal.
First, use the following steps to failover the Azure SQL Database from the primary server to the secondary server:
failovergroup-mjg022624
.Next, use the following steps to failover the WebSphere cluster with the recovery plan:
In the search box at the top of the Azure portal, enter Recovery Services vaults and then select Recovery Services vaults in the search results.
Select the name of your Recovery Services vault - for example, recovery-service-vault-westus-mjg022624
.
Under Manage, select Recovery Plans (Site Recovery). Select the recovery plan you created - for example, recovery-plan-mjg022624
.
Select Failover. Select I understand the risk. Skip test failover.. Leave the default values for other fields and select OK.
Note
You can optionally execute Test failover and Cleanup test failover to make sure everything works as expected before you test Failover. For more information, see Tutorial: Run a disaster recovery drill for Azure VMs. This tutorial tests Failover directly to simplify the exercise.
Monitor the failover in notifications until it completes. It takes about 10 minutes for the exercise in this tutorial.
Optionally, you can view details of failover job by selecting the failover event - for example, Failover of 'recovery-plan-mjg022624' is in progress... - from notifications.
Then, use the following steps to enable the external access to the WebSphere Integrated Solutions Console and sample app in the secondary region:
was-cluster-westus-mjg022624
. Sort items by Type in the Resource Group page.dmgr
. Select IP configurations > ipconfig1. Select Associate public IP address. For Public IP address, select the public IP address prefixed with dmgr
. This address is the one you created previously. In this article, the address is named dmgr-public-ip-westus-mjg022624
. Select Save, and then wait until it completes.ihs
. Select IP configurations > ipconfig1. Select Associate public IP address. For Public IP address, select the public IP address prefixed with ihs
. This address is the one you created previously. In this article, the address is named ihs-public-ip-westus-mjg022624
. Select Save, and then wait until it completes.Now, use the following steps to verify that the failover works as expected:
Find the DNS name label for the public IP address of the Dmgr you created previously. Open the URL of Dmgr WebSphere Integrated Solutions Console in a new browser tab. Don't forget to use https
. For example, https://dmgrmjg022624.westus.cloudapp.azure.com:9043/ibm/console
. Refresh the page until you see the welcome page for sign in.
Sign in to the console with the user name and password for WebSphere administrator that you saved aside previously, and then use the following steps:
In the navigation pane, select Servers > All servers. In the Middleware servers pane, you should see 4 servers listed, including 3 WebSphere application servers consisting of WebSphere cluster MyCluster
and 1 Web server that is an IHS. Refresh the page until you see that all servers are started.
In the navigation pane, select Applications > Application Types > WebSphere enterprise applications. In the Enterprise Applications pane, you should see 1 application - websphere-cafe
- listed and started.
To validate the cluster configuration in the secondary region, follow the steps in the Configure the cluster section. You should see that the settings for Synchronize changes with Nodes and Distributed sessions are replicated to the failover cluster, as shown in the following screenshots:
Find the DNS name label for the public IP address of the IHS you created previously. Open the URL of IHS console appended with the root context /websphere-cafe/
. Note that you must not use https
. This example doesn't use https
for IHS - for example, http://ihsmjg022624.westus.cloudapp.azure.com/websphere-cafe/
. You should see two coffees you created previously listed in the page.
Switch to the browser tab of your Traffic Manager profile, then refresh the page until you see that the Monitor status value of the endpoint myFailoverEndpoint
becomes Online and the Monitor status value of the endpoint myPrimaryEndpoint
becomes Degraded.
Switch to the browser tab with the DNS name of the Traffic Manager profile - for example, http://tmprofile-mjg022624.trafficmanager.net/websphere-cafe/
. Refresh the page and you should see the same data persisted in the application data table and the session table displayed. The UI that you see should be similar to the following screenshot:
If you don't observe this behavior, it might be because the Traffic Manager is taking time to update DNS to point to the failover site. The problem could also be that your browser cached the DNS name resolution result that points to the failed site. Wait for a while and refresh the page again.
Use the following steps to commit the failover after you're satisfied the failover result:
In the search box at the top of the Azure portal, enter Recovery Services vaults and then select Recovery Services vaults in the search results.
Select the name of your Recovery Services vault - for example, recovery-service-vault-westus-mjg022624
.
Under Manage, select Recovery Plans (Site Recovery). Select the recovery plan you created - for example, recovery-plan-mjg022624
.
Select Commit > OK.
Monitor the commit in notifications until it completes.
Select Items in recovery plan. You should see 5 items listed as Failover committed.
Use the following steps to disable the replication for items in the recovery plan and then delete the recovery plan:
For each item in Items in recovery plan, select the ellipsis button (...), and then select Disable Replication.
If you're prompted to provide a reason for disabling protection for this virtual machine, select one you prefer - for example, I completed migrating my application. Select OK.
Repeat step 1 until you disable replication for all items.
Monitor the process in notifications until it completes.
Select Overview > Delete. Select Yes to confirm deletion.
The secondary region is now the failover site and active. You should reprotect it in your primary region.
First, use the following steps to clean up resources that are unused and that the Azure Site Recovery service is going to replicate in your primary region later. You can't just delete the resource group, because the site recovery restores resources into the existing resource group.
was-cluster-eastus-mjg022624
. Sort items by Type on the Resource Group page.Next, use the same steps in the Set up disaster recovery for the cluster using Azure Site Recovery section for the primary region, except for the following differences:
was-cluster-eastus-mjg022624
.recovery-service-vault-eastus-mjg022624
.was-cluster-eastus-mjg022624
.Note
You might notice that Azure Site Recovery supports VM reprotection when the target VM exists. For more information, see the Reprotect the VM section of Tutorial: Fail over Azure VMs to a secondary region. Due to the approach we're taking for WebSphere, this feature doesn't work. The reason is that the only changes between the source disk and the target disk are synchronized for the WebSphere cluster, based on the verification result. To replace the functionality of the VM reprotection feature, this tutorial establishes a new replication from the secondary site to the primary site after failover. The entire disks are copied from the failed over region to the primary region. For more information, see the What happens during reprotection? section of Reprotect failed over Azure virtual machines to the primary region.
Use the same steps in the Failover to the secondary site section to fail back to the primary site including database server and cluster, except for the following differences:
recovery-service-vault-eastus-mjg022624
.was-cluster-eastus-mjg022624
.recovery-service-vault-eastus-mjg022624
.myPrimaryEndpoint
becomes Online and endpoint myFailoverEndpoint
becomes Degraded.was-cluster-westus-mjg022624
.recovery-service-vault-westus-mjg022624
.If you're not going to continue to use the WebSphere clusters and other components, use the following steps to delete the resource groups to clean up the resources used in this tutorial:
myResourceGroup
- in the search box at the top of the Azure portal, and select the matched resource group from the search results.myResourceGroupTM1
.recovery-service-vault-westus-mjg022624
.recovery-plan-mjg022624
.was-cluster-westus-mjg022624
.was-cluster-eastus-mjg022624
.In this tutorial, you set up an HA/DR solution consisting of an active-passive application infrastructure tier with an active-passive database tier, and in which both tiers span two geographically different sites. At the first site, both the application infrastructure tier and the database tier are active. At the second site, the secondary domain is restored with Azure Site Recovery service, and the secondary database is on standby.
Continue to explore the following references for more options to build HA/DR solutions and run WebSphere on Azure:
Kaganapan
Mar 17, 9 PM - Mar 21, 10 AM
Sumali sa serye ng meetup upang bumuo ng mga scalable AI solusyon batay sa mga kaso ng paggamit ng tunay na mundo sa mga kapwa developer at eksperto.
Magparehistro naPagsasanay
Module
Plan and implement updates, backups, and disaster recovery - Training
Plan for disaster recovery.
Sertipikasyon
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.