:1,.−1dTo delete all rows above the current lin, press d (delete) followed by capital G (end of document):
d + G
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
:1,.−1dTo delete all rows above the current lin, press d (delete) followed by capital G (end of document):
d + G
vi myfilePress the escape key to enter interactive mode, then type
:%s/.*/\L&/Press escape, then save + exit the editor:
:wq
ps -fu postgres | grep $(pgrep -f postmaster) postgres 1913 1 0 Jul17 ? 00:02:51 /usr/pgsql-15/bin/postmaster -D /var/lib/pgsql/15/data/ postgres 1982 1913 0 Jul17 ? 00:00:24 postgres: logger postgres 2063 1913 0 Jul17 ? 00:00:18 postgres: checkpointer postgres 2064 1913 0 Jul17 ? 00:00:03 postgres: background writer postgres 2119 1913 0 Jul17 ? 00:00:07 postgres: walwriter postgres 2120 1913 0 Jul17 ? 00:00:14 postgres: autovacuum launcher postgres 2121 1913 0 Jul17 ? 00:00:01 postgres: archiver postgres 2122 1913 0 Jul17 ? 00:00:00 postgres: logical replication launcher postgres 2657 1913 0 Jul17 ? 00:02:05 postgres: postgres_exporter postgres localhost(48674) idleThe command lists all processes by user "postgres" and and greps for the output of the command "pgrep -f postmaster", which returns a list of process IDs
pgrep -c postmaster 9
cd $ORACLE_GG tree -L 2 --noreport $(ls -d dir* | grep -v '^dirdat$')
target=server2.oric.no && rsync -vaz --delete /u01/app/myfiles ebsuser@$target:/u01/appThis will sync the entire "/u01/app/myfiles" folder + all subfolders.
cd /sw/oracle/admin
tree -L 2
.
├── cdb
│ ├── adump
│ ├── dpdump
│ ├── log
│ ├── pfile
│ └── xdb_wallet
├── sales
│ ├── adump
│ ├── dpdump
│ ├── pfile
│ ├── sql
│ └── xdb_wallet
└── hr
├── adump
├── dpdump
├── log
├── pfile
├── scripts
├── sql
└── xdb_wallet
20 directories, 0 files
The -L flag indicates the number of levels you want to display. In my case, if I change the value from 2 to 3, I get the output below instead (abbreviated):
. ├── cdb │ ├── adump │ │ ├── FE78BD1F8E6730CDE0536709D10AC9C0 │ │ └── FE7BD04D2DFBE569E0536709D10A3AF0 │ ├── dpdump │ │ ├── dp.log │ │ ├── FE78BD1F8E6730CDE0536709D10AC9C0 │ │ ├── FE7AF28B415262F7E0536709D10A8B2E │ │ └── FE7BD04D2DFBE569E0536709D10A3AF0 │ ├── log │ │ ├── 2023-07-11_cdb.2431565 │ │ ├── 2023-07-12_cdb.2489915 │ │ ├── 2023-07-12_cdb.2576176 ├── sales │ ├── adump │ ├── dpdump │ │ └── dp.log │ ├── pfile │ │ └── init.ora.5192023145034 │ ├── sql │ │ ├── analyze_sales.sh │ │ ├── cfgtoollogs │ │ ├── config_sales.txt │ │ ├── cre_db.sh │ │ └── deploy_sales.sh 26 directories, 181 filesThe command is not installed by default but is avaible both for RHEL / CentOS / Fedora Linux as well as Debian based Linux distributions like Ubuntu.
cd $ORACLE_HOME/.patch_storage du -h --max-depth=1 100K ./29585399_Apr_9_2019_19_12_47 284K ./NApply 4.0K ./oracle-home-1681903491076105 434M ./34786990_Dec_6_2022_13_24_50 20K ./NRollback 436M ./35050341_Mar_17_2023_04_11_10 2.0G ./35042068_Apr_6_2023_15_25_04 91M ./backup_delete_inactive 2.9G .
root # echo "Test message" | mailx -S smtp="smtp.oric.no" -vvv -s "$(hostname) is up" monitoring@oric.no
[Feb 19, 2023 2:29:51 PM] [INFO] Prerequisite check "CheckActiveFilesAndExecutables" failed.
The details are:
Following active files/executables/libs are used by ORACLE_HOME :/sw/oracle/product/19.18
/sw/oracle/product/19.18/lib/libclntsh.so.19.1
Reason:
fuser -v /sw/oracle/product/19.18/lib/libclntsh.so.19.1
USER PID ACCESS COMMAND
/sw/oracle/product/19.18/lib/libclntsh.so.19.1:
oracle 48439 ....m prometheus_orac
oracle 595787 ....m ggsci
log in as the Golden Gate software owner ggsci --> info all --> list all processes stop mgr !One of two processes quit its handler on the file:
fuser -v /sw/oracle/product/19.18/lib/libclntsh.so.19.1
USER PID ACCESS COMMAND
/sw/oracle/product/19.18/lib/libclntsh.so.19.1:
oracle 48439 ....m prometheus_orac
For the prometheus agent, we simply kill the agent, and the output from fuser now reveals that no file handlers are open:
kill 48439 fuser -v /sw/oracle/product/19.18/lib/libclntsh.so.19.1
PDB1_test1.oric.noIn other words, the files listener.ora, sqlnet.ora and tnsnames.ora are symlinks pointing to this subdirectory:
# ls -altr lrwxrwxrwx 1 oracle dba 34 Feb 10 13:29 sqlnet.ora -> PDB1_test1.oric.no/sqlnet.ora lrwxrwxrwx 1 oracle dba 36 Feb 10 13:29 tnsnames.ora -> PDB1_test1.oric.no/tnsnames.ora lrwxrwxrwx 1 oracle dba 36 Feb 18 12:17 listener.ora -> PDB1_test1.oric.no/listener.ora drwxr-xr-x 2 oracle dba 4096 Feb 18 12:18 PDB1_test1.oric.no drwxr-xr-x 5 oracle dba 4096 Feb 18 12:19 .If you are to exchange a string in these files, for example when switching to a new version of the Oracle software, make sure you use the directive --follow-symlinks to preserve your symlinks:
export PRE_ORACLE_VERSION=19.17 export NEW_ORACLE_VERSION=19.18 cd $TNS_ADMIN sed --follow-symlinks -i "s/$PRE_ORACLE_VERSION/$NEW_ORACLE_VERSION/g" listener.oraIf you don't, the listener.ora will be placed directly in $TNS_ADMIN, and the symlinks will be dropped.
su - oracle <<! instructions here !I was not able to save the value of a string extracted from an xml file in a session variable.
su - oracle <<! export CNTXT_FILE_PERL_VERSION=\`grep PERL5LIB \$CONTEXT_FILE | awk -F "site_perl/" '{print \$2}' | cut -f 1 -d":"\` !
su - oracle -c "/tmp/set_params.sh"You may see errors like the following:
set_params.sh: line 6: $'\r': command not found set_params.sh: line 42: syntax error: unexpected end of fileRoot cause:
dos2unix set_params.sh dos2unix: converting file flexpod_params.sh to Unix format...When executed again, the above errors should be gone!
#!/bin/bash
export SCRIPT_NAME=`basename $0`
export TS=`date +\%m.\%d.\%y\_%H_%M_%S`
export GLOGFILE=/u01/mylogfile_${TS}.log
touch ${GLOGFILE}
chmod 666 ${GLOGFILE}
exec 1> ${GLOGFILE} 2>&1
echo "Starting job at " `date`
your shell instructions here
echo "Ending job at " `date`
exit
findmnt -t nfs TARGET SOURCE FSTYPE OPTIONS /u01 pzl2ora1:/Oracle/software/pzh0oric/u01 nfs rw,nodiratime,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,acregmin=300,acregmax=300,acdirmin=300,ac /u02 pzl2ora1:/Oracle/pzh0oric/u02 nfs rw,nodiratime,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,acregmin=300,acregmax=300,acdirmin=300,ac /u03 pzl2ora1:/Oracle/pzh0oric/u03 nfs rw,nodiratime,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,acregmin=300,acregmax=300,acdirmin=300,ac /u04 pzl2ora1:/Oracle/pzh0oric/u04 nfs rw,nodiratime,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,acregmin=300,acregmax=300,acdirmin=300,ac
This is the error I received:cat /etc/redhat-releaseRed Hat Enterprise Linux release 8.5 (Ootpa)
export CV_ASSUME_DISTID=OEL7.8Execute the installer again and you will see a different screen:
./runInstaller
Clone Volume: true
Clone Parent server Name: myserver1-cluster49
SnapClone Parent Volume: myvolume_mirror1
cat clonetext.txt | grep Clone
Clone Volume: true
Clone Parent server Name: myserver1-cluster49
SnapClone Parent Volume: myvolume_mirror1
Grepping for the 4th column helps, but you still get two rows, not just the single one you're interested in:
oracle@oric-db01:[mydb01]# cat clonetext.txt | grep Clone | awk -F' ' '{print $4}'
Name:
myvolume_mirror1
Adding the NR flag to your command solves the problem:
cat clonetext.txt | grep Clone | awk -F' ' 'NR==3 {print $4}'
myvolume_mirror1
[root@myserver /home/oracle]# lsof | grep '/data1' extract 14041 oracle 25r REG 0,23 2896 1235955379 /data1/goldengate/dirdat/et000000127 (storage1:/Oracle/myserver/data1)You will see a list of processes. Terminate these with the kill-command:
kill 13859 14041After this is done, you can unmount the nfs file system:
umount -f /data1
lsb_release -aOutput:
No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.1 LTS Release: 18.04 Codename: bionicReplace the -a switch with the -d switch to limit the output to the version only.
cat /etc/os-release:
NAME="Ubuntu" VERSION="18.04.1 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.1 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic