WebLogic Cluster on the same machine
WebLogic cluster has more than one WebLogic Server running parallel to solve server failovers and provide scalability. Depends on the machine performance like CPU speed, processors, memory and hard disk space, we could add, delete and stop the WebLogic server instance in a cluster while it is running. A cluster is part of a WebLogic domain.
WebLogic provides a web utility called ‘Console’ for a domain. Through the console, Administrator can create, manage and monitor WebLogic cluster, server, and other parameters through a browser. Here I have mentioned ‘Administrator,’ yes, it is a role in WebLogic which can be assigned to a user to become Administrator. Let’s talk about the two main feature of WebLogic cluster, i.e., Failover and stability.
For example, we deployed a web application (war file) on a single WebLogic Server instance. Due to power failure, CPU overload or system crash the server shuts down and stops the web application. Because of that, the application is unavailable to the user. If we deploy the same web application on multiple servers which is in a cluster and if one server goes down, then the application is taken care by remaining running server instances in the cluster. It solves the issue of failovers if any server failed then the remaining running servers in the cluster takes care of the application. The same way we could cluster JMS, JMX data sources, etc.
For example; a web application is deployed on a WebLogic server instance, and 100 users are accessing the application concurrently. The machine where the server is running is capable of handling 150 concurrent users at max. Due to some demand, around 300 users starts using the application at the same time which leads to poor performance. So adding an extra server in the cluster is required to handle the 300 user requests and it will resolve this issue. WebLogic administrator can add or remove server instances without interrupting the service depends on demand.
There are other main features that are part of the cluster are called Session Replication, Load Balancing, Migratable targets which I will cover in my upcoming blog posts. This section we’ve described creating and running WebLogic cluster and deploy a sample web application on the cluster in Windows.
WebLogic should be installed ( WebLogic 12C installation instruction)
Go to <WEBLOGIC_HOME> > common > bin . Double click on the config.cmd file to create a domain (It is config.sh for Linux)
Note: Weblogic_Home is a directory where all the WebLogic software binaries will reside. It usually in <WEBLOGIC_HOME>\wlserver
It opens a config wizard; Input a domain name. A domain consists of cluster, server instances with one AdminServer. The WebLogic console will be deployed on the AdminServer where a user can manage and control server instances. The domain will be created in a location as mentioned here. This is called <DOMAIN_HOME>
Accept default and click next.
Input WebLogic username and password. Save the credentials in a secret location. This is required to log in to WebLogic console.
Choose the Development mode so that WebLogic won’t ask for credentials during the startup
If we choose the Development mode, the WebLogic username and password will be stored in a file boot.properties under <DOMAIN_HOME>\servers\Adminserver\security. The password will be encrypted automatically by the WebLogic server, and it uses this file for authentication during the startup.
Enable all the check boxes and click Next. We will cover each one shortly
Default the Admin server will be running on 7001. Change the port if required. The WebLogic console will be deployed in the AdminServer. The URL of console is http://localhost:7001/console
If SSL is enabled and port is specified, User could access the console with SSL support. For example, https://localhost:port/console
Enable ‘Manual Node Manager Setup and click Next. Node Manager is a Java utility running as a separate process. Using Nodemanager, a user can control the domain remotely. For example, we could start, stop a WebLogic managed server remotely
If credentials are provided in this screen, then node manager asks for username and password during the startup
This screen we add WebLogic Server instances for a cluster. Using the Add button, add WebLogic servers. I have added here two managed servers with port 7003 & 7004.
Note: All servers other than admin server are called <MANAGED SERVER>
This screen, we will add the cluster. Using the Add button, create a cluster
Move the managed servers we’ve created earlier to the cluster as shown below. Here we are adding the managed servers to cluster
A machine is a logical name of the computer where the WebLogic server instances are running. The default port is 5556 that can be updatable on this screen. It is
Add the servers to the machine; now these servers are controlled remotely through node manager
Click Next to Virtual Targets
Click Next to Partitions
Review the summary and click Create
So far we have created a WebLogic domain with the cluster, a machine, and two managed servers. Now we need to start the NodeManager, AdminServer, and Managed servers
Open another command prompt and go to the bin directory again. Run startWebLogic.cmd . This will start the AdminServer
Because of we chose the domain as development mode. The server won’t ask for WebLogic username and password. If you choose production mode, then input the WebLogic username and Password that mentioned in screen four from top of the page
Once the WebLogic completes running. The output shows similar like below
Register WebLogic domain with NodeManager
- Open a command prompt and go to the WEBLOGIC_HOME/server/bin
- Run setWLSEnv.cmd as shown below
3. Enter the following command in the terminal window. (If Java is not in the windows path, the below command will not run)
4. Connect to the WebLogic admin console by entering the following command
connect('<USERNAME>', '<PASSWORD>', 't3://<ADMIN_HOST>:<ADMIN_PORT>')
USERNAME = WebLogic username,
password w= WebLogic password,
Hostname =server name where WebLogic is running,
Port = WebLogic admin server port
For example: connect(‘WebLogic’, ‘weblogic123’, ‘t3://localhost:7001’)
5. Use the nmEnroll command to enroll the WebLogic domain. The nmEnroll requires two arguments where
a) The domain directory
b) The Node Manager home directory
6. Input exit() to exit the node manager
Start Node Manager:
Open a command prompt > Go to the domain directory have created earlier > Go to the bin > Run the setDomainEnv.cmd
The domain directory is under <MIDDLEWARE_HOME>\user_projects\domains\<DOMAIN_NAME>\bin
Go to the bin directory again and run the startNodemanager.cmd as shown below
Allow access if it prompts. Once it finished running, the output will be like below
Start Managed Servers
Now time to start Managed Servers in a cluster. Open a browser and go to the URL http://localhost:7001/console . Input the WebLogic username and password and click login
Expand Environment and Click on the servers on the WebLogic home page. Here you see the AdminServer and managed servers.
The AdminServer is in running mode, and managed servers are in shutdown mode
Click on the control tab > Select the managed servers > Click start
A green text appears on the top and say it started the selected servers
Refresh the browser after few minutes; the server will change in to Running state
Deploy a war file
Download the sample Web application from webapp. Unzip the file and you will find a webapp.war file.
On the Weblogic console, Click on the Deployment > Click Install
Go to the directory where the war file is present > Select the war file > Click Next
Select the cluster and click Next
The webApp active state indicates it is in running mode
Run the application from the two managed servers.
The webapp will display the page like below
Hey wait, Am I going to access the deployed web application in different URL’s even its clustered? The answer is NO; Using load balance, a user would know only one URL to access the application; I’ll brief this in my next post.
The views expressed on this blog are my personal views and do not necessarily reflect the views of my employer.
Please feeling free to reach me on any comments and feedbacks you have. Would be more than glad to listen and reply 🙂
Latest posts by Govind
- How to create a Read-Only-User in Oracle WebLogic server - May 13, 2018
- How to disable Primavera P6 admin config or Application settings from user - May 7, 2018
- How to increase the session timeout in Primavera P6 EPPM - February 28, 2018