|
|
Quick
UNIX and LINUX notes for Oracle DBAs The
following are the commands that you, as a DBA, do
not need to know but it is good to know. INDEX
Copy file archives in and out. Example: $cd
/etc
#Go to directory that you want to have a backup. $ls
| cpio –oc > /u01/cpio_bkup
#Copy all files in /etc to the /u01/cpio_bkup
file. $mkdir
/u01/copyhere
#Make a directory. $cd
/u01/copyhere
#Change directory to the created
directory. $cat
/u01/cpio_bkup | cpio –ic #Read
cpio_bkup file and copy all data into the current directory. $ls | cpio –oc
> /dev/rmt/0
#Copy all ls output files into tape device. Administration command for /dev and /devices. Example; $cd /dev/rmt #Check the content of the /dev/rmt directory. $devfsadm –c tape #A new tape device was added to the system. $cd /dev/rmt #Check the differences. $mt status #Check your magnetic tape status. $dttape init /dev/rmt/0
–volume X
#Initialize the tape using datatools. $obacktrack
#Use obacktrack if you have sqlback track. Disk partitioning and maintenance utility (Unix/Solaris only). Example; $format #Disk partitioning and maintenance utility. Initialize your server. Example: $su root $init 0
#Shutdown the server and have OK prompt. $init
6
#Reboot the server. $reboot
#Reboot the server. On the OK prompt, you can boot. Example: $ok boot #Boot from default disk. $ok boot cdrom #Boot from cdrom $ok boot 2th_boot_disk #Boot from a different boot disk. $ok nvalue /2th_boot_disk /…/…. #Define an alias for the second boot disk. $ok nvstore #Save the alias. Add a Unix/Linux group account. Example: $more /etc/group|grep dba #Check to see if the group exists. $groupadd –g dba #If not add a group. $more /etc/group|grep dba #Check to see that the group was added. Delete a Unix/Linux group account. Example: $more /etc/group|grep dba #Check to see if the group exists. $groupdel dba #Delete a group. $more /etc/group|grep dba #Check to see that the group was deleted. Describe instruction set architectures. Example: $isainfo –v
#Describe instruction set architectures
(64bits or 32bits). Display java version or other information. Example: $java –version
#Display java full version.
Assign a symbolic link. Example: $cd /u01 #Change your directory. $df –k >
myfile
#Create a file that contains disk space
allocation. $more myfile #Display the file content. $mkdir mylinkdir #Create a directory for all your links. $ln –s /u01/myfile /u01/mylinkdir/mylink
#Create a link. $more /u01/mylinkdir/mylink
#Display the link file content. Mount a device. Example: $mount /dev/rmt/1 /mnt #Mount a second external tape device. $mount /dev/dsk/c3t1d0s0 /mnt #Mount a disk device. $mount 127.0.0.1:/cdrom/cdrom0 /mnt
#Mount your disktop cdrom or if a server does
not have cdrom. A device status. Example: $mt -f /dev/rmt/0 status
Apply single patch to your O/S. Example: $patchadd patch_number #Add a single patch to your O/S. patchadd Add multiple patches to your O/S. Example: $cd /../patches #Change directory to downloaded patches. $for i in ‘ls –l 1*’;do #For all patches that their numbers start from 9. $patchadd $i #Read each patch number. $done #Apply patches. Remove a single patch from your O/S. Example: $patchrm patch_number #Remove a single patch from your O/S. Print system configuration. Example: $prtconf #Print all system configuration. $prtconf | grep Mem #Print the size of system memory.
$prtstat #For memory usage Print process system configuration. Example: $psrconf -v #Print all process system configuration. Display the latest release of your applied patches. Example: $showrev –p |grep patch_number #Display the latest information about your patches.
Symplicity Storage Manager Tool Example: $/usr/lib/symsm/bin/symsm & #Execute the Symplicity Storage Manager Tool. Synchronize your system. Do this before your shutdown. Example: $sync;sync;sync;halt
#Before halting your system, synchronize the
system. Tar to a tape. Example: $cd /u01/app/oracle #Change to a directory that you want to tar all information to a tape. $tar –cvf /dev/rmt/0 . #Copy all the current information to a tape. $tar –tvf /dev/rmt/0 #Display the tape table of contents. $tar –xvf /dev/rmt/0 #Extract files from tape. Un-mount the file system device. Example: $cd / #Go to route sub-directory. $mkdir u01 #Make a directory. $mount /dev/dsk/c3t1d0s5 /u01 #Mount it. $cd /u01
#Change your current directory to /u01. Add
files to it. $cd /
#Go back to route directory (make sure you are
not using /u01 device). $umount
#umount it. $cd /u01
#Change your current directory to /u01 (what
do you see?). Print name of current system. Example: $uname –a #Print name of current system with all information (-a). Dump a system file incrementally. Example: $umount /u01 #Un-mount the device that you want to do a dump. $ufsdump 0uf /dev/rmt/0 /dev/rdsk/c3t1d0s0
#Dump un-mounted device into a tape. $ufsdump 0uf /u01dump /dev/rdsk/c3t1d0s0
#Dump un-mounted device into a disk.
# 0 – all files, u – update the dump
record, f – file system device. $mount /dev/rdsk/c3t1d0s0
/u01 #Mount the device
that you have dumped. #Don’t forget when you un-mount and mount a file system, change the vfstab file also if needed. Restore a system file. Example: $mount /dev/rdsk/c3t1d0s0 /u01 #Mount the device that you want to restore a file system. $cd /u01 #Change the directory to the mounted device. $ufsrestore tvf
/dev/rmt/0
#Show the table of contents from tape. $ufsrestore rvf
/dev/rmt/0
#Restore recursively from tape to /u01.
# r – restore recursively, v – verbose,
and f - file system device. Add a Unix/Linux user account. Example: $more /etc/shadow|grep oracle #Check to see the Oracle user exists. $userdel –r
oracle
#Delete it and also its default directory. $mkdir /home/app
#Make the Oracle default directory. $chown oracle /home/app #Change its owner to the ‘oracle’ user. $useradd –u 1001 –d /home/app –s /bin/ksh oracle
#Create oracle user with default directory
/home/app and
#user id 1001, password ‘pass’ and default
shell (korn shell). $more /etc/shadow|grep
oracle #Check to see the
user was added. Delete a Unix/Linux user account. Example: $more /etc/shadow|grep oracle #Check to see the Oracle user exists. $userdel –r
oracle
#Delete it and also its default directory (-r
remove the default directory). $mkdir /home/app
#Make the Oracle default directory. $chown oracle /home/app #Change its owner to the ‘oracle’ user. $useradd –u 1001 –d /home/app –s /bin/ksh –p pass oracle
#Create oracle user with default directory
/home/app and
#user id 1001, password ‘pass’ and default
shell (korn shell). $more /etc/shadow|grep
oracle #Check to see the
user was added. $userdel –r
oracle
#Delete it and also its default directory (-r
remove the default directory). SQL
Backtrack To backup your Oracle data, you may have sql-backtrack. Remember the following function. Example: $obacktrack #Run SQL backtrack interactively. Networker Quick and simple commands. Example: $/usr/bin/nsr/networker start #Start networker. $/usr/bin/nsr/networker stop #Stop networker. $/usr/sbin/nsr/nsrjb –Hev #Diagnose networker. $tail /usr/logs/messages
#Check error messages. $tail -100 /usr/logs/daemon.log #Check logs. Managing
your disk (Unix/Solaris only):
Important
Network UNIX
files: /etc/hosts 127.0.0.1 localhost localhost.domain.name /etc/nsswitch.dns hosts: dns, files /etc/resolv.conf domain domain_name nameserver 155.33.222.140 search domain_name /etc/defaultrouter 127.0.0.1 #Router IP address.
Important
Network LINUX files: Basic linux network configuration files:
Making the following gross assumptions:
Your IP is: 192.168.0.1
Your Gateway is: 192.168.0.254
Your netmask is: 255.255.255.0
Your nameservers are: 192.168.0.2, 192.168.0.3, and 192.168.0.4
/etc/sysconfig/network
======================
NETWORKING=yes
HOSTNAME=your_machine_name.saa.senate.gov
GATEWAY=192.168.0.254
/etc/hosts
==========
127.0.0.1 localhost.localdomain localhost
192.168.0.1 your_machine_name.company.com your_machine_name
192.168.0.254 your_gateway.company.com your_gateway
(You don't absolutely *need* your gateway in the hosts file,
but I feel it does sometimes speed up some operations)
/etc/sysconfig/network-scripts/ifcfg-eth0
=========================================
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.0.1
NETMASK=255.255.255.0
/etc/resolv.conf
================
search gateway compay_gateway
nameserver 192.168.0.2
nameserver 192.168.0.3
nameserver 192.168.0.4
(The 'search' line is optional. You can have
up to 3 'nameserver' lines,and they don't need to be inside your network)
Generic Linux documentation can always be found at: http://www.tldp.org
Important
Network Information: IP address: Netmask: Network: Broadcast: Hostname: Gateway: Primary DNS: Secondary DNS: Ternary DNS:
Important
Notes to disable or enable Linux components:
How to disable or enable Software
component in LINUX for example telnet. First list or check to see if your software is on or off. $chkconfig –list (you must be as root) Open the "/etc/xinetd.d/telnet"
file. You
get something like this: [oracle@linux xinetd.d]$ more telnet # default: on # description: The telnet server serves
telnet sessions; it uses \ # unencrypted
username/password pairs for authentication. service telnet {
flags
= REUSE
socket_type = stream
wait
= no
user
= root
server =
/usr/sbin/in.telnetd log_on_failure
+= USERID
disable =
no } Change the disable parameter to "no" or "yes" in order to disable or enable the telnet session.
Apache
Web Server: ps -ef|grep
apache #check the web server was started. |