Unix Commands
Unix Commands
A symbolic (soft) linked file and the targeted file can be located on the same o r different file system while for a hard link they must be located on the same f ile system. 8. How would you change all occurrences of a value using VI? Use :%s///g ================================================================================ ================================= To help determine if root.sh has been executed, you can look for root owned file s in $ORACLE_HOME/bin: oracle:orprod46@lnxora12 /oracle/product/10.2.0.4apr09/bin > ls -al |grep root -rwsr-x--- 1 root dba 622819 Apr 24 01:16 extjob -r-sr-s--- 1 root dba 14931 Mar 11 2008 oradism ================================================================================ ================================= Give two UNIX kernel parameters that effect an Oracle install Kernal Parameters ( SHMMAX & SHMMNI ) $ grep -i sem /etc/system $ grep -i shm /etc/system ----------------------------------------------------------------------# more /etc/system |grep shmmax set shmsys:shminfo_shmmax=28454158336 # grep shmmax /etc/system set shmsys:shminfo_shmmax=45097156608 root@gaalstdbsblor02-stg # bc 42*1024*1024*1024 45097156608 --------------------------------------------------------------------------$ find /opt/new -size +100000k $ find /oracle -size +100000k $ find /oracle -size +10000k $ find /oracle -size +10000k ---------------------------------------------------------------------------------------------------------------------------oracle:r47ma4@malnxfdcrac1d /home/oracle > psg hot ------> 30096 is the parent process. oracle:r47ma4@malnxfdcrac1d /home/oracle > pstree -p 30096 ---->Child Process ---------------------------------------------------------------------------------------------------------------------------$ niscat passwd |grep etltest ----------------------------------------------------------------------------oracle:ortest58@admin-srv424 /var/opt/oracle > mpstat 2 3 oracle:ortest58@admin-srv424 /var/opt/oracle > iostat -c oracle:ortest58@admin-srv424 /var/opt/oracle > iostat -d oracle:ortest58@admin-srv424 /var/opt/oracle > uptime oracle:ortest58@admin-srv424 /var/opt/oracle > ps -ef | grep ora --------------------------------------------------------------------------------------------------------$ iostat -x 1 1 $ lsof -S 2 cat /proc/meminfo $ mpstat -P ALL $ netstat -s
$ ps -elf cat /proc/slabinfo $ top -b -n 1 (/mu/bin/top) $ uptime $ vmstat 1 1 The last sar raw data file, if NPRF_SAR_DATA setting value is true =================================================== 10. Briefly, how do you install Oracle software on UNIX. Basically, set up disks, kernel parameters, and run orainst. 2.) What UNIX command will control the default file permissions when files are created? Umask $ cpio -idmv < filename.cpio -------> to unzip the CPIO file $ find . -name 'file*' -print $which brconnect ---> Important commnad 2) :se nu ------------> Gives the Line Numbers(IMP)
3) :1,$d -> to remove the existing data 4) :%s/existing/new/g ------> change the new one 5) :%s/$/;/g ----------------------> To add last values 6) :%s/^/alter user /g ------------> To add front Values 7) dos2unix filename a) diff filename.txt filename2.txt 8) Last -10 9) History -20 5) to check port working or not --> telnet hostname portno a) prtconf | grep -i mem ---> Memory
b) prtdiag -v | pg -----------> Memory and type of CPU (IMP)-Frequency b) prtconf | head 6) prtconf | grep Memory --> To check Memory(RAM size) a) psrinfo ---------------------> No.of CPUs
b) psrinfo -p ---------------------> No.of CPUs 7) uname a --------------> O/s Version a) cat /etc/release nslookup gaalstdboemor01 ----IP address of the host
8) uptime ----------------->when it was up/load 9) $ORACLE_HOME/bin --> file oracle --> To know ORACLE level bit size(64 or 32) 10) isainfo -v (32bit or 64 bit) $isainfo -kv ------------------> To find out the BIT in Solaris $getconf LONG_BIT --->To find out the BIT -- Linux $ > cat /proc/cpuinfo ----------------> Linux Command to the CPU/processor oracle:orprd39a@lnxora10 /SW/Linux > uname -i i386=======================================> related to 32-bit 11) /usr/bin/isainfo -kv 12) $ showrev -p ------> o/s patches are installed > sar ---> to know memory > iostat xnMpz 5 ----> IOSTAT > sar 2 3 > vmstat > ipcs [to check the shared memory allocated to oracle or not]. > prstat -a [CPU Utilisation of which process] > mt stat [to see session and status of tape] 14) cat /etc/hosts ---------> to know IP address 15) cat /etc/passwd -----------> To know the Passwd in binary format ====================================== passwd -r nisplus smuddulu nette [CONTRACTOR] says: chkey -p ---------------------------------------------------------------------------> grep ORA-01843 alert*.log* > grep ORA-00600 alert*.log* >cat CreSelectInPartition.sql |grep -i select | wc -l > cat ResultCountInPartition.txt | wc -l ====================================== > stty erase ^? > ls -l | grep \^- | wc > find . -name cbl -print > mt stat > chown oracle:dba redolog redolog directory] > ipcs ot]. > prstat -a [To set backspace key as erase key] [To calculate number of files] [To find cbl file,directory in current directory] [to see session and status of tape] [To make owner to oracle user and dba group of [to check the shared memory allocated to oracle or n [CPU Utilisation of which process]
> prtconf | grep -i mem ------Ram size > prtdiag -v | pg root@njcsprdbdwhor01 # format --------------> Root User Searching for disks...done root@njcsprdbdwhor01 # prtdiag -v | more ----------------------------> Root Use r System Configuration: Sun Microsystems sun4u Sun Fire E6900 System clock frequency: 150 MHz Memory size: 81920 Megabytes root@njcsprprvn01 # vxdctl -c mode mode: enabled: cluster inactive Command used to share the diskgroup on both nodes #vxdg s init <disk-group> <disks> Note: use the -s option to import a disk group as cluster-sharable root@njcsprprvn01 # powermt display dev=all|grep Log Logical device ID=05B4 Logical device ID=05BC -----------------------------------------------------------------------------------------FORCEDIRECTIO: OS level in the /etc/vfstab file /dev/vx/dsk/dwhdwp-vxdg/u02vol /dev/vx/rdsk/dwhdwp-vxdg/u02vol /u02 ufs 3 no log ging,forcedirectio mount -o remount,forcedirectio `mountpoint-name` -->Applying online without the downtime ----------------------------------------------------------------disk_asynch_io = false . ----------------------------------------------------------------------------ps -ef | grep inherit --------> List all running Oracle Listeners ps -ef | grep smon --------> List all running Oracle Databases ipcs | grep oracle ----->Semaphores and shared memory segments belonging to ora cle Remove with ipcrm, but be carefull!!! ls -la . | awk '{total += $5}; END {print total}' -----> Prints the total size (in bytes) of all files in the current directory ls -laR . | awk '{total += $5}; END {print total/1024/1024 " Meg"}' --> Prints t he total size of files in the current directory and subdirectories below ls -laR | awk '{print $5 "\t" $9}' | sort -n | tail ---> Find the largest files in dir and subdirecotry. -------------------------------------------------------------------------------------------------------------------------$ df -h /t* | grep "\/dev\/vx\/dsk" | awk '{ print $3, $6}' | sort $ find . -mtime +15 -exec rm -f { } \ ; $ find . -mtime +5 -exec ls -l {} \; ----------------------------------------------------------------------------------------------------to remove 1 yrs old archive files use from os box; go to archive path then n
bash-2.05$ find*.log -mtime +365 -exec rm {} \; --------------------------------------------------------------------------------------------------------$export EDITOR=vi (ksh) $ crontab -e -----------------> To edit the cron jobs $ crontab -l ----------------> To list the cron jobs -----------------------------------------------------------------( csh shell like EPD ) stty erase ^? oraepd 4% setenv EDITOR vi oraepd 5% crontab -e --------------------------------------------------------------------epddb:oraepd 2% ps PID TTY TIME CMD 17159 pts/2 0:00 csh 17277 pts/2 0:00 ps -------------------------------------------------------------------------$ env | grep ORACLE_HOME $ env | grep PATH $ env | grep ORA_NLS33 $ env | grep ORACLE_BASE $ env | grep LD_LIBRARY_PATH $ env | grep ORACLE_PATH ---------------------------------------------------------$ PATH=$PATH:$ORACLE_HOME/OPatch ----------------it is IMP $ export PATH ----------------------------------------------------------Udump 1 day file move to NEW location and delete ---------------------------------------------------------------for i in `find . -type f -mtime -1` do mv $i /u01/app/oracle/admin/SBLTPP/udump/new/ done From NEW Location to UDUMP location ------------------------------------------------------------------for i in `find . -type f -mtime -1` do mv $i /u01/app/oracle/admin/SBLTPP/udump/ done -----------------------------------------------------------------------------------------------------------ORACLE_SID = DWHDWP ORACLE_HOME=/u01/app/oracle/product/9.2.0.7 ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data PATH=/bin:/usr/bin:/usr/openwin/bin:/usr/sbin:/usr/ccs/bin:/sbin:$ORACLE_HOME/bi n: LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:$ORACLE_HOME/lib: export ORACLE_HOME ORACLE_SID export ORA_NLS33 LD_LIBRARY_PATH PATH Note : After modified the changes in .profile, make sure that ORACLE_HOME variab
le is in 9207 version Run the .profile as $. ./.profile ----------------------------------------------# cat .profile ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/9.2.0.6 #NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1 #for English #NLS_LANG=TURKISH_TURKEY.WE8ISO8859P9 #for Turkish #ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data PATH=/bin:/usr/bin:/usr/openwin/bin:/usr/sbin:/usr/ccs/bin:/sbin:$ORACLE_HOME/bi n: PATH=$PATH:/usr/local/bin: #LD_LIBRARY_PATH=/usr/lib:/usr/openwin/lib:$ORACLE_HOME/lib: export ORACLE_BASE ORACLE_HOME export NLS_LANG ORA_NLS33 DISPLAY LD_LIBRARY_PATH PATH -------------------------------------------------------------------------------------------------Profile in cshell-----> .cshrc PATH=/oracle/S50/920_64/bin:/local/user/oras50:/usr/sap/S50/SYS/exe/runU:/usr/sa p/S50/SYS/exe/run:/etc:/usr/bin:.:/opt/EMCpower/bin/sparcv9:/etc/emc/bin:/usr/cc s/bin:/usr/ucb LD_LIBRARY_PATH=/usr/sap/S50/SYS/exe/run:/usr/sap/S50/SYS/exe/runU:/oracle/S50/9 20_64/lib ORACLE_PSRV=S50 ORACLE_SID=S50 ORACLE_HOME=/oracle/S50/920_64 ORACLE_BASE=/oracle ORA_NLS33=/oracle/S50/920_64/ocommon/nls/admin/data $ relink all ---------------------------------------------------------------------------------------------DISPALY=10.132.161.1:1.0 DISPALY=gaalstdboemor01:0.0 export DISPLAY admintool xhost + #/usr/openwin/bin/xclock VNCServer Path: PATH=$PATH:/opt/sfw/bin:/usr/openwin/bin ; export PATH vncserver kill -9 :1 Note: We have to give the permissons to log file located at /tmp location ---------------------------------------------------------------IMP IMP IMP To know which ORACLE_HOME it is using ora9i@gaalstdboemor01-Stg# ps -eaf | grep ora9i 22073 1 0 May 25 ? ora9i 3395 98 0 19:28:16 pts/1 ora9i 29040 1 0 May 25 ? pmon 0:00 ora_pmon_STGRMAN 0:00 grep pmon 0:00 ora_pmon_OEMREP
ora9i@gaalstdboemor01-Stg# pwdx 22073 22073: /oraarchive/temp_9206/dbs -----------------------------------------------------$ df -h . Filesystem size used avail capacity Mounted on /dev/md/dsk/d70 135G 107G 26G 81% /u01 $ du -sh . 9.0G . $ pwd /u01 $ Space not getting cleared from /u01 area in NJCSPRDBSBLOR01 server. -------------------------------------------------------------------------Donot Use below commands $psradm ----------> Disable the CPU as os level $cfgadm ----------> Couldn t disable the CPU at Hardware level ----------------------------------------------------------------------------EIDM R8 DR Database in ShareDB DR Cluster Projetct Plan Steps : 1. Stop the Seebeyond, Tibco and EIDM STG applications, because they depend on ShareDB STG cluster 2. Bring the Shared DB STG Cluster Down 3. Request Stop R1 to R2 replication for all PRD servers. 4. Remove STG LUNs and Present R2 LUNs for Shared DB Cluster 5. Boot the Shared DB Cluster in DR environment. 6. Import the ITIM Disk Group replicated from PRD and mount DR File systems 7. Request HCL DBA to recover the Database 8. ITIM DR database cluster integration 9. TSM Integration for R8 database 10. Cluster Failover tests. 11. Test the Application functionality. 12. Shutdown ShareDB DR cluster 13. Remove R2 LUNs and Present STG LUNs for Shared DB Cluster. 14. Start R1 to R2 Replication for all PRD servers in Adaptive Copy (Disk Copy ) mode 15. Boot the ShareDB Cluster in STG environment 16. Start all databases under cluster control. 17. Start Seebeyond, Tibco and EDIM Applications on all servers Command Line Implementation plan 1. Log into gaalstdbshaor02 as root. 2. Shutdown Shared DB STG Cluster > root@gaalstdbshaor02 Stg # scshutdown g0 -y 3. Boot the Cluster Nodes in DR environment: > ok boot rootdisk-dr -r 4. Import the eidmr8p-vxdg disk group to eidmr8p-dr-vxdg > root@gaalstdbshaor02 DR # vxdg C n eidmr8p-dr-vxdg import eidmr8p-vxdg 5. Start the DR disk group volumes root@gaalstdbshaor02 DR # vxdg g eidmr8p-dr-vxdg startall
6. Add the entries for EIDM R8 DR File systems to /etc/vfstab file on both nodes /dev/vx/dsk/eidmr8p-dr-vxdg/e02vol /dev/vx/rdsk eidmr8p-dr-vxdg/e02vol /e02 ufs 3 no logging /dev/vx/dsk/eidmr8p-dr-vxdg/e03vol /dev/vx/rdsk eidmr8p-dr-vxdg/e03vol /e03 ufs 3 no logging /dev/vx/dsk/eidmr8p-dr-vxdg/e04vol /dev/vx/rdsk eidmr8p-dr-vxdg/e04vol /e04 ufs 3 no logging /dev/vx/dsk/eidmr8p-dr-vxdg/e05vol /dev/vx/rdsk eidmr8p-dr-vxdg/e05vol /e05 ufs 3 no logging /dev/vx/dsk/eidmr8p-dr-vxdg/e06vol /dev/vx/rdsk eidmr8p-dr-vxdg/e06vol /e06 ufs 3 no logging /dev/vx/dsk/eidmr8p-dr-vxdg/oraarchiveevol /dev/vx/rdsk eidmr8p-dr-vxdg/oraarchi vee /oraarchivee ufs 3 no logging 7. Mount and unmount the file systems to check the filesystem are mounting witho ut any issues. On both nodes # mkdir /e02 /e03 /e04 /e05 /e06 /oraarchivee # for d in /e02 /e03 /e04 /e05 /e06 /oraarchivee > do > chown ora9i:dba $d > mount $d > unmount $d > done # 8. Create a failover resource group > # scrgadm a g rg-eidmr8p-dr-db > # scrgadm c g rg-eidmr8p-dr-db y nodelist=gaalstdbshaor02, gaalstdbshaor01 9. Edit and add the following line in /etc/hosts to reflect new logical-hostname on both nodes 10.132.128.17 gaalstsha-dr-eidmr8p 10. Add a network resource to the failover resource group. > # scrgadm -a -L -j rs-gaalstsha-dr-eidmr8p -g rg-eidmr8p-dr-db \ -l gaalstsha-dr-eidmr8p 11. Create the resource oracle-hastp-rs of type SUNW.HAStoragePlus. > # scrgadm -a -j rs-hastp-dr-eidmr8p -g rg-eidmr8p-dr-db -t SUNW.HAStoragePlus -x FilesystemMountPoints=/e02,/e03,/e04,/e05,/e06,/oraarchivee \ -x AffinityOn=TRUE 12. > # > # > # > # Enable the resources of the EIDM R8 resource group scswitch e j rs-gaalstsha-dr-eidmr8p scswitch e M j rs-gaalstsha-dr-eidmr8p scswitch e j rs-hastp-dr-eidmr8p scswitch e M j rs-hastp-dr-eidmr8p
13. Hand over the Cluster-Resource to DBA's for Oracle Recovery. 14. Once DBAs confirm, integrate Oracle and listener with Sun Cluster. > # scrgadm -a -j rs-ora-dr-eidmr8p -g rg-eidmr8p-dr-db \ -t SUNW.oracle_server \ -x Connect_string=scmon/scmon123 \ -x ORACLE_SID=ITIMPRD \ -x ORACLE_HOME=/u01/app/oracle/product/9.2.0.6 \ -x Alert_log_file=/u01/app/oracle/admin/ITIMPRD/bdump/alert_ITIMPRD.log \ -y resource_dependencies=rs-hastp-dr-eidmr8p
> # scrgadm -a -j rs-ora-lsnr-dr-eidmr8p -g rg-eidmr8p-dr-db \ -t SUNW.oracle_listener \ -x LISTENER_NAME=listenerit \ -x ORACLE_HOME=/u01/app/oracle/product/9.2.0.6 \ -y resource_dependencies=rs-hastp-dr-eidmr8p 15. > # > # > # > # Enable Oracle and listener resources scswitch e j rs-ora-dr-eidmr8p scswitch e M j rs-ora-dr-eidmr8p scswitch e j rs-ora-lsnr-dr-eidmr8p scswitch e M j rs-ora-lsnr-dr-eidmr8p
16. Verify Oracle and listener resources for EIDM R8 DR Database are online. 17. TSM Integration a. Create the executable scripts for start, stop and probe file of R8EIDM in the location /opt/Tivoli/tsm/client/ba/bin directory for the below files The content of one files should be root@gaalstdbshaor01 # more stopEIDMR8P.sh #!/bin/sh /opt/tivoli/tsm/client/ba/bin/dsmsched_stop ITIMPRD root@gaalstdbshaor01 # more startEIDMR8P.sh #!/bin/sh /opt/tivoli/tsm/client/ba/bin/dsmsched_start ITIMPRD root@gaalstdbshaor01 # more probeEIDMR8P.sh #!/bin/sh /opt/tivoli/tsm/client/ba/bin/dsmsched_probe ITIMPRD b. Create the TSM resource under oracle resource group. root@gaalstdbshaor01 # scrgadm -a -t SUNW.gds root@gaalstdbshaor01 # scrgadm -a -t SUNW.gds scrgadm -a -g rg-eidmr8p-dr-db \ -j rs-tsm-dr-eidmr8p \ -t SUNW.gds \ -x Start_command="/opt/tivoli/tsm/client/ba/bin/startITIMPRD.sh" \ -x Stop_command="/opt/tivoli/tsm/client/ba/bin/stopITIMPRD.sh" \ -x Probe_command="/opt/tivoli/tsm/client/ba/bin/probeITIMPRD.sh" \ -y Start_timeout=120 \ -y Stop_timeout=180 \ -x Probe_timeout=60 \ -y Failover_mode=SOFT \ -y Port_list="9999/tcp" c. Bring the resource online. root@gaalstdbshaor01 # scswitch e j rs-tsm-dr-eidmr8p 18. Failover the EIDM R8 Resource Group to the other node and verify Oracle and listener resources for EIDM R8 DR Database are online on Node 2. Else co-ordina te with DBA and fix the issue. Once issue is fixed start on the node2 and give t o apps team. ------------------------------------------------------------------------------------------------------------For Sharee memory Segment (shmmax) This solution is applicable for Linux. Please look in to the URL for more details. http://www.globule.org/docs/doc007.html
-------------------------------------------------------------------------------------------------------------who u g o a = = = = user group other all action + = add - = remove permissions r = read w = write x = execute
Examples: chmod a+r sample.f - Adds read permission for all users to the file sample.f. chmod o-r sample.f - Removes read permission for others to the file sample.f. chmod og+rx prog* - Adds read and execute permissions for group and others to all files which contain "prog" as the first four characters of their name. chmod +w * - Adds write permission for user to all files in current directory. File access permissions can also be changed by a numerical (octal) chmod specifi cation. Read permission is given the value 4, write permission the value 2 and e xecute permission 1. r w x 4 2 1 These values are added together for any one user category: 0 1 2 3 4 5 6 7 = = = = = = = = no permissions execute only write only write and execute (1+2) read only read and execute (4+1) read and write (4+2) read and write and execute (4+2+1)
So access permissions can be expressed as three digits. For example: user chmod 640 file1 chmod 754 file1 chmod 664 file1 rwrwx rwgroup r-r-x rwothers --r-r--
ls -l names1
chmod o-r names1 ls -l names1 ls -l names2 chmod g+w names2 ls -l names2 ls -l file* chmod go-r file* ls -l file*