Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Tuesday, July 7, 2015

Shell script–Utility functions

Hello fellow DBAs, Oracle and Linux enthusiasts.

Today I'm going to share the script I use to "source" utility functions to the shell scripts I commonly use for my daily DBA tasks.

Let's add some explanation:

  • continueQuestion
    • This function is a simple "Continue? (y/n)" question. As this is used a lot in interactive scripts, seemed like a good idea for me to add it to the utility functions script.
  • debugPrint
    • For debugging, it adds the timestamp prior to the message. Allows you to keep track of what, where and when something is happening.
  • msgPrint
    • Allows you to format in several ways the output that you want to send to console/log file.

I hope you find this useful and makes your job better!

Monday, July 6, 2015

Shell script–Quickly check Oracle listeners

Hello everyone,

Today I would like to share something with you. In my day to day work, I have encountered more than one place where DEV environments are spread through only some hosts. This normally leads to creating several databases on the same host and to create several listeners to be able to split communication through several ports.

Having this, after OS patches or any OS related activity that would require the database software to be shutdown, it's an usual case that people forget to start listeners.  For this I have this useful script:

Enjoy.

Hope this helps in making your job easier.

Friday, September 28, 2012

Configure Solaris 10 DNS client

Let’s get started!

I just got my brand new Solaris 10 server, but somehow although I have a DNS server in my domain, it cannot resolve any names given.  What’s wrong?

We have to first check the existence of some files and the status of the DNS client service.

So, first thing to do:  check the service

# svcs -a | grep dns
 
disabled     XX:XX:XX    svc:/network/dns/server:default
disabled     XX:XX:XX    svc:/network/dns/client:default



Then, let’s check the files.


Does the resolver configuration file exists? Try to see its contents with the following command.



# cat /etc/resolv.conf
 
cat: cannot open /etc/resolv.conf

Let’s then, create the file and edit it to add our name servers.



# touch /etc/resolv.conf
 
# vi /etc/resolv.conf

Add some lines with the following format



domain somedomain.com
nameserver 10.11.12.13
nameserver 14.15.16.17
nameserver 18.19.20.21
search firstdomain.com,seconddomain.com,thirddomain.com

where domain is the domain to look for as default, nameserver is the IP of each name server we have (up to three) and search is the domains that must be added as sufix to the name to look for if none was given.


That’s it with the resolver.  Now, we should go check the naming service switch file, /etc/nsswitch.conf


If you look for some nssswitch file in the /etc directory you’ll find that there are several templates already configured for your use. So backup your current file and replace it with the nsswitch.dns file provided.



# cp /etc/nsswitch.conf /etc/nsswitch.orig
 
# cp /etc/nsswitch.dns /etc/nsswitch.conf

Once you’re done.  Enable the dns client service and check again its status



# svcadm enable /network/dns/client
 
# svcs -a | grep dns
disabled    XX:XX:XX    svc:/network/dns/server:default
online      XX:XX:XX    svc:/network/dns/client:default
 

And welcome to the naming world, Solaris 10.


Hope this helps some of you.

Friday, June 3, 2011

Solaris 10 and the Linux Zone

For anyone out there trying to make an installation of Oracle with this configuration, I wish you the best of luck and I hope you don’t spend hours and hours researching, googling and figuring out the best way to make this work.

As we’re already half the way into 2011, past the first decade of the 21st century, you may be asking yourselves (as I did) why the hell a client wants to keep Oracle 9i if there’s 2 new versions out there.

Anyhow, the fact is that we’re stuck with UIX systems that aren’t meant to host Oracle under version 10g and we’re trying to get a dinosaur into a beauty spa.

Here’s what I did after numerous failed attempts a lot of research and an organization of tutorials, whitepapers and some common sense.

Users and Groups

I like to have access with a “support” account that has root privileges in order to be able to work remotely on the server. So, first step after installation, must be create groups and users.

Here’s how and soon I’ll post a full explanation about the commands for user and group management under Solaris 10

First the group: support

Group creation commands
groupadd -g 100 support
Group creation commands

Next the users: support

User creation commands
useradd -u 1000 -c "Support User" -m -d /export/home/support -e "" -g support -G root,adm -s /usr/bin/bash support
User creation commands

Linux Zone

In order to be able to install Oracle Database 9i inside the Solaris box you have to create a container, that is a box inside the box which will have the compatible linux libraries and files needed for the database to run smoothly.

So the next step is to create the Linux Zone.  For this purpose we will need an ISO or CD/DVD of a compatible linux image (RHEL or CentOS 3.5 to 3.8).  As for this point there’s a little problem: Up to 3.8, CentOS ISOs ARE ON HELL OF A GHOST!!!  It’s very HARD TO FIND.  I hope, truly, deeply that when the time comes and you’re reading this guide, you can still find it out there, or at least be able to tell your client to go jump off the roof or something.  Of course, the client could use the common sense (the least common of all senses) and UPGRADE THE GODDAMNED database system!

Once the flames have been thrown, let’s continue.  :)

Another way around is to give it a shot to another RHEL 3 free version, Whitebox Linux 3

