Shell Scripting for begginers

Bash Scripting is one of the skills that any system adminsitrator or DBA’s should knows, why ? because it’s making your life much easier, for example, imagine you are about to change the persimisson of files for example under one directory, and inside it you have 10 files (i know it’s that much), Will you do it one by one, it will be a good idea, maybe you are fast typer but what if it will be more than 10 ?
Shell Scripting is the solution for this.

Bash is comamnd language and it’s widely available on various operating system, the name it’s self came from Bourne-Again SHell

Shell which is allows you for interactive or non-interactive execution.

Finally; which is scripting, the commands that will be executed one by one.

One of the simplest example which is “Hello World”, Save it as hello.sh

 

#!/bin/sh
echo “Hello, World”

if we need to modify this script to read name of the user; it will be like this :-

#!/bin/sh
echo “What is your name?”
read MY_NAME
echo “Hello, $MY_NAME”

Mathamtics examples :-

Shell Scripting can be used also in mathamtics operations such as the below:-

#!/bin/bash
((sum=25+35))
echo $sum
#!/bin/bash
((area =2*2))
echo $area

Looping :-

If you want to repeat something, then you should use either for or while which will make your life easier:-

The following example, will print the counter number each time, as you see the counter start from 5 and it will out once it will be 0

#!/bin/bash
for (( counter=5; counter>0; counter– ))
do
echo -n “$counter ”
done
printf “\n”

Using While but once it will be 5 the loop will be terminated.

#!/bin/bash
Bol_value=true
count=1
while [ $Bol_value ]
do
echo $count
if [ $count -eq 5 ];
then
break
fi
((count++))
done

 

Operator Description
-eq Checks if the value of two operands are equal or not; if yes, then the condition becomes true.
-ne Checks if the value of two operands are equal or not; if values are not equal, then the condition becomes true.
-gt Checks if the value of left operand is greater than the value of right operand; if yes, then the condition becomes true.
-lt Checks if the value of left operand is less than the value of right operand; if yes, then the condition becomes true.
-ge Checks if the value of left operand is greater than or equal to the value of right operand; if yes, then the condition becomes true
le Checks if the value of left operand is less than or equal to the value of right operand; if yes, then the condition becomes true.

 

If you want to learn more from here

Summary:-

  • Shell is a program which interprets user commands through CLI like Terminal.
  • Shell scripting is writing a series of command to execute.
  • Shell scripting can help you create complex programs

 

Cheers

Osama

Change Hostname in Oracle Solaris 11.3

In this post i will share how to change hostname in Solaris 11.3 , i never test this way on other version but regarding to Oracle it will be working without any issue.

  • as root user, list the current hostname using the below command :-

# svccfg -s system/identity:node listprop config

config                                                         application
config/enable_mapping            boolean     true
config/ignore_dhcp_hostname boolean     false
config/loopback                        astring
config/nodename                      astring       solarisdb1

  • change hostname to new one

# svccfg -s system/identity:node setprop config/nodename=”solarisdbnew1″

  • Refresh and restart

# svcadm refresh system/identity:node

# svcadm restart system/identity:node

  •  Check the configuration

# svccfg -s system/identity:node listprop config

 Thank you

Osama

Out Of memory , Not Enough Space Solaris 11

SQL> startup mount ;
ORA-27102: out of memory
SVR4 Error: 12: Not enough space
Additional information: 1671
Additional information: 16106127360
Additional information: 64424509440

The Above error appeared When trying to start Oracle 12c on Solaris 11.3, this is published bug 
Bug:20635316 – 12C DATABASE INSTANCE STARTUP FAILS WITH ORA-27102: OUT OF MEMORY
Solaris using something called OSM , Optimized Shared memory You can know more about it here 
To avoid this error as workaround just set the parameter

_use_osm=FALSE

Thanks
Osama

Create new swap file to Linux

to add new swap file to Linux just follow the below steps , in my case i will add 32GB and i am not using LVM :-

  • just create file by the below command :-
    • touch /new.swap
  • Write on the file :-
    •  dd if=/dev/zero of=/new.swap bs=1024 count=33554432
  • Format the file :-
    • mkswap /new.swap
  • Add the file to the system as a swap file.
    • swapon /new.swap
  • finally add it to fstab :-
    • /new.swap none swap sw 0 0
Thanks
Osama

Direct NFS: please check that oradism is setuid

The above error appeared in Database Alertlog  and it’s related to permission, i am using DNFS as file system for Database :-

 ls -ltr  $ORACLE_HOME/bin/oradism

-rwxrwxr-x 1 sorabill oinstall 109247 Jul  7  2014 /u01/app/oracle/product/12.1.0/dbhome_1//bin/oradism

as you see from the above the permission for this file is wrong 
  • Change to root user
  • Run the following command :-
    • cd /u01/app/oracle/product/12.1.0/dbhome_1//bin
    • chmod 750 oradism
    • chmod u+s oradism
  • Restart DB.
Check again.
Cheers
Osama

