Wednesday, December 13, 2023

GOLDEN GATE 19c Installation On Linux

Enable supplemental logging for a specific table:-

ALTER TABLE your_schema.your_table ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;

Enable supplemental logging :-

ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;

Enable supplemental logging for a column in a table:-

ALTER TABLE your_schema.your_table 
  ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY, COLUMN1, COLUMN2, ...);


create goldengate user :-
# useradd -m goldengate
--add goldengate user to oracle groups --
# sudo usermod -aG $(groups oracleuser | cut -d' ' -f3- | sed 's/ /,/g') goldengate
# sudo usermod -g oinstall goldengate 
-- add following info in /home/goldengate/.bash_profile
export ORACLE_HOME=/u02/app/ogg19c
export LD_LIBRARY_PATH=$ORACLE_HOME:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME:$PATH

su - oracle
GG_HOME=/u02/app/oracle/GG_HOME
cd GG_HOME
wget https://download.oracle.com/otn_software/linux/instantclient/1921000/instantclient-basic-linux.x64-19.21.0.0.0dbru.zip
chmod 777 *.zip
unzip *.zip 
cd instant_client_19_21
mv * ../ 
./ggsci 


su - oracle
sqlplus / as sysdba
create user ggadmin identified by ggadmin;
alter user ggadmin quota unlimited on ggadmin;
grant create session, connect, resource, alter system, select any dictionary, flashback any table to ggadmin container=all;
exec dbms_goldengate_auth.grant_admin_privilege(grantee => 'ggadmin',container=>'all');
PL/SQL procedure successfully completed.
alter user ggadmin set container_data=all container=current;
grant alter any table to ggadmin container=ALL;
alter system set enable_goldengate_replication=true scope=bot
alter database force logging;
alter pluggable database add supplemental log data;
Pluggable database altered.
-- to add integrated extract 
su - goldengate
cd $GG_HOME
./ggsci
add extract ext, integrated tranlog, begin now
info all
add exttrail /u02/app/oracle/GG_HOME/lt, extract ext
--start extract always from cdb$root 
start extract ext atscn <scn>;
[goldengate@pm ~]$ cat /home/goldengate/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export ORACLE_HOME=/u02/app/oracle/product/19c/dbhome_1
export ORACLE_SID=sakri
export GG_HOME=/u02/app/oracle/GG_HOME
export PATH=$GG_HOME:$PATH
export LD_LIBRARY_PATH=$GG_HOME/lib:$LD_LIBRARY_PATH
[goldengate@pm ~]$
[goldengate@pm ~]$
[goldengate@pm ~]$
[goldengate@pm ~]$
[goldengate@pm ~]$ cat /u02/app/oracle/GG_HOME/dirprm/ext.prm
EXTRACT ext
setenv (ORACLE_SID = "sakri")
setenv (ORACLE_HOME = "/u02/app/oracle/product/19c/dbhome_1")
USERID ggadmin, PASSWORD ggadmin
EXTTRAIL /u02/app/oracle/GG_HOME/dirprm/lt
--TRANLOGOPTIONS ASMUSER your_asm_user, ASMPASSWORD your_asm_password
TABLE cdb$root.ggadmin.*;

SQL> show pdbs;
    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB                            READ WRITE NO

ALTER PLUGGABLE DATABASE pdb$seed,pdb OPEN READ ONLY FORCE;
ALTER PLUGGABLE DATABASE pdb$seed,pdb CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE ALL OPEN;
ALTER PLUGGABLE DATABASE ALL CLOSE IMMEDIATE;
ALTER PLUGGABLE DATABASE ALL EXCEPT pdb$seed OPEN;
ALTER PLUGGABLE DATABASE ALL EXCEPT pdb CLOSE IMMEDIATE;

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 51> delete extract ext
Deleted EXTRACT EXT.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 52> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 53> edit param ext


GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 54> add extract ext, integrated tranlog, begin now
EXTRACT (Integrated) added.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 55> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     STOPPED     EXT         00:00:00      00:00:01
GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 96> add exttrail /u02/app/oracle/GG_HOME/dirprm/lt, extract ext
EXTTRAIL added.
GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 97> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     ABENDED     EXT         00:00:00      00:01:18

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 98> start extract ext
Sending START request to MANAGER ...
EXTRACT EXT starting

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 56> register extract ext database
2024-03-01 23:36:09  ERROR   OGG-08223  ERROR: One or more containers must be specified when registering Extract for a container database.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 57> register extract ext database container (pdb)
2024-03-01 23:36:58  INFO    OGG-02003  Extract EXT successfully registered with database at SCN 2267932.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 58> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     STOPPED     EXT         00:00:00      00:01:05

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 59> start extract ext
Sending START request to MANAGER ...
EXTRACT EXT starting

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 60> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     STOPPED     EXT         00:00:00      00:01:10

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 61> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     STOPPED     EXT         00:00:00      00:01:12

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 62> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     STOPPED     EXT         00:00:00      00:01:13

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 63> register extract ext database container all
2024-03-01 23:37:23  ERROR   OGG-15406  Missing opening parenthesis in container list for REGISTER EXTRACT command.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 64> register extract ext database container (pdb$seed)
2024-03-01 23:37:53  ERROR   OGG-01754  Cannot register or unregister EXTRACT EXT because the Extract is currently running. Stop the Extract and retry the command.

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 65> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:01

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 66> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:02

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 67> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:04

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 68> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:05

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 69> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:07

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 70> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:09

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 71> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:12

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 72> info ext
ERROR: You must specify a group name.
GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 73> info extract ext
EXTRACT    EXT       Initialized   2024-03-01 23:35   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:02:18 ago)
Process ID           8654
Log Read Checkpoint  Oracle Integrated Redo Logs
                     2024-03-01 23:35:57
                     SCN 0.0 (0)

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 74> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:20

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 75> info all
Program     Status      Group       Lag at Chkpt  Time Since Chkpt
MANAGER     RUNNING
EXTRACT     RUNNING     EXT         00:00:00      00:02:22

GGSCI (pm.shaikh.com as ggadmin@sakri/CDB$ROOT) 76>

Wednesday, November 29, 2023

ORACLE RAC 10G-11G COMMANDs

 crs_stat -t  :- show HA resource status

crsstat :-  output of crs_stat -t formatted nicely 

ps -ef | grep d.bin :- crsd.bin evmd.bin ocssd.bin

crsctl check crs :- css, crs, evm appears healthy.

crsctl stop crs :- stop crs and all other services.

crsctl disable crs* :- prevents crs from starting on reboot.

crsctl enable crs* :- enables crs start on reboot.

crs_stop -all :- stops all regiestered resources.

crs_start -all :- starts all registered resources. 

srvctl start instance -d  <db_name> -i <inst_name> :-  starts an instance.

srvctl start database -d <db_name> :-  starts all instances. 

srvctl stop database -d <db_name> :- stops all instances. 

srvctl stop instance -d <db_name> -i <inst_name> :- stops an instance.

srvctl start service -d <db_name> -s <service_name> :- starts a service.

srvctl stop  service -d <db_name> -s <service_name> :- stops a service.

srvctl status service -d <db_name> :- check status of a service.

srvctl status instance -d <db_name> -i <inst_name> :-  checks status of instance

srvctl status database -d <db_name> :- checks status of all instances.

srvctl start nodeapps -n <node_name> :- starts gsd, vip, listener and ons

srvctl stop nodeapps -n <node_name> :- stops gsd, vip, listener and ons 

Tuesday, November 14, 2023

oracle environment variables

cat /etc/profile

cat ~/.profile 

cat ~/.bash_profile

cat /etc/oraInst.loc inventory_loc=/u01/app/oraInventory
inst_group=oinstall

Sunday, October 22, 2023

Details about all /etc/files

 The "/etc" directory in Linux contains a wide range of configuration files and directories that are essential for the proper functioning of the system and various software applications. Below are some common files and directories found in "/etc" and their typical usage:
/etc/passwd: This file contains user account information, including usernames, user IDs, group IDs, home directories, and shell types.

/etc/group: It stores information about user groups, including group names and group IDs.

/etc/shadow: This file holds encrypted password information for user accounts.

/etc/hostname: It stores the system's hostname, which is used to identify the machine on a network.

/etc/hosts: This file maps hostnames to IP addresses, allowing the system to resolve hostnames to IP addresses without using DNS.

/etc/hostname: It specifies the system's hostname, which is used during system boot.

/etc/resolv.conf: Contains DNS resolver configuration, including the IP addresses of DNS servers.

/etc/network/interfaces (or /etc/sysconfig/network-scripts): These files are used to configure network 
interfaces on the system.

/etc/fstab: It lists the file systems and partitions to be mounted at boot and their associated options.

/etc/mtab: This file contains a list of currently mounted file systems.

/etc/ssh/sshd_config: Configuration file for the OpenSSH server.

/etc/sudoers: Configuration for the sudo command, which allows users to execute commands as superusers.

/etc/apt/sources.list (Debian/Ubuntu) or /etc/yum.conf (RHEL/CentOS): Configuration files for package management systems. They define where the package manager should look for software packages.

/etc/crontab: The system-wide crontab file for scheduling tasks at specific times or intervals.

/etc/sysctl.conf: Configuration file for the sysctl command, which allows you to configure kernel parameters.