Zone creation commands
mkdir -p /export/zones

mkdir -p /export/zones/linux

chmod 700 /export/zones/linux

zonecfg -z linux

linux: No such zone configured
Use 'create' to begin configuring a new zone.

zonecfg:linux> create -t SUNWlx
zonecfg:linux> add net
zonecfg:linux:net> set physical=e1000g0
zonecfg:linux:net> set address=10.10.10.13
zonecfg:linux:net> end
zonecfg:linux> add fs
zonecfg:linux:fs> set dir=/cdrom
zonecfg:linux:fs> set special=/cdrom
zonecfg:linux:fs> set type=lofs
zonecfg:linux:fs> add options=[ro,nodevices]
zonecfg:linux:fs> end
zonecfg:linux> set zonepath=/export/zones/linux
zonecfg:linux> set autoboot=true
zonecfg:linux> verify
zonecfg:linux> commit
zonecfg:linux> exit

zoneadm -z linux install
Zone creation commands

At this point you should have the linux image CD/DVD/ISO available in the selected media so that the installation of the zone goes as painless as it can go.

Once the DVD ISO was in place, I excecuted the command

FAILED Install attempt
# zoneadm -z linux install

Installing cluster 'desktop'

Would you like the system to eject the final install CD when
  installation of 'linux' is complete? ([y]/n)

The final install CD WILL be ejected.

You will need CDs 1 - 3 (or the equivalent DVD) to
install CentOS 3.8.
Installing miniroot for zone 'linux'.
Attempting to locate 30 packages...

Installing 30 miniroot packages...

Setting up the initial lx brand environment.
System configuration modifications complete.
Duplicating miniroot; this may take a few minutes...
Booting zone miniroot...
Miniroot zone setup complete.

Performing full install for zone 'linux'.
Attempting to locate 669 packages...

Installing zone 'linux' from
  CentOS 3.8, CD 1.


Installing 433 packages; this may take several minutes...

Please insert CentOS 3.8, CD 2, or a
  CentOS 3.8 DVD in the removable media
  drive and press <RETURN>.

Install of zone 'linux' from
  CentOS 3.8, CD 2 FAILED.

Attempt to eject '' failed.
Please eject the disc manually.

Installation of CentOS 3.8 to zone
  'linux' FAILED Fri Jun  3 12:10:16 VET 2011.

Cleaning up after failed install...

Installation of zone 'linux' FAILED.

See the log file:
  '/export/zones/linux/root/var/log/linux.install.3986.log'
for details.
 
FAILED Install attempt

Maybe you didn’t notice it, but the installation process doesn’t have any interactivity, so it would be only a matter of guessing when to switch the Images/CDs/DVDs.  But not al hope is lost.  The installation of the zone can be done with the –d <path_to_ISOs> option which will look in that path not for the files but for the ISO images.  It will mount the images as needed and copy all that needs to be copied.

So, after issuing a new  # zoneadm –z linux uninstall command to have the zone once more in the “configured” state, I issued the new and improved version of my installation command.

SUCCESSFUL Install attempt
# zoneadm -z linux install -d /export/CentOS
Installing distribution 'CentOS 3.8'...
Installing cluster 'desktop'
Installing miniroot for zone 'linux'.
Attempting to locate 30 packages...

Installing 30 miniroot packages...

Setting up the initial lx brand environment.
System configuration modifications complete.
Duplicating miniroot; this may take a few minutes...
Booting zone miniroot...
Miniroot zone setup complete.

Performing full install for zone 'linux'.
Attempting to locate 669 packages...

Installing zone 'linux' from
  ISO "/export/CentOS/CentOS-3.8-i386-bin1of3.iso".


Installing 433 packages; this may take several minutes...

Attempting to locate 236 packages...

Installing zone 'linux' from
  ISO "/export/CentOS/CentOS-3.8-i386-bin2of3.iso".


Installing 134 packages; this may take several minutes...

Attempting to locate 102 packages...

Installing zone 'linux' from
  ISO "/export/CentOS/CentOS-3.8-i386-bin3of3.iso".


Installing 102 packages; this may take several minutes...

Completing installation; this may take a few minutes.
Setting up the initial lx brand environment.
System configuration modifications complete.
Installation of CentOS 3.8 to zone
  'linux' completed Fri Jun  3 14:01:17 VET 2011.

Installation of zone 'linux' completed successfully.

Details saved to log file:
    "/export/zones/linux/root/var/log/linux.install.8971.log"
 
SUCCESSFUL Install attempt

After the installation is ready, the Zone will be at a ready state.  And we can proceed to boot it so it get running.

Soon, the Oracle Installation Process over the Linux (CentOS 3.8) Zone

Last words and Special Thanks

I hope that this guide made your experience installing Oracle 9i over a Solaris box one with a lot less pain that it normally is.

A word of advice for Oracle.  Guys, you really REALLY have to make these processes easier.  Or, at least, publish some good guides to help people throughout the whole thing.  We all understand that goes against your high paying support service, but it will give you a lot more customers and maybe bring some from MySQL and PostgreSQL.

Special thanks must go to First Alternative and their excellent tutorials and informative pages.