Posts

Showing posts with the label Linux

Using ssh X11 tunnel through a bastion host to connect to a database server

Image
Hi, I succeeded running Oracle dbca, xclock & virt-viewer using Bastion over VPN (with root) 😊 Theoretical Steps: First, connect to machine B and forward [localPort] to C:22 through B A$ ssh -L [localPort]:C:22 B Next, connect to C from A through this newly-created tunnel using [localPort], forwarding X11 A$ ssh -X -p [localPort] localhost Now we can run X11 programs on C and have them display on A C$ xclock [localPort] can be any port that you are not already listening to on A, I often use 2222 for simplicity. X11Forwarding should be enabled on server C AllowTcpForwarding should be enabled on server B Actual Steps First, connect to machine B and forward [localPort] to C:22 through B A$ ssh -L [localPort]:C:22 B Next, connect to C from A through this newly-created tunnel using [localPort], forwarding X11 From A using putty to localhost using [localPort] enable X11 forwarding to localhost:0.0 Now we can run X11 programs on C and have them display on A ...

How to install Oracle Linux in kvm without a need to X server

Image
Hi, I managed to install Oracle Linux on kvm guest without a need to X console (no GUI, vnc or X11) 1. We can see the PXE menu 2. We can select image to install 3. We need to add console=ttyS0 to the PXE (cobbler is supporting this feature the same way as grub enable you to add parameter to the boot) Disclaimer: I tested this on Oracle Linux 7.5 using libvirt 1.5 # virt-install --hvm --connect qemu:///system --network=bridge:virbr0 --pxe --graphics none --name Oracle_Linux_7.4-x86_64 --ram=756 --vcpus=1 --os-type=linux --os-variant=rhel7 --disk path=/tmp/rhel7-machine.img,size=5 --console pty,target_type=serial --boot 'menu=on,useserial=on' Starting install... Allocating 'rhel7-machine.img'                                                                                ...

Oracle Database Auto Discovery

Image
Hi, I was asked by our development team to provide the best way to identify database parameters from database host, I was surprised to find so many options. Identifying all instances on the current machine Option 1:  $ ps -ef |grep smon | grep -v grep oracle    3025  1  0  2016 ?   00:00:48 asm_smon_+ASM oracle    11459  1  0 17:24 ?  00:00:00 ora_smon_ fdb oracle SID is  fdb and process id is  11459 Option 2:  $ pgrep  -lf _pmon_ 3025 asm_pmon_+asm 11459 ora_pmon_ fdb oracle SID is  fdb  and process id is  11459 Option 3:  cleaner way for sid: $ ps -ef |grep 'ora_smon_.*$' | grep -v grep | awk -F_ '/ora_smon/{print $NF}' fdb oracle SID is  fdb  Option 4:  When we already know ASM home (grid infrastructure) we can use the cluster commands: $ /oracle/product/12.1.0.2/grid/bin/crsctl stat res -t -w "TYPE = ora.database.type"|awk '...

Setup additional local DNS - to add scan addresses

Image
In this document I demonstrate how to add local DNS server to be added additionally to an existing DNS, I had this need for creating some additional IP addresses in the DNS for Real Application Cluster (VIP and SCAN) My Testing Environment My Private DNS Server IP Address: 10.20.2.100 Host Name: localdns OS: Oracle Linux Server release 7.5 Client Machine to use DNS IP Address: 10.33.1.120 Host Name: dbhost OS: Oracle Linux Server release 7.4 Current Domain DNS Primary: 192.168.1.10 Secondary: 192.168.1.1 1 DNS entry to add IP Address: 10.33.1.123 Host Name: dbhost-scan Verify that the above IP  address is not being used via ping command $ ping 10.33.1.123 -c1 -w 1 >/dev/null 2>&1 ; if [ $? -eq 1 ]; then echo "This IP is Not used"; else echo "This IP is used"; fi This IP is Not used Install required packages $ sudo yum install bind* -y Define zone files in master configuration ‘named.conf‘ file $ sudo vim /etc/named.conf Change 127.0.01 to a...

Oracle Linux ASM docker recipe

Image
General information In this setup we are: Installing docker Creating Non-root user (ynixon) with sudo and docker privileges ASM device: /dev/sdb1 Enabling sqlnet + ssh to the container Default ASM port is 1521 ssh port 2222 Passwords for root + grid os users in the container are “ynixon” Password for sys ASM user is “ynixon” Grid software is 12.2 without any patches Container Operating system is Oracle Linux 7.5 Within the container, there is no use of UDEV / ASMLIB or ASMFD – the asm_diskstring='/dev/asm*' ,'/dev/*' All test done on regular Ubuntu 14.04 There is a crontab job to keep 15 days of trace files + remove audit files. Prepare host for ASM device Make sure the device has permissions of the same container ids by applying UDEV rules $ vi /etc/udev/rules.d/100-asm.rules KERNEL=="sdb1", NAME="ASM_DISK", OWNER="54421", GROUP="54421", MODE="0660" udevadm trigger --sysname-match=sdb1 --ver...

Coloring alert.log output via tail and less

Image
Making my day to day job easier and convenient I like having some utilities and some aliases. We, the DBAs nation, have a need to look at the alert.log file frequently. So basically, I did the following: - Created a script to tail my alert.log file. - Colored the important words. - Added an alias to that script $ vi tail_alert.sh #!/bin/bash export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source ${SCRIPT_DIR}/platform.env ECHO_RED="\E[1;40;31m" ECHO_STD="\E[1;40;37m" LIGHT_RED=`echo -e '\033[1;40m\033[1;31m'` RED=`echo -e '\033[1;40m\033[0;31m'` LIGHT_PURPLE=`echo -e '\033[1;40m\033[0;35m'` GREEN=`echo -e '\033[1;40m\033[32m'` NORMAL=`echo -e '\033[0m'` if [ "$1" = "" ] then     ALERT_FILE=${ORACLE_BASE}/diag/${DIR_TYPE}/${ORACLE_UNQNAME,,}/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log     if [ ! -s ${ALERT_FILE} ]     then...

DBA Scripts coding considerations for best compatibility to any platform

Image
Did you find yourself trying to convert your DBA scripts to work on other OS or UNIX flavors ? This is a typical issue DBAs cope with, the solutions can be: Each system has its own best scripting code (PowerShell for windows, bash for Linux), let's keep some versions of the same code. Write the code in a common language for all systems Shell : In the past I used the old Posix shell (sh) which exited in all Unix systems. These days I use bash as is very common.  Perl : Oracle installation already has its own Perl, no need to install it. Java : Oracle installation already has its own java, no need to install it. Python : Python should be installed, but the libraries that can be used are huge, and you can write shorter code. Write in sql/plsql as much as you can, the external code will be minimal (cmd / sh). Work remotely from your convenient operating system, using your scripts written in the language you master. Use a few macros injected to your terminal. Why...

Basics commands for DBA part 1 - finding instance

Image
Hi, In the next few blogs I will discuss on scripting technics that DBA usually needs. I am concentrating in the commands, that are usually part of larger script. Later on I will submit some scripts that uses these technics. Identifying all instances running on the current machine Option 1:  # ps -ef |grep smon oracle    3025     1  0  2016 ?        00:00:48 asm_smon_+ASM oracle    11459      1  0 17:24 ?        00:00:00 ora_smon_ fdb root     12763 11332  0 17:52 pts/1    00:00:00 grep --color=auto smon SID is fdb and process id is 11459     Option 2:  # pgrep  -lf _pmon_ 3025 asm_pmon_+asm 11459 ora_pmon_ fdb SID is fdb and process id is 11459    Option 3:  Cleaner way for sid: $ ps -ef |grep 'ora_smon_.*$' | grep -v grep | awk -F_ '/ora_smon/{print $NF}' fdb SID is fdb Op...

Static routing

Image
Hi, Trying to configure dNFS with multipath I ran into the need of routing traffic from a specific devices (10G), this article describing how to do this in the Operating System (Centos/Redhat/Oracle). There are 2 different ways of configuring persistent static routes. The first approach requires adding entries for each device (NIC) to the files /etc/sysconfig/network-scripts/route-eth[X] For eth0, the file would be /etc/sysconfig/network-scripts/route-eth0 Example: echo "192.168.10.30 via 192.168.10.10" >> /etc/sysconfig/network-scripts/route-eth0 echo "192.168.10.32 via 192.168.10.12" >> /etc/sysconfig/network-scripts/route-eth1 To add the routes instantly, run the script /etc/sysconfig/network-scripts/ifup-routes. It takes the device name as input. The script is always run at boot time so the static routes are recreated after reboots. Example: /etc/sysconfig/network-scripts/ifup-routes eth0 /etc/sysconfig/network-scripts/ifup-ro...

oracle 11.2 on ubuntu

installing or upgrading on Ubuntu is not supported but can be done thanks to other bloggers it is well documented here https://lostinmac.com/2012/01/29/installtion-doracle-11gr2-sur-ubunutu-11-10/ thanks