Tuesday, July 6, 2021

Why and How to install/update tomcat 9 in Linux

 

** This is applicable in Linux environment (red hat , Centos , Amazon linux ..etc) .

 Why ?

Tomcat will allow you to run a web server and Servlet container. So, if you have an application needs to run in this platform and a free web server needed , you will go to install tomcat as a most common in this matter.

How ?

Below are most brief commands you may need to use in install tomcat 9 in Redhat / Centos 7 & 8  :

1- download tomcat files from tomcat website (you may use “wget” if interned open in server) and upload it to your server and create a tomcat service user as below:

groupadd -g 53 -r tomcat

useradd -c "tomcat" -u 53 -g tomcat -s /bin/sh -r tomcat

 2- unzip/untar the file to your installation path, I will use
(/app/tomcat) and setup permissions:

mkdir -p /app/tomcat

tar -xf apache-tomcat-9.0.40.tar.gz -C /app/tomcat

chown -R tomcat:tomcat /app/tomcat/

chmod -R u+X /app/tomcat/

3- Check/Install and configured whether java 11 or java 8

java -version

yum install java-11-openjdk

alternatives --config java

4- Create systemd service to manage tomcat9 (sample configuraiont)

 vim /etc/systemd/system/tomcat9.service

[Unit]

Description=Tomcat 9 servlet container

After=network.target

[Service]

Type=forking

User=tomcat

Group=tomcat

Environment="JAVA_HOME=/usr/lib/jvm/jre"

# you may need to set below if application use the below

# import java.security.SecureRandom;

Environment="JAVA_OPTS=-Djava.security.egd=file:/dev/./urandom"

Environment="CATALINA_BASE=/app/tomcat"

Environment="CATALINA_HOME=/app/tomcat"

Environment="CATALINA_PID=/app/tomcat/temp/tomcat.pid"

Environment="CATALINA_OPTS=-Xms512M -Xmx2048M -server -XX:+UseParallelGC"

ExecStart=/app/tomcat/bin/startup.sh

ExecStop=/app/tomcat/bin/shutdown.sh

[Install]

WantedBy=multi-user.target

---------

systemctl daemon-reload

systemctl enable --now tomcat9

5- configure your tomcat 9 :

/app/tomcat/conf (server.xml , web.xml ..etc)

/app/tomcat/webapps # (put your application files)

systemctl restart tomcat9.service

systemctl status tomcat9.service

Sunday, June 27, 2021

Why and How to manage Sun Cluster resources running for Oracle Database

  Why ?

To do activity for Oracle database like patching , upgrade or switchover/failover ..etc and this sever is running on Sun cluster HA services , you have to do disable/enable and monitor/unmonitored for certain services configured in your cluster resources and group.

How ?

Below are most important commands you may need to use in Sun Cluster management  :

1- Checking Cluster group status:

clrg status

=== Cluster Resource Groups ===

Group Name      Node Name        Suspended      Status

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

Group_res       Server1         No             Online

                Server2         No             Offline

 

2- Check Cluster resources details of the group :

clrs status

=== Cluster Resources ===

Resource Name      Node Name        State       Status Message

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

DB-srv            Server1           Online      Online

                   Server2           Offline     Offline

 

DB-lsnr            Server1           Online      Online

                   Server2           Offline     Offline

 

Ip_HA             server1            Online      Online - LogicalHostname online.

                  server2            Offline     Offline

 

DB_zfs-rs        server1            Online      Online

3- Stop/shutdown certain recourse

clrs disable DB-srv

clrs enable DB-srv

4- Disable the cluster management for certain resource

clrs unmonitor DB-srv

clrs monitor DB-srv

5- Show configured things in resource :

clrs show -v DB-srv

6- Switchover to server2

clrg switch -n server2 Group_res


A good reference you may refer to is :

Thursday, June 24, 2021

Why and How to create a shell loop script to run same file in multiple directories

  Why ?

To run on command or execute the same file in different directory you will need to do this whether using a find command or with shell script to be in more flexible .

How ?

This is a shell script file  :

1- create a shell file(example):

vim check_file.sh

2- sample of for loop to execute "file.sh" and echo command in multiple directories (dir1, dir2, dir3 , dir4) :

#!/bin/sh

for dir in /path/dir*; do

        echo $dir

        $dir/file.sh

done;

Tuesday, June 22, 2021

Why and How to stop/start Oracle standby database server under data guard broker ( DGMGRL) for maintenance

 

 Why ?

For maintenance purpose in the standby server or primary server you will need to stop Data Guard things prior reboot or do the activity in the server OS things for example , thus; to avoid  any issue in the data sync between primary and stand by you should stop these shipping data and it will be re-shipped once everything revert back to normal.

How ?

I am assuming you already configure a Data guard broker and everything running normally :

1- check current data guard status:

dgmgrl / as sysdba

DGMGRL> show configuration

Configuration - orcl_dg_config

  Protection Mode: MaxPerformance

  Members:

  Orcl_prim   - Primary database

    Orcl_stdby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS   (status updated 25 seconds ago)

2- Stop redo transport (stop sending data from primary to standby) :

DGMGRL> EDIT DATABASE '<primary_db>' SET STATE='TRANSPORT-OFF';

3- Stop redo apply (stop applying the received data in standby DB )

DGMGRL> EDIT DATABASE '<standby_db>' SET STATE='APPLY-OFF';

4- Disable broker ( to avoid any failover/switchover during the activity).

 DGMGRL> disable configuration

5- Shutdown database:

sqlplus / as sysdba

shutdown immediate;

quit

lsnrctl stop

6-Perform maintenance activities

7- Start database in the respective open_mode (read write primary, or mounted standby) , In below case you will open standby DB in a read only; if you have an active data guard license .

sqlplus / as sysdba

startup open ;

quit

lsnrctl start

or first mount it and then open in read only mode :

SQL> startup nomount;

SQL> alter database mount;

SQL>  ALTER DATABASE OPEN READ ONLY;

8- Enable broker

DGMGRL> enable configuration

 9. Start redo apply

DGMGRL> EDIT DATABASE '<standby_db>' SET STATE='APPLY-ON';

10. Start redo transport

 

DGMGRL> EDIT DATABASE '<primary_db>' SET STATE='TRANSPORT-ON';

10. Check dataguard status

 

After a while and things got recovered, you can check the status :

 

dgmgrl / as sysdba

DGMGRL> show configuration

Configuration - orcl_dg_config

  Protection Mode: MaxPerformance

  Members:

  Orcl_prim   - Primary database

    Orcl_stdby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS   (status updated 25 seconds ago)

Why and How to install Grid 19c on RHEL 8?

  Why ? Simply we will be requested to install Oracle Grid RAC DB on Redhat RHEL 8, below is my note for this installation . How ? 1-  OS in...