/etc/hostnamectl (systemd-based systems): This file contains system hostname and related information.

/etc/selinux/config (SELinux-enabled systems): Configuration file for SELinux, a mandatory access control system.

*/etc/default (or /etc/default/ on Debian-based systems)**: These directories store default configuration settings for various services.

/etc/X11/xorg.conf (or /etc/X11/xorg.conf.d/ on some systems): Configuration files for the X Window System.

/etc/samba/smb.conf (if Samba is installed): Configuration file for the Samba file-sharing service.

Please note that the above list is not exhaustive, and the files and directories in the "/etc" directory can vary between different Linux distributions and systems. Each file serves a specific purpose in configuring and managing the system and its software components. It's essential to use caution when making changes to these files, as misconfiguration can affect system stability and security.





Sunday, October 15, 2023

archivelogs location in oracle

 select inst_id,name,value from v$diag_info;



best for finding exact location of archivelog location in oracle linux:-

select dest_name,status,destination from gv$archive_dest where status='VALID';


SELECT name, space_limit, space_used FROM v$recovery_file_dest;

DBMS PACKAGES IN ORACLE

 


rm -rf !(folder) in linux

shopt -s extglob  # Enable extended pattern matching

rm -rf !(folder)  # Delete everything except the 'folder' directory

shopt -u extglob  # Disable extended pattern matching (optional)


Monday, October 9, 2023

savepoint, rollback, commit in oracle db

 commit: make changes done in transaction permanent.

rollback : rollback the state of database to the last commit point.

savepoint : use to specify a point in transaction to which later you can rollback.





create table student 

(

id number primary key,

name varchar2(50),

college varchar2(50)

);


insert all

into student values (1,'pravin','ness')

into student values (2,'prakash','ness')

into student values (3,'pratap','ness')

into student values (4,'pranav','ness')

into student values (5,'prayank','ness')

select * from dual;


--create savepoint student_original --

savepoint student_original;


-- delete some records --

delete student where id=5;


-- rollback to student_original savepoint --

rollback to student_original;


-- most important fact --

you cannot rollback to any previous savepoint once you've triggered commit; 


Friday, September 29, 2023

Linux SSH REMOTE EXECUTION OF COMMANDS

 ssh -t -q oracle@pm "(df -h /u02; hostname -f; date)" 


read -p "enter server name: " server ; ssh -t -q $server "(sudo -iu oracle)"


or looping multiple servers :-

for servers in server1 server2 server3 server4 ;

do 

ssh -t -q $servers "(df -h /u02; hostname -f ; date)" ;

done;


EXPLANATION:- 

  • ssh: This is the SSH command used for secure remote shell access.

  • -t: This option is used to allocate a pseudo-terminal. It's often necessary when you want to run interactive commands remotely because it simulates an interactive terminal session.

  • -q: This option stands for "quiet" and is used to suppress warning and diagnostic messages. It makes the SSH command less verbose.

  • oracle@pm: This part specifies the username (oracle) and the hostname or IP address (pm) of the remote server you want to connect to. The @ symbol separates the username from the hostname.

  • "(...)": The parentheses enclose a series of commands that you want to execute on the remote server. In this case, three commands are enclosed: df -h /u02, hostname -f, and date.

  • -t option is essential when running multiple commands, as it ensures that the commands are executed in an environment that behaves like an interactive shell session.

Tuesday, September 19, 2023

File System Alerts Short Cuts Commands specially "find command"

 


[oracle@pm u02]$ find ./* -type d -name "archivelog" -exec du -sh {} +  2>&1 | grep -v "Permission denied"

612M    ./app/oracle/fast_recovery_area/CHENNAI/archivelog
660M    ./app/oracle/fast_recovery_area/SAKRI/archivelog

[oracle@pm u02]$ find ./* -type d -name "trace" -exec du -sh {} +  2>&1 | grep -v "Permission denied"
0       ./app/oracle/product/21c/dbhome_1/network/trace
17M     ./app/oracle/diag/rdbms/chennai/chennai/trace
2.9M    ./app/oracle/diag/rdbms/sakri/chennai/trace
29M     ./app/oracle/diag/rdbms/sakri/sakri/trace
40K     ./app/oracle/diag/rdbms/unknown/chennai/trace
4.0K    ./app/oracle/diag/clients/user_oracle/host_3163451292_110/trace
1.3M    ./app/oracle/diag/tnslsnr/pm/listener/trace
0       ./app/oracle/homes/OraDB21Home1/network/trace

[oracle@pm u02]$ find ./* -type d -name "alert" -exec du -sh {} +  2>&1 | grep -v "Permission denied"
8.9M    ./app/oracle/diag/rdbms/chennai/chennai/alert
168K    ./app/oracle/diag/rdbms/sakri/chennai/alert
11M     ./app/oracle/diag/rdbms/sakri/sakri/alert
16K     ./app/oracle/diag/rdbms/unknown/chennai/alert
20K     ./app/oracle/diag/clients/user_oracle/host_3163451292_110/alert
2.2M    ./app/oracle/diag/tnslsnr/pm/listener/alert


[oracle@pm u02]$ find ./* -type d -name "*backup*" -exec du -sh {} +  2>&1 | grep -v "Permission denied"
4.6M    ./app/oracle/product/21c/dbhome_1/inventory/backup
164M    ./app/oracle/fast_recovery_area/CHENNAI/autobackup
19M     ./app/oracle/fast_recovery_area/SAKRI/autobackup
12K     ./app/oraInventory/backup

[oracle@pm u02]$ find ./* -type d -name "*dump*" -exec du -sh {} +  2>&1 | grep -v "Permission denied"
158M    ./app/oracle/product/21c/dbhome_1/rdbms/utl/upgrade_dump_seed
0       ./app/oracle/diag/rdbms/chennai/chennai/cdump
0       ./app/oracle/diag/rdbms/sakri/chennai/cdump
0       ./app/oracle/diag/rdbms/sakri/sakri/cdump
0       ./app/oracle/diag/rdbms/unknown/chennai/cdump
0       ./app/oracle/diag/clients/user_oracle/host_3163451292_110/cdump
0       ./app/oracle/diag/tnslsnr/pm/listener/cdump
18M     ./app/oracle/admin/chennai/adump
4.0K    ./app/oracle/admin/chennai/dpdump
13M     ./app/oracle/admin/sakri/adump


[oracle@pm u02]$ find ./* -type d -name "*crs*" -exec du -sh {} +  2>&1 | grep -v "Permission denied"
208M    ./app/oracle/product/21c/dbhome_1/crs
24K     ./app/oracle/product/21c/dbhome_1/inventory/Components21/oracle.rdbms.crs
32K     ./app/oracle/product/21c/dbhome_1/inventory/Templates/crs
0       ./app/oracle/diag/crs


others RAC GRID:-
find /opt -type d -name "*crsd*" 2>&1 | grep -v "Permission denied"
find ./* -type d -name "*crsd*"  2>&1 | grep -v "Permission denied"
find ./* -type d -name "*evm*"  2>&1 | grep -v "Permission denied"
find ./* -type d -name "*orarootagent*"   2>&1 | grep -v "Permission denied"
find ./* -type d -name "*oraagent*"   2>&1 | grep -v "Permission denied"
find ./* -type d -name "*ohas*"    2>&1 | grep -v "Permission denied"

+++++++++++ To find files older than some hours +++++++++++++++++++++++++++++++
find . -daystart -type f -newermt "$(date -d 'today 10 hours ago' +'%Y-%m-%d %H:%M:%S')"
find . -type f -writable
find . -type f -executable
find . -type f -readable 

+++++++++++++files older between 5 hours to 10 hours from the daystart++++++++++++++
find .  -daystart -type f -newermt "$(date -d 'today 10 hours ago' +'%Y-%m-%d %H:%M:%S')" ! -newermt "$(date -d 'today 5 hours ago' +'%Y-%m-%d %H:%M:%S')"

find . -type f -newermt '5 hours ago' 
find . -type f -newermt '5 minutes ago' 
find . -type f -newermt '5 days ago' 
find . -type f -newermt '5 months ago' 
find . -type f -newermt '5 years ago' 
find . -type f -newermt 'yesterday' 
we can use 
"-type d" flag for directories 
"-type b" flag for block devices
"-type f" flag for files 




Thursday, September 14, 2023

NLS (NATIONAL LANGUAGE SUPPORT) in SQL

 NLS 
(national language support)
nls_sort and nls_comp are parameters used to 
control the sorting and comparison behaviour of
characters in SQL queries. 

1. NLS_SORT:-
binary-binary sorting (ascii)
french-french linguistic sorting.
german-german linguistic sorting.
spanish-spanish linguistic sorting
binary_ci-binary sorting with case-insensitivity.
french_ci-french linguistic sorting with case-insensitivity.
example:-
alter session set nls_sort='FRENCH';

2. NLS_COMP:-
binary-binary comparison (case-sensitive).
linguistic- linguistic comparison(case-insensitive).
example:-
alter session set nls_comp='LINGUISTIC';


overall best for case-insensitive search in SQL oracle:-
alter session set nls_sort='binary_ci';
alter session set nls_comp='linguistic';


select * from nls_database_parameters;
select * from nls_instance_parameters;
select * from nls_session_parameters;

Enable OpenSSH on Windows 11

Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...