1. 程式人生 > 其它 >Oracle Weblogic-as-a-Service for vRealize Automation

Oracle Weblogic-as-a-Service for vRealize Automation

Oracle Weblogic-as-a-Service for vRealize Automation

Published:February 15, 2018AutomationCloud-ServicesHow-tovRealize-AutomationvRealize-Suite

Purpose:

Recently I got a request to build a Weblogic-as-a-Service in vRealize Automation for a customer. This post provides details of that custom built Out-of-the-Box Oracle Weblogic-as-a-Service in vRealize Automation.

Requirement:

The requirement is to deploy a Weblogic Cluster as a whole. Also, user should be able to choose any number of nodes in the cluster at runtime. For example, it may be anything within the range 1 to 20, etc.

Solution:

VMware vRealize Automation, vCenter Server and vRealize Orchestrator was used to build the overall solution. Red Hat Linux 7.2 was selected as the base operating system for the Weblogic platform. Provided below are the details of the technologies used:

  • VMware vRealize Automation 7.2 (It should work with other versions as well)
  • VMware vCenter Server 6.0 U3 (Should work with other versions as well)
  • VMware vRealize Orchestrator 7.2 (7.x versions should work)
  • RHEL 7.2
  • Java 1.8.0_151
  • Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
  • Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode
  • Oracle WebLogic Server 12.2.1.3 (Generic)

Pre-Requisites:

Provided below are the pre-requisites for the solution. There are multiple stages of the solution.

  1. A properly installed and configured vRealize Automation should be available
  2. Proper licenses should be available in vRealize Automation
  3. Build out the Template for the solution

Provided below are the steps for building out the Template to be used for the solution.

Step-1: Create a VM and install RHEL 7.2 in it. The VM configuration is as given below:

  • 16GB RAM
  • 8 GB Swap
  • 4 vCPUs
  • /weblogic - 50 GB
  • /weblogs - 50 GB

Also, make sure to run the following commands to install required packages in the base image:

yum install gcc*yum install compat-libcap*yum install compat-libstdc*yum install libaio*
Copy

Step-2: Prepare the RHEL 7.2 VM Template:

Step-3: WebLogic-Common-Environment-Creation

Run the following commands to build the common environment for Weblogic.

/usr/sbin/groupadd -g 666 wladmin

/usr/sbin/useradd -u 666 -g wladmin -G wladmin wladmin

/usr/bin/echo -e "$Pass1\\n$Pass1" | (/usr/bin/passwd --stdin wladmin)

/usr/bin/mkdir -p /WebLogic/oracle/inventory

/usr/bin/chown -R wladmin:wladmin /WebLogic

/usr/bin/chmod -R 775 /WebLogic

/usr/bin/su - wladmin -c "/usr/bin/mkdir -p /WebLogic/oracle/middleware"

/usr/bin/java -version

/usr/bin/touch /etc/oraInst.loc

/usr/bin/echo "inventory_loc=/WebLogic/oracle/inventory" > /etc/oraInst.loc

/usr/bin/echo "inst_group=wladmin" >> /etc/oraInst.loc

/usr/bin/chown wladmin:wladmin /etc/oraInst.loc

/usr/bin/chmod 775 /etc/oraInst.loc
Copy

Step-4: WebLogic-Response-File-Creation

Run the following commands to create the response file

/usr/bin/cat > /WebLogic/oracle/Install.rsp << EOF

[ENGINE]

#DO NOT CHANGE THIS.

Response File Version=1.0.0.0.0

[GENERIC]

#The oracle home location. This can be an existing Oracle Home or a new Oracle Home

ORACLE_HOME=/WebLogic/oracle/middleware


#Set this variable value to the Installation Type selected. e.g. Fusion Middleware Infrastructure, Fusion Middleware Infrastructure With Examples.

INSTALL_TYPE=WebLogic Server

#Provide the My Oracle Support Username. If you wish to ignore Oracle Configuration Manager configuration provide empty string for user name.

MYORACLESUPPORT_USERNAME=

#Provide the My Oracle Support Password

MYORACLESUPPORT_PASSWORD=<SECURE VALUE>

#Set this to true if you wish to decline the security updates. Setting this to true and providing empty string for My Oracle Support username will ignore the Oracle Configuration Manager configuration

DECLINE_SECURITY_UPDATES=true

#Set this to true if My Oracle Support Password is specified

SECURITY_UPDATES_VIA_MYORACLESUPPORT=false

#Provide the Proxy Host

PROXY_HOST=

#Provide the Proxy Port

PROXY_PORT=

#Provide the Proxy Username

PROXY_USER=

#Provide the Proxy Password

PROXY_PWD=<SECURE VALUE>

#Type String (URL format) Indicates the OCM Repeater URL which should be of the format [scheme[Http/Https]]:/[repeater host]:[repeater port]

COLLECTOR_SUPPORTHUB_URL=

EOF
Copy

Step-5: WebLogic-Installation-Prerequisite

/usr/bin/ls -ltr /WebLogic/oracle/middlewareexport WL_HOME=/WebLogic/oracle/middleware/wlserver/usr/bin/cp  /root/fmw_12.2.1.3.0_wls.jar /home/wladmin//usr/bin/chown wladmin:wladmin  /home/wladmin/fmw_12.2.1.3.0_wls.jar/usr/bin/su  - wladmin -c "java -jar /home/wladmin/fmw_12.2.1.3.0_wls.jar -silent -invPtrLoc/etc/oraInst.loc -responseFile /WebLogic/oracle/Install.rsp -logfile /WebLogic/oracle/wlsInstall.log"/usr/bin/ls -ltr /WebLogic/oracle/middleware
Copy

Step-6: Disable Firewall or open firewall ports

We need to either disable the firewall or open ports in the firewall. For this example, we will disable the firewall in the template.

service firewalld stopsystemctl disable firewalld
Copy

Once the Template is ready, export and use it in vRealize Automation.

Blueprint Creation:

Using the above template create a Blueprint in vRealize Automation (as per your requirement). A sample screenshot is provided below:

Blueprint 1

Save the blueprint and follow the process to expose it as a Catalog Item in vRealize Automation.

** Please note, while giving entitlement, please provide “Scale Out (Deployment)” as an Action Item on the items.

Import the vRO Package:

Download the vRO package fromGitHub Repository.

Next, import the vRO package “com.vmware.library.weblogic-as-a-service.package” in vRealize Orchestrator server.

Build the Catalog Item:

Next, build a XaaS catalog item in vRealize Automation. Login to vRA with a user with proper rights to create a XaaS Blueprint. Go to Design à XaaS à XaaS Blueprints. Click on New, in the new window, select “Weblogic-as-a-Service” workflow under the Weblogic-as-a-Service Folder in vRO workflow list. Press next and select all the default values.

Setting up Values in vRO

We need to set up the following values in“Weblogic-as-a-Service”in vRO.

Provided below are few screenshots as an example.

Requesting the Item

Login to the vRealize Automation portal with proper rights. Select the exported Catalog Item and Click on “Request”.

In the next page provide the following details:

  • Enter the number of Cluster Nodes:
  • Enter the Weblogic User Name:
  • Enter the Weblogic User Password:

Once the request is submitted, it will initiate tasks in vRO which in turn will initiate the following serial tasks in vRA.

  • Deploying an instance of the Weblogic Catalog Item
  • Scale out the Deployment from above step as per the number of cluster nodes.
  • Once both the above tasks as finished, rest of the Weblogic installation and configuration will be done in vRO

Once all the above is complete, the original Catalog Item request of “Weblogic-as-a-Service” will complete and marked as “Successful”. A typical successful workflow run in vRO looks like following:

Testing the Deployment

Once the Request is successful, identify the Admin node with the lowest denominator. For example, if you had chosen a 4-node cluster and the nodes are named as weblogic-1, weblogic-2, weblogic-3 and weblogic-4 then weblogic-1 is the Admin node. Remember, the node with lowest number is always the Admin node as it is deployed first.

Note, the IP of the Admin Node. SSH to the admin node and run the following commands:

# cd /WebLogic/oracle/middleware/user_projects/domains/base_domain/bin
# nohup ./startNodeManager.sh &
# nohup ./startWebLogic.sh &
# ./startManagedWebLogic.sh MS-01 http://<IP of Admin Node>:7001
Copy

Note, the last command. MS-01 is the admin node, provide the IP address of Admin node in the URL. After the above open the following URL in a browser:http://:7001/consoleThis will open the Weblogic Console. Login with Weblogic admin user id and password provided at setup time. In my case, the user was“weblogic”.

Workflow Explanation

The vRO workflow is divided into multiple parts.

  • The first part deploys the required number of VM’s in vRA and collects the relevant information about them (IPADDRESS, Hostname etc.)
  • The Second part runs the scripts inside the Guest Operating system of the nodes to install and configure Weblogic Cluster in the nodes.

In the next section, we will elaborate each one of them.

  • First part of the script requests the deployment in vRA. This first VM is considered the Admin node.
  • In the next part, depending on the number of nodes, if a single node cluster is selected, then a Single Node Cluster configuration is set.

The script related to single Node Cluster is provided below:

/usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/wlst.sh" << EOFreadTemplate('/WebLogic/oracle/middleware/wlserver/common/templates/wls/wls.jar')cd('Servers/AdminServer')cmo.setListenAddress("$HostName01.lab.local")setOption('ServerStartMode','prod') set('ListenPort', 7001)create('AdminServer','SSL')cd('SSL/AdminServer')set('Enabled', 'True')set('ListenPort', 7002)cd('/')cd('Security/base_domain/User/weblogic')cmo.setPassword('$weblogicpass')setOption('ServerStartMode','prod')setOption('OverwriteDomain', 'true')writeDomain('/WebLogic/oracle/middleware/user_projects/domains/base_domain')closeTemplate()exit()EOF/usr/bin/echo "Domain Configured on $HostName01.lab.local"/usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/wlst.sh" << EOFreadDomain('/WebLogic/oracle/middleware/user_projects/domains/base_domain')cd('/')create('MS-01', 'Server')cd ('Servers')cd ('MS-01')set('ListenPort', 7004)set('ListenAddress', '$HostName01.lab.local')create('basecluster', 'Cluster')assign('Server', 'MS-01','Cluster','basecluster')cd('Cluster/basecluster')set('ClusterMessagingMode', 'unicast')set('WeblogicPluginEnabled', 'true')cd('/')create('Machine01', 'Machine')assign('Server', 'MS-01','Machine','Machine01')cd('Machines/' + 'Machine01/')create('Machine01', 'NodeManager')cd('NodeManager/' + 'Machine01')set('NMType', 'Plain')set('ListenAddress', '$HostName01.lab.local')set('DebugEnabled', 'false')updateDomain()closeDomain()disconnect()exit()EOFexport DOMAIN_HOME=/WebLogic/oracle/middleware/user_projects/domains/base_domainexport WL_HOME=/WebLogic/oracle/middleware/wlserver/usr/bin/su - wladmin -c "/usr/bin/mkdir -p /WebLogic/oracle/middleware/user_projects/domains/base_domain/servers/AdminServer/security"/usr/bin/su - wladmin -c "/usr/bin/cat > /WebLogic/oracle/middleware/user_projects/domains/base_domain/servers/AdminServer/security/boot.properties" << EOFusername=$weblogicuserpassword=$weblogicpassEOF/usr/bin/su - wladmin -c "/usr/bin/sed -i -e 's/SecureListener=true/SecureListener=false/g' /WebLogic/oracle/middleware/user_projects/domains/base_domain/nodemanager/nodemanager.properties"/usr/bin/su - wladmin -c "nohup /WebLogic/oracle/middleware/user_projects/domains/base_domain/bin/startNodeManager.sh &"/usr/bin/su - wladmin -c "nohup /WebLogic/oracle/middleware/user_projects/domains/base_domain/bin/startWebLogic.sh &"/usr/bin/su - wladmin -c "nohup /WebLogic/oracle/middleware/user_projects/domains/base_domain/bin/startManagedWebLogic.sh MS-01"
Copy
  • Next, build a XaaS catalog item in vRealize Automation. Login to vRA with a user with proper rights to create a XaaS Blueprint. Go to Design à XaaS à XaaS Blueprints. Click on New, in the new window, select “Weblogic-as-a-Service” workflow under the Weblogic-as-a-Service Folder in vRO workflow list. Press next and select all the default values.

    Setting up Values in vRO

    We need to set up the following values in“Weblogic-as-a-Service”in vRO.Provided below are few screenshots as an example.

    Requesting the Item

    Login to the vRealize Automation portal with proper rights. Select the exported Catalog Item and Click on “Request”.

    In the next page provide the following details:

    • Enter the number of Cluster Nodes:
    • Enter the Weblogic User Name:
    • Enter the Weblogic User Password:

    Once the request is submitted, it will initiate tasks in vRO which in turn will initiate the following serial tasks in vRA.

    • Deploying an instance of the Weblogic Catalog Item
    • Scale out the Deployment from above step as per the number of cluster nodes.
    • Once both the above tasks as finished, rest of the Weblogic installation and configuration will be done in vRO
    Once all the above is complete, the original Catalog Item request of “Weblogic-as-a-Service” will complete and marked as “Successful”. A typical successful workflow run in vRO looks like following:

    Testing the Deployment

    Once the Request is successful, identify the Admin node with the lowest denominator. For example, if you had chosen a 4-node cluster and the nodes are named as weblogic-1, weblogic-2, weblogic-3 and weblogic-4 then weblogic-1 is the Admin node. Remember, the node with lowest number is always the Admin node as it is deployed first.

    Note, the IP of the Admin Node. SSH to the admin node and run the following commands:

    # cd /WebLogic/oracle/middleware/user_projects/domains/base_domain/bin
    # nohup ./startNodeManager.sh &
    # nohup ./startWebLogic.sh &
    # ./startManagedWebLogic.sh MS-01 http://<IP of Admin Node>:7001
    
    Copy Note, the last command. MS-01 is the admin node, provide the IP address of Admin node in the URL. After the above open the following URL in a browser:http://:7001/consoleThis will open the Weblogic Console. Login with Weblogic admin user id and password provided at setup time. In my case, the user was“weblogic”.

    Workflow Explanation

    The vRO workflow is divided into multiple parts.

    • The first part deploys the required number of VM’s in vRA and collects the relevant information about them (IPADDRESS, Hostname etc.)
    • The Second part runs the scripts inside the Guest Operating system of the nodes to install and configure Weblogic Cluster in the nodes.
    In the next section, we will elaborate each one of them.
    • First part of the script requests the deployment in vRA. This first VM is considered the Admin node.
    • In the next part, depending on the number of nodes, if a single node cluster is selected, then a Single Node Cluster configuration is set.

    The script related to single Node Cluster is provided below:

/usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/wlst.sh" << EOFreadTemplate('/WebLogic/oracle/middleware/wlserver/common/templates/wls/wls.jar')cd('Servers/AdminServer')cmo.setListenAddress("$HostName01.lab.local")setOption('ServerStartMode','prod') set('ListenPort', 7001)create('AdminServer','SSL')cd('SSL/AdminServer')set('Enabled', 'True')set('ListenPort', 7002)cd('/')cd('Security/base_domain/User/weblogic')cmo.setPassword('$weblogicpass')setOption('ServerStartMode','prod')setOption('OverwriteDomain', 'true')writeDomain('/WebLogic/oracle/middleware/user_projects/domains/base_domain')closeTemplate()exit()EOF/usr/bin/echo "Domain Configured on $HostName01.lab.local"/usr/bin/touch /tmp/answers.txt/usr/bin/cat >> /tmp/answers.txt << EOFreadDomain('/WebLogic/oracle/middleware/user_projects/domains/base_domain')cd('/')create('MS-01', 'Server')cd('Servers')cd('MS-01')set('ListenPort', 7004)set('ListenAddress', '$HostName01.lab.local')EOF
Copy

Next comes the second major part of the Workflow. In this section, we configure the managed nodes.

In this portion, we are dynamically building an answers.txt file which will have all the inputs for the Weblogic Cluster. This file is dynamic as the number of nodes vary and so does the IPADDRESS and Hostname. Let’s break up and elaborate the parts one by one.

The script used in answersBuild1 is provided below:

/usr/bin/cat >> /tmp/answers.txt << EOFcd('/')create('MS-REPLACE', 'Server')cd('Servers')cd('MS-REPLACE')set('ListenPort', 7004)set('ListenAddress', '$HostNameReplace.lab.local')EOF
Copy
  • Next part has the answersbuild2 script.

