Sunday, July 12, 2020

Install APEX with deploying ORDS in WebLogic as Web listener

The installation is completed on Oracle Linux 7.5, and following components/ applications are installed,

    JDK 1.8.0_241
    Weblogic 12.2.1.4.0
    Oracle Application Express (APEX) 19.2
    Oracle REST Data Services (ORDS) 19.4

1. Install JDK 1.8

Oracle WebLogic Server 12.2.1.4.0 and its quick installer requires JDK 1.8.0_211 (Java SE 8u211). Current available update of Java SE 8 is 241 (JDK 1.8.0_241) which is newer/higher than requirements. Technically, it is not bad idea to install newer updates of same version than required. However, it is not recommended to install higher version such as Java SE 13.

Download JDK 1.8.0_241 from official website (https://www.oracle.com/java/technologies/javase-downloads.html)

Make sure you are choosing correct OS version and preferred format. I am going to install on Linux x86_64 and prefer compressed archive format, the downloaded file is jdk-8u241-linux-x64.tar.gz.

Extract JDK files under /u01/jdk1.8.0_241
[oracle@host01]$ cd /u01
[oracle@host01]$ tar zxf /u01/stage/jdk-8u241-linux-x64.tar.gz
[oracle@host01]$ /u01/jdk1.8.0_241/bin/java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b26, mixed mode)

2. Install/configure Weblogic 12.2.1.4.0

