Showing posts with label APEX. Show all posts
Showing posts with label APEX. Show all posts

May 27, 2024

Batch script to monitor ORDS service and send mail notification it goes down

 

Hi Everyone,

 

Recently I came across an issue where ords service on windows was getting stopped due to some reason. It was hard to monitor as they had no mechanism to monitor this.

 

To mitigate the problem, I wrote a batch script which will monitor ords service’s uptime on windows . The script will send a mail once notifying service has gone down.

 

Save the following script in .bat format and schedule it as per your requirement in task scheduler.

 

@echo off

setlocal enabledelayedexpansion

set my_date=%date%

set my_time=%TIME%

set my_hours=%my_time:~0,2%

set my_minutes=%my_time:~3,2%

set my_seconds=%my_time:~6,2%

 

REM Define variables

set APEX_URL=http://server1.example.com:7799/ords

set MAIL_RECIPIENT='soumya.das@testmail.com'

set SMTP_SERVER=smtp.office365.com

set SMTP_PORT=587

set MAIL_SENDER=notification@example.com

set MAIL_SUBJECT="Oracle APEX URL Status"

set SMTP_USER=emr-notification@example.com

set SMTP_PASSWORD=xyz123#

set SUBJECT="Apex down Alert"

set HOSTNAME=%COMPUTERNAME%

 

REM Check if the URL is accessible

curl -s -o NUL -w "%%{http_code}" %APEX_URL% > D:\response.txt

 

REM Check if D:\response.txt exists

if not exist D:\response.txt (

    REM If D:\response.txt is not present, send email notification

               powershell.exe -command "Send-MailMessage -From '%MAIL_SENDER%' -To %MAIL_RECIPIENT% -Subject '%SUBJECT%' -Body 'Oracle APEX URL is not accessible at %HOSTNAME% .Apex Service is down.' -SmtpServer '%SMTP_SERVER%' -Port %SMTP_PORT% -UseSsl -Credential (New-Object PSCredential('%SMTP_USER%', (ConvertTo-SecureString '%SMTP_PASSWORD%' -AsPlainText -Force)))"

)

 

REM Read the HTTP status code

set /p HTTP_STATUS=<D:\response.txt

 

REM Check if HTTP status code is 000, indicating a failure

if "%HTTP_STATUS%" equ "503" (

    powershell.exe -command "Send-MailMessage -From '%MAIL_SENDER%' -To %MAIL_RECIPIENT% -Subject '%SUBJECT%' -Body 'Oracle APEX URL is not accessible at %HOSTNAME%.Apex Service is down.' -SmtpServer '%SMTP_SERVER%' -Port %SMTP_PORT% -UseSsl -Credential (New-Object PSCredential('%SMTP_USER%', (ConvertTo-SecureString '%SMTP_PASSWORD%' -AsPlainText -Force)))"

) else if "%HTTP_STATUS%" equ "000" (

              powershell.exe -command "Send-MailMessage -From '%MAIL_SENDER%' -To %MAIL_RECIPIENT% -Subject '%SUBJECT%' -Body 'Oracle APEX URL is not accessible at %HOSTNAME%.Apex Service is down.' -SmtpServer '%SMTP_SERVER%' -Port %SMTP_PORT% -UseSsl -Credential (New-Object PSCredential('%SMTP_USER%', (ConvertTo-SecureString '%SMTP_PASSWORD%' -AsPlainText -Force)))"

)

 

REM Cleanup temporary files

del D:\response.txt

 

endlocal

 

April 22, 2024

How to change admin password in Apex 23.2

 

How to change admin password in Apex 23.2

 

In apex , admin password can be changed using two methods such as

Method 1. By executing apxchpwd.sql

Method 2. By executing sql command



Method 1. By executing apxchpwd.sql

Login to Database server  and navigate to apex installation folder and execute apxchpwd.sql as sys user.

 

[oracle@ocisoumya-2 ~]$ cd /u01/apex/apex/

[oracle@ocisoumya-2 apex]$ sqlplus / as sysdba

 

SQL> @apxchpwd.sql

...set_appun.sql

================================================================================

This script can be used to change the password of an Oracle APEX

instance administrator. If the user does not yet exist, a user record will be

created.

================================================================================

Enter the administrator's username [ADMIN]

User "ADMIN" exists.

Enter ADMIN's email [ADMIN]

Enter ADMIN's password []

Changed password of instance administrator ADMIN.

 

 

Method 2. By executing sql command

Login to database as sys user and set the current schema as your existing apex version.

SQL> select username from dba_users where username like 'APEX%';

 

USERNAME

--------------------------------------------------------------------------------

APEX_LISTENER

APEX_PUBLIC_USER

APEX_REST_PUBLIC_USER

APEX_230200

 

SQL> alter session set current_schema=APEX_230200 ;

 

Session altered.

 

SQL> set lines 222

SQL> COLUMN first_name FORMAT A20

SQL> COLUMN last_name FORMAT A20

SQL> COLUMN default_schema FORMAT A30

SQL> COLUMN user_id Format 9999999999999

 

SQL> SELECT user_id, first_name,last_name,

default_schema FROM   wwv_flow_fnd_user WHERE  user_name = 'ADMIN'

ORDER BY last_update_date DESC;  2    3

 

           USER_ID FIRST_NAME           LAST_NAME            DEFAULT_SCHEMA

------------------ -------------------- -------------------- ------------------------------

  1395498604080259                                           APEX_230200

 

SQL>

 

Set the ADMIN user password for the id we retried from above query

 

SQL> UPDATE wwv_flow_fnd_user SET    web_password = 'NewApexPAssword'

WHERE  user_name = 'ADMIN'

AND    user_id = 1395498604080259; 

 

 

Unlock ADMIN user :-

 

SQL> BEGIN

  WWV_FLOW_SECURITY.g_security_group_id := 10;

  WWV_FLOW_FND_USER_API.unlock_account('ADMIN');

  COMMIT;

END;

/

 

 

 

 

April 15, 2024

Oracle REST Data Services (ORDS) Configuration on Linux 8 - Part II

 Before we proceed, the first part that includes apex installation and configuration can be found here

Download ORDS 23.4

Ords can be downloaded from Here

Download oracle JDK 17 +

https://www.oracle.com/in/java/technologies/downloads/#java17

 

Create following directories.

mkdir /u01/apex/ords_23.4

cd /u01/apex/ords_23.4

mkdir /u01/apex/ords_23.4/config

mkdir /u01/apex/ords_23.4/config/ords/standalone/logs

 

Unzip the downloaded directory

[oracle@ocisoumya ords_23.4]$ unzip ords-23.4.0.346.1619.zip -d /u01/apex/ords_23.4/


Install ORDS on linux 8

[oracle@ocisoumya ~]$ cd /u01/apex/ords_23.4/bin

[oracle@ocisoumya bin]$ ./ords --config /u01/apex/ords_23.4/config install --interactive --log-folder /u01/apex/ords_23.4/co              nfig/ords/standalone/logs

2024-04-01T14:40:08.532Z INFO        Your configuration folder /u01/apex/ords_23.4/config is located in ORDS product folder.                Oracle recommends to use a different configuration folder.

 

ORDS: Release 23.4 Production on Mon Apr 01 14:40:08 2024

 

Copyright (c) 2010, 2024, Oracle.

 

Configuration:

  /u01/apex/ords_23.4/config

 

The option --log-folder /u01/apex/ords_23.4/config/ords/standalone/logs is located in the ORDS product folder.  Oracle recom              mends to use a different --log-folder location.

 

Created folder /u01/apex/ords_23.4/config/ords/standalone/logs

The configuration folder /u01/apex/ords_23.4/config does not contain any configuration files.

 

Oracle REST Data Services - Interactive Install

 

  Enter a number to select the type of installation

    [1] Install or upgrade ORDS in the database only

    [2] Create or update a database pool and install/upgrade ORDS in the database

    [3] Create or update a database pool only

  Choose [2]: 2

  Enter a number to select the database connection type to use

    [1] Basic (host name, port, service name)

    [2] TNS (TNS alias, TNS directory)

    [3] Custom database URL

  Choose [1]:

  Enter the database host name [localhost]: ocisoumya

  Enter the database listen port [1521]:

  Enter the database service name [orcl]:

  Provide database user name with administrator privileges.

    Enter the administrator username: sys as sysdba

  Enter the database password for sys as sysdba:

Connecting to database user: sys as sysdba url: jdbc:oracle:thin:@//ocisoumya:1521/orcl

 

Retrieving information.

  Enter the default tablespace for ORDS_METADATA and ORDS_PUBLIC_USER [SYSAUX]: APEX

  Enter the temporary tablespace for ORDS_METADATA and ORDS_PUBLIC_USER [TEMP]: TEMP

  Enter a number to select additional feature(s) to enable:

    [1] Database Actions  (Enables all features)

    [2] REST Enabled SQL and Database API

    [3] REST Enabled SQL

    [4] Database API

    [5] None

  Choose [1]:

  Enter a number to configure and start ORDS in standalone mode

    [1] Configure and start ORDS in standalone mode

    [2] Skip

  Choose [1]:

  Enter a number to select the protocol

    [1] HTTP

    [2] HTTPS

  Choose [1]:

  Enter the HTTP port [8080]:

  Enter the APEX static resources location: /u01/apex/ords_23.4/config/ords/standalone/doc_root/images


copy images folder from apex installation folder to following path /u01/apex/ords_23.4/config/ords/standalone/doc_root/images which resides in ords installation directory.

[oracle@ocisoumya apex]$ cd

[oracle@ocisoumya ~]$ cd /u01/apex/apex

[oracle@ocisoumya apex]$ cp -r images/ /u01/apex/ords_23.4/config/ords/standalone/doc_root/

 


April 3, 2024

Oracle Apex 23.2 Installation and configuration on Linux - Part I

Oracle Application Express 23.2 Installation Steps 

 

Before installing Oracle Application Express, you must verify your configuration meets the minimum installation requirements.

                Oracle Database Requirements

Oracle Application Express release 23.2 requires an Oracle Database release 19c or later, including Enterprise Edition and Standard Edition (SE) and Database 23c Free. Oracle Application Express can be installed in single-instance database and in Oracle Real Application Clusters (Oracle RAC) database.

 

•        MEMORY_TARGET of the Target Database

Oracle Application Express requires the system global area (SGA) and program global area (PGA) to be at least 300 MB.

 

•        Oracle XML DB Requirement

Oracle XML DB must be installed in the Oracle database that you want to use if you are installing a full development environment. Oracle XML DB is not required for runtime only installations. If you are using a preconfigured database created either during an installation or by Database Configuration Assistant (DBCA), Oracle XML DB is already installed and configured.

 

Download Link: -

Oracle Application Express can be downloaded from HERE 





Environment details: -

OS

RHEL 7.9

IP

192.168.0.106

HOSTNAME

Server3.soumya.com

APEX VERSION

23.2

DB VERSION

19.3.0

 Once downloaded, unzip the software to begin the installation.

Create a directory where the apex software will be installed.

[oracle@server3 u01]$ mkdir -p /u01/apex

[oracle@server3 apex]$ unzip apex_23.2.zip -d /u01/apex

 

 

Create a new tablespace for APEX.

[oracle@server3 apex]$ sqlplus / as sysdba

 SQL> create tablespace APEX datafile '/u01/app/oradata/ORCL/apexd01.dbf' size 2G autoextend on;

 

Apex Installation: -

[oracle@server3 apex]$ cd /u01/apex/apex

[oracle@ocisoumya apex]$sqlplus / as sysdba

SQL>@apexins.sql APEX APEX TEMP /i/   -- i refers image location in application. APEX refers the tablespace name , TEMP refers the temporary tablespace name.

 


Once the installation is complete, confirm it by running following query

SYS> SELECT comp_name, version, status FROM dba_registry WHERE comp_id='APEX';

 

COMP_NAME                      VERSION             STATUS

------------------------------ ------------------------------ -----------

Oracle APEX                            23.2.0                   VALID

 


To change the admin password using “apxchpwd.sql” script as sys user.

SQL> @apxchpwd.sql

...set_appun.sql

================================================================================

This script can be used to change the password of an Oracle APEX

instance administrator. If the user does not yet exist, a user record will be

created.

================================================================================

Enter the administrator's username [ADMIN]

User "ADMIN" does not yet exist and will be created.

Enter ADMIN's email [ADMIN]

Enter ADMIN's password []

Created instance administrator ADMIN.


   For configuring static files, we must run apex_rest_config.sql after a new installation of Oracle          APEX.



SQL> @apex_rest_config.sql

 

Enter a password for the APEX_LISTENER user              []

Enter a password for the APEX_REST_PUBLIC_USER user              []

...set_appun.sql

...setting session environment

...create APEX_LISTENER and APEX_REST_PUBLIC_USER users

...grants for APEX_LISTENER and ORDS_METADATA user


      Configure APEX

            Now there are two ways which we can use to access APEX.

1.    Oracle REST Data Services(ORDS)

2.    Embeded PL/SQL Gateway(EPG) Configuration

However Oracle recommendation is ORDS.

create  a custom profile and assign the profile to  standard users to avoid user lock issues.


CREATE PROFILE app_user1 LIMIT

   FAILED_LOGIN_ATTEMPTS unlimited

   PASSWORD_LIFE_TIME unlimited

   PASSWORD_REUSE_TIME unlimited

   PASSWORD_REUSE_MAX unlimited

   PASSWORD_VERIFY_FUNCTION NULL

   PASSWORD_LOCK_TIME unlimited

   PASSWORD_GRACE_TIME unlimited;


Alter all apex related users to assign custom profile.

select username,account_status from dba_users where username like ('%APEX%');

 

ALTER USER APEX_230200 PROFILE app_user1;

ALTER USER APEX_LISTENER PROFILE app_user1;

ALTER USER APEX_REST_PUBLIC_USER PROFILE app_user1;

ALTER USER APEX_PUBLIC_USER  PROFILE app_user1;


Unlock the users:-

ALTER USER APEX_LISTENER identified by Concept_ora1 account unlock;

ALTER USER APEX_REST_PUBLIC_USER identified by Concept_ora1 account unlock;

ALTER USER APEX_PUBLIC_USER  identified by Concept_ora1 account unlock;

 

Execute following to grant connect privileges to any host for the APEX_230200 database user. This example assumes you connected to the database where Oracle Application Express is installed as SYS specifying the SYSDBA role.

BEGIN

  DBMS_NETWORK_ACL_ADMIN.append_host_ace (

    host       => '*',

    ace        => xs$ace_type(privilege_list => xs$name_list('connect','resolve'),

                              principal_name => 'APEX_230200',

                              principal_type => xs_acl.ptype_db));

END;

/

 

 


October 14, 2020

How to install Oracle Application Express(APEX) 20.1 in Linux

 

Oracle Application Express 20.1 Installation Steps 


Before installing Oracle Application Express, you must verify your configuration meets the minimum installation requirements.

Oracle Database Requirements

Oracle Application Express release 20.1 requires an Oracle Database release 11.2.0.4 or later, including Enterprise Edition and Express Edition (Oracle Database XE). Oracle Application Express can be installed in single-instance database and in Oracle Real Application Clusters (Oracle RAC) database.

MEMORY_TARGET of the Target Database

Oracle Application Express requires the system global area (SGA) and program global area (PGA) to be at least 300 MB.

Oracle XML DB Requirement

Oracle XML DB must be installed in the Oracle database that you want to use if you are installing a full development environment. Oracle XML DB is not required for runtime only installations. If you are using a preconfigured database created either during an installation or by Database Configuration Assistant (DBCA), Oracle XML DB is already installed and configured.


Download Link: -

Oracle Application Express can be downloaded from HERE


Environment details:-

OS

RHEL 6.4

IP

192.168.0.106

Hostname

server3.soumya.com

Apex Version

20.1

DB Version

12.1.0.2


Oracle Database 26ai Installation Using RPM on Oracle Linux 9 (OEL 9) – Step-by-Step Guide

  In this post I will describe the installation of Oracle Database 26ai 64-bit on Oracle Linux 9 (OL8) 64-bit. The installation requires a m...