Result: Clock synchronization check using Network Time Protocol(NTP) failed RAC

When trying to Run the Runcluvfy command to check RAC pre requsiites the NTP failed , but at the same time it’s gives you the solution to solve it  :-

in the following file :- /etc/sysconfig/ntpd open it and edit it, add the following :-

[root@prddb2 .ssh]# cat /etc/sysconfig/ntpd
# Drop root to id ‘ntp:ntp’ by default.
OPTIONS=”-x -u ntp:ntp -p /var/run/ntpd.pid -g”

Add the above letter in RED color only.

Thanks
Osama

Skip DNS reslov.conf check during RAC configuration

Before start reading this post you should know that Oracle is highly recommended using DNS while configure Oracle RAC include to this it will make your life easier in case any one wants to change the IP’s.

However today i was working on EBS installation using startCD51 and this is allow me to install EBS directly on RAC but the customer database RAC not configured to use DNS so everytime i was trying to install EBS

The following Error shown up in my face :-

INFO: Verification Result for Node:RAC1,RAC2WARNING: Result values are not available for this verification taskINFO: *********************************************INFO: Task resolv.conf Integrity: This task checks consistency of file /etc/resolv.conf file across nodesINFO: Severity:CRITICALINFO: OverallStatus:OPERATION_FAILEDINFO: ———————————————–

and there is nothing i can do to skip this error,

i choose to do the following ;-

Rename resolv.conf to resolv.conf.old for example

and re run the installation again .

perfect worked for me

Thanks
Osama

Maximum locked memory check Oracle

INFO: Maximum locked memory check: Check maximum locked memory setting on the system
INFO: Severity:IGNORABLE
INFO: OverallStatus:VERIFICATION_FAILED

To solve this issue just add the following to /etc/security/limits.conf

*                soft   memlock         unlimited
*               hard    memlock         unlimited

Thank you
Osama mustafa

Error : Cannot export Display Linux

There are different tools to do X11 forwarding on Windows one of them Xming it’s small software and very easy to use no need to do any special configuration only run the installation file.

But sometimes you are using this application and try to run the GUI on your desktop or laptop it’s working like you excepted, one simple solution to solve it.

I am using as ssh client Putty, before put the server ip from putty left panel

  • Connection > SSH > X11
  • Check X11 forwarding: [x] Enable X11 forwarding
  • Add to the “X display location” field: localhost:0.0
Cheers
Osama

create IPS repository in Solaris 11.2

I discussed before how to create package repository on Linux here, the same could be happened on Solaris 11.2 when you install Database any version mandatory packages should be installed to make it easy repository helps you a lot and will be available any time you need, and Image packaging system(IPS) repository is one of the important things in Solaris 11 onwards.

You need to download the following files & upload them to the server :-

Once the file is ready upload them to the server under one file called Repo for example. it should looks like the below :-

#ls -lrt
total 14373947
-rwx——   1 root     root     1771800121 Aug  9 08:24 sol-11_2-repo-1of4.zip
-rwx——   1 root     root     1889867782 Aug  9 11:20 sol-11_2-repo-2of4.zip
-rwx——   1 root     root     1902167161 Aug  9 22:34 sol-11_2-repo-3of4.zip
-rwx——   1 root     root     1790358735 Aug 10 00:16 sol-11_2-repo-4of4.zip
-rwx——   1 root     root        5594 Aug 10 20:16 install-repo.ksh
-rwx——   1 root     root         228 Aug 10 20:17 sol-11_2-repo-md5sums.txt
drwxr-xr-x   2 root     root           2 Aug 10 20:40 repo

#pkg publisher
PUBLISHER TYPE STATUS URI
solaris origin online http://pkg.oracle.com/solaris/release/

 as you see from the above output package publisher still working under oracle Link. Let’s Start Working, Set the executable bit for install-repo.ksh and execute like below.

#./install-repo.ksh -d /export/oracle/repo/ -v -c
Comparing checksums of downloaded files…done. Checksums match.
Uncompressing sol-11_2-repo-1of4.zip…done.
Uncompressing sol-11_2-repo-2of4.zip…done.
Uncompressing sol-11_2-repo-3of4.zip…done.
Uncompressing sol-11_2-repo-4of4.zip…done.
Repository can be found in /export/oracle/repo/.
Initiating repository verification.

Again Check the current publisher.

#pkg publisher
PUBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F http://pkg.oracle.com/solaris/release/

configure the new publisher, Path should be the same.

#pkg set-publisher -G ‘*’ -M ‘*’ -g file:///export/oracle/repo solaris

#pkg publisher
UBLISHER                   TYPE     STATUS P LOCATION
solaris                     origin   online F file:///export/oracle/repo

Configure the repository service to point to the new location by run the following command :-

# svccfg -s application/pkg/server setprop pkg/inst_root=/export/oracle/repo 


Check

# svcprop -p pkg/inst_root application/pkg/server

Reload the Services Just to confirm :-

# svcadm refresh application/pkg/server

Cheers
Osama Mustafa