The script of answersbuild2:

/usr/bin/cat >> /tmp/answers.txt << EOFcd('/')create('basecluster', 'Cluster')assign('Server', 'WEBLOGICSERVERNODES','Cluster','basecluster')cd('Cluster/basecluster')set('ClusterMessagingMode', 'unicast')set('WeblogicPluginEnabled', 'true')cd('/')create('Machine01', 'Machine')assign('Server', 'MS-01','Machine','Machine01')cd('Machines/' + 'Machine01/')create('Machine01', 'NodeManager')cd('NodeManager/' + 'Machine01')set('NMType', 'Plain')set('ListenAddress', '$HostName01.lab.local')set('DebugEnabled', 'false')EOF
Copy
  • Next is answersBuild3 script:
/usr/bin/cat >> /tmp/answers.txt << EOFcd('/')create('MachineREPLACE', 'Machine')assign('Server', 'MS-REPLACE','Machine','Machine02')cd('Machines/' + 'MachineREPLACE/')create('MachineREPLACE', 'NodeManager')cd('NodeManager/' + 'MachineREPLACE')set('NMType', 'Plain')set('ListenAddress', '$HostName02.lab.local')set('DebugEnabled', 'false')EOF
Copy
  • Next is answersBuild4. At this stage our answers.txt file is ready. Now we can simply read this file for the inputs to Weblogic Cluster setup.

The script for answersBuild4:

/usr/bin/cat >> /tmp/answers.txt << EOFupdateDomain()closeDomain()disconnect()exit()EOFcat /tmp/answers.txt/usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/wlst.sh < /tmp/answers.txt" /usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/pack.sh -managed=true -domain=/WebLogic/oracle/middleware/user_projects/domains/base_domain -template=/WebLogic/oracle/middleware/user_projects/domains/base_domain-wlsTemplate.jar -template_name=base_domain"/usr/bin/su - wladmin -c "/usr/bin/mkdir -p /WebLogic/oracle/middleware/user_projects/domains/base_domain/servers/AdminServer/security"/usr/bin/su - wladmin -c "/usr/bin/cat > /WebLogic/oracle/middleware/user_projects/domains/base_domain/servers/AdminServer/security/boot.properties" << EOFusername=$weblogicuserpassword=$weblogicpassEOF/usr/bin/su - wladmin -c "/usr/bin/sed -i -e 's/SecureListener=true/SecureListener=false/g' /WebLogic/oracle/middleware/user_projects/domains/base_domain/nodemanager/nodemanager.properties"
Copy
  • Next, we copy the generated template.jar file to each of the managed nodes
/usr/bin/su - wladmin -c "sshpass -p '$wladminpass' scp -o StrictHostKeyChecking=no  /WebLogic/oracle/middleware/user_projects/domains/base_domain-wlsTemplate.jar  wladmin@$HostNameIPAdd:/WebLogic/"/usr/bin/echo "$HostNameIPAdd  $HostName02.lab.local $HostName02" >> /etc/hosts
Copy
  • At the last stage, we login to each of the managed nodes and unpack the template.jar file in each one of them.

Script for unpackManagedNode:

/usr/bin/echo "$HostName1IPAdd  $HostName1.lab.local $HostName1" >> /etc/hosts/usr/bin/echo "$AdminIPAdd  $Admin.lab.local $Admin" >> /etc/hosts/usr/bin/su - wladmin -c "/usr/bin/mkdir -p  /WebLogic/oracle/middleware/user_projects/domains/base_domain"/usr/bin/su - wladmin -c "/WebLogic/oracle/middleware/oracle_common/common/bin/unpack.sh -domain=/WebLogic/oracle/middleware/user_projects/domains/base_domain -template=/WebLogic/base_domain-wlsTemplate.jar"
Copy

Yet to Do:

Currently, the package cannot do the following:

  • Once the VM's are deployed in vRA and later configuring the Weblogic packages if the workflows fail, the VM's remain in vRA. The VM's are not cleared.
  • As a future option, I plan to add an action item which will let the end user add a number of nodes at a later point in time

Conclusion:

Using the process described in the post you can create Oracle Weblogic-as-a-Service in vRealize Automation environment. As always do let me know if this was helpful to you.