Download Weblogic Server 12.2.1.4.0 (file fmw_12.2.1.4.0_wls_Disk1_1of1.zip) from official website (https://www.oracle.com/middleware/technologies/fusionmiddleware-downloads.html)

Extract jar file fmw_12.2.1.4.0_wls.jar from the downloaded file zip file fmw_12.2.1.4.0_wls_Disk1_1of1.zip
[oracle@host01]$ cd /u01/stage
[oracle@host01]$ unzip fmw_12.2.1.4.0_wls_Disk1_1of1.zip
Archive:  fmw_12.2.1.4.0_wls_Disk1_1of1.zip
  inflating: fmw_12.2.1.4.0_wls.jar
  inflating: fmw_12214_readme.html

2.1 Launch the installation program by running java -jar as following,

/u01/jdk1.8.0_241/bin/java -jar /u01/stage/fmw_12.2.1.4.0_wls.jar


The installation program shows a series of screens.

* Installation Inventory Setup

On UNIX operating systems, this screen opens if this is the first time you are installing any Oracle product on this host. Specify the location where you want to create your central inventory. Make sure that the operating system group name selected on this screen has write permissions to the central inventory location.

    Inventory Directory:     /u01/oraInventory
Operating System Group:  oinstall
* Auto Updates

If you enable Auto Updates, the installer checks for new versions of this software.

Keep the default setting Skip Auto Updates if you do not want your system to check for software updates at this time.

Click Select patches from directory to navigate to a local directory if you downloaded patch files.

Select Search My Oracle Support for Updates to automatically download software updates if you have a My Oracle Support account. You must enter Oracle Support credentials then click Search. To configure a proxy server for the installer to access My Oracle Support, click Proxy Settings . Click Test Connection to test the connection. 

* Installation Location

Use this screen to specify your Oracle home directory location.

  /u01/Middleware/Oracle_Home
   
* Installation Type

  To create the standard installation topology for WebLogic Server and Coherence, select WebLogic Server.   

* Prerequisite Checks

  Verifies that your system meets the minimum necessary requirements. If you see a warning or error message, fix the issues before continue.
  
* Installation Summary

  Use this screen to verify the installation options you chose.  
  
* Installation Progress
  Shows the installation progress  
 
* Installation Complete
  Opens when installation is complete. The next step is to launch the Configuration Wizard to create a WebLogic domain. 
 
  Select Automatically Launch the Configuration Wizard. After you click Finish, the Configuration Wizard starts and you can configure a domain.
  
  
2.2 Start Configuration Wizard to Configure the Domain

* Configuration Type

  Select Create a new domain, enter Domain Location or take default /u01/Middleware/Oracle_Home/user_projects/domains/base_domain
 
* Configuration Templates

  Choose Basic WebLogic Server Domain [wlserver]

* Administrator Account

  Name: weblogic
  Password: weblogic9
  
  I am using simple password weblogic for demonstration purpose. Password complexity policy should be used for your production environment.

* Domain Mode and JDK

  Domain Mode: Production
  JDK: Default (which is used to start installer)

* Advanced Configuration

  Choose all three options (Administration Server, Node Manager, Topology)
  
* Administration Server

  Server Name: AdminServer
  Listen Address: All Local Addresses
  Listen Port: 7001
  Enable SSL: Yes
  SSL Listen Port: 7002  
  
* Node Manager
  
  Node Manager Type: Per Domain Default Location
  Node Manager Credentials
       Username:  weblogic
   Password:  weblogic9
   
  The user name and password do not have to be same as Administrator Account created before. For sample, I just used same user name, but they are actually two different accounts.
   
* Managed Servers

  Click Add, then enter 

  Server Name: ords
  Listen Address: All Local Addresses
  Listen Port: 7003
  Enable SSL: Yes
  SSL Listen Port: 7503

* Clusters
 
  Skip this step

* Server Templates

  Skip this step

* Machines

  Click Add, and enter

  Name: host01.lab.dbaplus.ca
  Node Manager Listen Address: 137.15.49.110
  Node Manager Listen Port: 5556

  Here, the Name do not have to be same as the host name for weblogic server, Node Manager Listen Address should be IP or host name of this weblogic server.
  
* Assign Servers to Machines

  In the Machines pane, select the machine you want to assign the servers to; in this case, host01.lab.dbaplus.ca.
  In the Servers pane, select AdminServer & other managed servers created before, then click on the right arrow to move it beneath the selected machine (host01.lab.dbaplus.ca) in the Machines pane.
  
* Virtual Targets

  Skip

* Partitions

  skip

* Configuration Summary

  Click Create.

* Configuration Progress

  Click Next.

* End of Configuration

  Click Finish
  
2.3 Start/stop Node Manager & WebLogic Server

Start Node Manager & WebLogic Server for first time, and it will initialize the configuration.

Start Node Manager
[oracle@host01]$ cd /u01/Middleware/Oracle_Home/user_projects/domains/base_domain/bin
[oracle@host01]$ nohup ./startNodeManager.sh > nohup.out &

The Node Manager is started and running if startNodeManager.sh process can be found as following
[oracle@host01]$  ps -ef | grep startNodeManager.sh | grep -v grep
oracle    8382  3979  0 19:35 pts/2    00:00:00 /bin/sh ./startNodeManager.sh
oracle    8383  8382  0 19:35 pts/2    00:00:00 /bin/sh /u01/Middleware/Oracle_Home/wlserver/server/bin/startNodeManager.sh

Start WebLogic Admin server
[oracle@host01]$ cd /u01/Middleware/Oracle_Home/user_projects/domains/base_domain
[oracle@host01]$ ./startWebLogic.sh

The server will be started in interactive mode and you will be asked for user name and password which is WebLogic Administration Account created in step 2.2. The startup script will not return to OS prompt until WebLogic Server is stopped.

Stop Weblogic by press Ctrl + C on the console where startWebLogic.sh is running.

Stop Node Manger as following
[oracle@host01]$ cd /u01/Middleware/Oracle_Home/user_projects/domains/base_domain/bin
[oracle@host01]$ ./stopNodeManager.sh

Create file boot.properties for startWeblogic.sh to be started without asking for user name and password
[oracle@host01]$ mkdir -p /u01/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/security
[oracle@host01]$ cd /u01/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/security
[oracle@host01]$ echo "username=weblogic" >> boot.properties
[oracle@host01]$ echo "password=weblogic9" >> boot.properties
[oracle@host01]$ chmod 600 boot.properties  

Here, the username and password is the WebLogic Administration Account created in step 2.2. The file will be created under directory 

  /u01/Middleware/Oracle_Home/user_projects/domains/base_domain/servers/AdminServer/security

And the file includes following two lines

  username=weblogic
  password=weblogic9
   
The username and password will be encrypted after WebLogic is started once. It will become something like following,

  password={AES256}cPuY0lfChDhZcHs4emvZu2bG4VmbpxaXXEfMVcPxqCE\=
  username={AES256}w3A70pQ/v/MUMEStT9RCL/thg1jcEI13pGnVFG9pr1s\=

Start Node Manager & WebLogic Server in background
[oracle@host01]$ NMLOG=NM_start.log
[oracle@host01]$ WLLOG=WL_start.log
[oracle@host01]$ DOMAIN_HOME="/u01/Middleware/Oracle_Home/user_projects/domains/base_domain"
[oracle@host01]$ ${DOMAIN_HOME}/bin/startNodeManager.sh 1>${NMLOG} 2>${NMLOG} &
[oracle@host01]$ ${DOMAIN_HOME}/bin/startWebLogic.sh >${WLLOG} 2>${WLLOG} &
   
Following command can be used to stop WebLogic Server running in background,

  ${DOMAIN_HOME}/bin/stopWebLogic.sh
   
Following command can be used to stop WebLogic Server running in background,

  ${DOMAIN_HOME}/bin/stopNodeManager.sh
  
Here, value of environment variable DOMAIN_HOME is directory /u01/Middleware/Oracle_Home/user_projects/domains/base_domain. 
   
3. Install APEX   
   
Download the file apex_19.2.zip from the Oracle Application Express download page (https://www.oracle.com/tools/downloads/apex-downloads.html) 
   
Unzip downloaded zip file
[oracle@host01]$ unzip -q -d /u01 /u01/stage/apex_19.2.zip
[oracle@host01]$ ls -l /u01/apex/apexins.sql
-rw-r--r--. 1 oracle oinstall 5572 Jan 19  2018 /u01/apex/apexins.sql
[oracle@host01]$ ls -ld /u01/apex/images
drwxr-xr-x. 32 oracle oinstall 28672 Nov  6  2019 /u01/apex/images

Here, script apexins.sql is APEX installation script, and APEX image directory /u01/apex/images will be used by Oracle REST Data Services (ORDS) installation.

Connect to database as SYS to run APEX installation script
[oracle@host01]$ cd /u01/apex
[oracle@host01]$ sqlplus sys/oracle@orcl as sysdba
[oracle@host01]$ sys@orcl> @apexins.sql SYSAUX SYSAUX TEMP /i/

Here, /i/ is the virtual directory for Oracle Application Express images, which will be mapped by ORDS to physical directory /u01/apex/images. Technically, the virtual directory can be customized with more meaningful name (e.g. /image/). However, if you plan to use Embedded PL/SQL Gateway, it has to be /i/ in order to support future APEX upgrades.

Creating Instance Administration Account
[oracle@host01]$ cd /u01/apex
[oracle@host01]$ sqlplus sys/oracle@orcl as sysdba
[oracle@host01]$ sys@orcl> @apxchpwd.sql

The script asks for the administrator's username (default is admin) and password which will be created as APEX instance administration account.

Unlocking the APEX_PUBLIC_USER Account
[oracle@host01]$ sys@orcl>  alter user APEX_PUBLIC_USER identified by oracle account unlock;

APEX_PUBLIC_USER and its password will be asked by ORDS installation.

Configuring RESTful Services
[oracle@host01]$ cd /u01/apex
[oracle@host01]$ sqlplus sys/oracle@orcl as sysdba
[oracle@host01]$ sys@orcl> apex_rest_config.sql;

It creates two new database accounts APEX_LISTENER and APEX_REST_PUBLIC_USER with the passwords you provided, ORDS installation will ask you for their passwords.
   
4. Install Oracle REST Data Services
    
Download Oracle REST Data Services 19.4 (ords-19.4.0.352.1226.zip) from Oracle download website ( https://www.oracle.com/database/technologies/appdev/rest.html). 
   
Unzip downloaded file
[oracle@host01]$ mkdir -p /u01/ords
[oracle@host01]$ cd /u01/ords
[oracle@host01]$ unzip -q /u01/stage/ords-19.4.0.352.1226.zip
  
Setting the Location to store the ORDS configuration data with command 

    java -jar ords.war configdir <directory>
For my installation
[oracle@host01]$ cd /u01/ords
[oracle@host01]$ /u01/jdk1.8.0_241/bin/java -jar ords.war configdir /u01/ords
2020-07-12T02:01:22.918Z INFO   Set config.dir to /u01/ords in: /u01/ords/ords.war

Configure APEX static resources location (images path)

  /u01/jdk1.8.0_241/bin/java -jar ords.war static --context-path <virtual path> <physical directory path>

Sample command output on my system,
[oracle@host01]$ cd /u01/ords
[oracle@host01]$ /u01/jdk1.8.0_241/bin/java -jar ords.war static --context-path /i /u01/apex/images
WAR Generation complete
 WAR location     : /u01/ords/i.war
 Context path     : /i
 Static resources : /u01/apex/images
Ensure the static resources are available at path: /u01/apex/images
on the server where the WAR is deployed

If you use customized virtual path instead of /i/ during APEX installation, use your customized name with the command.

Install ORDS with following command,

  /u01/jdk1.8.0_241/bin/java -jar ords.war install advanced

During installation, it will ask for following information,

* Specify the database connection type to use

  Leave default value [1]

* Name of the database server, Database listen port, Database service name

  Enter your APEX database connection information
 
* Select verify/install Oracle REST Data Services schema

* Enter password of ORDS_PUBLIC_USER, it's a new user will be created

* Administrator username & password

  Enter sys and sys's password in APEX database
  
* Enter default & temporary tablespace for users ORDS_METADATA and ORDS_PUBLIC_USER

* Enter the PL/SQL Gateway database user name [default is APEX_PUBLIC_USER] & its password

* Enter 1 to specify passwords for Application Express RESTful Services database users

  And provide the passwords of the users APEX_LISTENER & APEX_REST_PUBLIC_USER which are created previously during APEX installation.
  
* Enter 2 to exit installation without starting ORDS in standalone mode because we are going to deploy ORDS with WebLogic.

Run command as following on my system  
[oracle@host01]$ /u01/jdk1.8.0_241/bin/java -jar ords.war install advanced
Specify the database connection type to use.
Enter number for [1] Basic  [2] TNS  [3] Custom URL [1]:
Enter the name of the database server [localhost]:host01.lab.dbaplus.ca
Enter the database listen port [1521]:
Enter 1 to specify the database service name, or 2 to specify the database SID [1]:
Enter the database service name:orcl
Enter 1 if you want to verify/install Oracle REST Data Services schema or 2 to skip this step [1]:
Enter the database password for ORDS_PUBLIC_USER:
Confirm password:
Requires to login with administrator privileges to verify Oracle REST Data Services schema.

Enter the administrator username:sys
Enter the database password for SYS AS SYSDBA:
Confirm password:
Connecting to database user: SYS AS SYSDBA url: jdbc:oracle:thin:@//host01.lab.dbaplus.ca:1521/orcl

Retrieving information.
Enter the default tablespace for ORDS_METADATA [SYSAUX]:
Enter the temporary tablespace for ORDS_METADATA [TEMP]:
Enter the default tablespace for ORDS_PUBLIC_USER [USERS]:
Enter the temporary tablespace for ORDS_PUBLIC_USER [TEMP]:
Enter 1 if you want to use PL/SQL Gateway or 2 to skip this step.
If using Oracle Application Express or migrating from mod_plsql then you must enter 1 [1]:
Enter the PL/SQL Gateway database user name [APEX_PUBLIC_USER]:
Enter the database password for APEX_PUBLIC_USER:
Confirm password:
Enter 1 to specify passwords for Application Express RESTful Services database users (APEX_LISTENER, APEX_REST_PUBLIC_USER) or 2 to skip this step [1]:
Enter the database password for APEX_LISTENER:
Confirm password:
Enter the database password for APEX_REST_PUBLIC_USER:
Confirm password:
Enter a number to select a feature to enable [1] SQL Developer Web [2] REST Enabled SQL [3] None [1]:
2020-07-12T01:45:38.060Z INFO   reloaded pools: []
Installing Oracle REST Data Services version 19.4.0.r3521226
... Log file written to /home/oracle/ords_install_core_2020-07-11_214538_00160.log
... Verified database prerequisites
... Created Oracle REST Data Services proxy user
... Created Oracle REST Data Services schema
... Granted privileges to Oracle REST Data Services
... Created Oracle REST Data Services database objects
... Log file written to /home/oracle/ords_install_datamodel_2020-07-11_214547_00888.log
... Log file written to /home/oracle/ords_install_apex_2020-07-11_214549_00048.log
Completed installation for Oracle REST Data Services version 19.4.0.r3521226. Elapsed time: 00:00:12.323

Enter 1 if you wish to start in standalone mode or 2 to exit [1]:2

5. Deploy ORDS applications in WebLogic server

Before deploying ORDS to WebLogic, start Node Manager & WebLogic first.

Launching the Administration Server Console 

   http://host01.lab.dbaplus.ca:7001/console
   
or    
   https://host01.lab.dbaplus.ca:7002/console


Log into console with account created during WebLogic installation, the username is weblogic and password is weblogic9. On the WebLogic console home page, deploy WAR files as followins,

* On the left-hand side Domain Structure pane, click plus sign before Environment, then click Servers from the expanded list.

* On the right-hand 'Summary of Servers' pane, click Control.

  Select ords from Servers list, click Start, then click Yes. 
  
  Click refresh icon and wait for the state of server ords changing to RUNNING.

* On the left-hand side Change Center pane, click Lock & Edit.

* On the left-hand side Domain Structure pane, click Deployments.

* On the right-hand 'Summary of Deployments' pane, click Install.

* Browse to the directory /u01/ords where the WAR files ords.war and i.war reside, mark the radio button next to the WAR file ords.war and click Next.

* Confirm that the radio button next to 'Install this deployment as an application' is marked and click Next.

* Select ords from Servers list, click Next.

  Here, ords is WebLogic managed server created during WebLogic installation in step 2.2.
  
* Leave default value for Security, Source Accessibility and Plan Source Accessibility, click Next.

* Confirm that the radio button next to 'No, I will review the configuration later' is marked and click Finish.

* Window comes back to 'Summary of Deployments'. Click Install and follow same way to install WAR file i.war.

  Now, i and ords will be seen in the Deploments list, and their state is 'distribute Initializing'

* On the left-hand side Change Center pane, click Activate Changes.

  Now, state of i and ords is 'New'.

* On the right-hand 'Summary of Deployments' pane, click Control tab.

* Select i and ords in Deployments list, click Start, then click Servicing all requests.

* On 'Start Application Assistant' pane, click Yes.

* Verifying the State and Health of i and ords

 On the Summary of Deployments, select the Control tab and verify that both the i and ords State are Active and the Health status is OK.

6. Test the installation

   Access APEX internal workspace  
   
     http://host01.lab.dbaplus.ca:7003/ords/apex_admin
   
   or

   https://host01.lab.dbaplus.ca:7503/ords/apex_admin
  
   Enter APEX instance administration account username and password which is created in step 3.
 
Now, I got a funtional APEX instance, which runs in database orcl and uses ORDS running in WebLogic managed server as Web listener.

No comments: