Search Articles

How to Spool SqlPlus Output to Microsoft Excel Format




It is very easy to export and save output of executed query in xls sheet using toad but how to do it on sql prompt. To do so you need to use some text formatting options and spool file name to save output.

To Spool SQLPLus output to Excel (.xls) file, the trick is to turn On "MARKUP HTML".


SET PAGESIZE 40000

SET FEEDBACK OFF

SET MARKUP HTML ON

SET NUM 24

SPOOL file_name.xls



---- Execute your query



SPOOL OFF

SET MARKUP HTML OFF

SPOOL OFF



Example:

SQL> SET PAGESIZE 40000

SQL> SET FEEDBACK OFF

SQL> SET MARKUP HTML ON

SQL> SET NUM 24

SQL> SPOOL ora_htl_hist.xls

SQL>

SQL>SELECT COUNT * FROM ORA.HTL_HIST;

SQL>

SQL>SPOOL OFF

SQL>SET MARKUP HTML OFF

SQL>SPOOL OFF


A file name ora_htl_hist.xls will be generated in the current directory. This is the best way to export and save sql plus output to xls sheet.

Read more ...

VI editor shows the error Terminal too wide within Solaris


Terminal too wide


You may receive the following error when using VI editor within Solaris. I got this error when I was adding tns entry in tnsnames.ora file.



$ vi tnsnames.ora

Terminal too wide




Here, Vi will not allow to edit files. For editing you must increase the number of columns as shown below.


To resolve this increase the number of columns using below command:

stty columns 120


Read more ...

How to Change the Default SSH Port When Selinux is Enable on Linux

In this How-To guide we are going to explain you though changing the default SSH port on a Linux system.

SSH - The Secure Shell Protocol by default uses port 22. You can change this port number for security purpose. If you use Oracle Linux 7, Centos 7 or Red Hat Linux 7 versions, you can change port number with below operations.

Change the default SSH port

Accepting this value does not make your system insecure, nor will changing the port provide a
significant variance in security. However, changing the default SSH port will stop attacker from making unauthorized access or from many automated attacks and a bit harder to guess on which port SSH is accessible from.

 If selinux is enabled, you have to add new port number to selinux configuration because of the fact that selinux allows only 22 port number for ssh connections.


How to Change SSH Port When Selinux is Enable in Linux



STEP1 : As root user, edit the sshd configuration file using default VI editor.
 # vi /etc/ssh/sshd_config

Port 2290

Save and Exit


STEP 2: Edit the line which states 'Port 22'. 
But before doing so, you must choose an appropriate port and also make sure that it not currently used by any other application on the system.

# What ports, IPs and protocols we listen for

Port 2290

Note: The Internet Assigned Numbers Authority (IANA) is responsible for the global coordination of the DNS Root, IP addressing, and other Internet protocol resources. It is good practice to follow their port assignment guidelines. Having said that, port numbers are divided into three ranges: Well Known Ports, Registered Ports, and Dynamic and/or Private Ports. The Well Known Ports are those from 0 through 1023 and SHOULD NOT be used. Registered Ports are those from 1024 through 49151 should also be avoided too. Dynamic and/or Private Ports are those from 49152 through 65535 and can be used. Though nothing is stopping you from using reserved port numbers, our suggestion may help avoid technical issues with port allocation in the future.


STEP 3 : Change Selinux Configuration

To change:
 # semanage port -a -t ssh_port_t -p tcp 2290


To list using grep:
# semanage port -l | grep ssh


STEP 4: Restart SSHD Service to Activate New Confiuration
 # systemctl restart sshd.service

Switch over to the new port by restarting SSH.

#/etc/init.d/ssh restart


STEP 5: Verify SSH is listening on the new port by connecting to it.
Now connect using new port no 2290.
ssh username@hostname.com -p 2290

Read more ...

ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance

Question: I am getting ORA-32004 error while starting the database but all the parameters in spfile are fine. This issue came after upgrade the database from 10g to 11.2.0.4.0

SQL> startup

ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance


How to fix the ORA-32004 error?


Cause: ORA-32004 causes because one or more obsolete parameters were specified in the SPFILE. These depreciated parameters are still in use by spfile.

Action: See alert log for a list of parameters that are obsolete or deprecated. Remove it from the SPFILE.

You must check alert log to see the names of the parameters that are obsolete.


You can also find the obsolete parameters with this SQL*Plus query:
select name from v$obsolete_parameter where isspecified='TRUE';
                                           OR
select p.name,p.value
from v$parameter p, v$spparameter s
where s.name=p.name
and p.isdeprecated='TRUE'
and s.isspecified='TRUE';

Once found, you must remove it from the spfile or pfile.  You can use alter system command to remove it from spfile.

Read more ...

[A-Z] VI Editor Commands for Editing Files in Linux

For operating systems like Solaris and Linux, you must know some of the basic vi editor commands for the smooth and frequent editing of files. These commands are frequently used in searching patterns within a file, moving arrows up, down, left and right, deleting characters/lines, inserting text etc.

vi editor commands in Linux


vi Editor Commands




Editing and Saving Files


        To create a new file: vi filename
        To exit vi and save changes: [esc][colon] ZZ or wq like Press esc then :wq
        To exit vi without saving changes: :q!
        To saves the current file without quitting: :w
        To enter vi command mode: [esc]
        To enter vi insert mode: Press i



Moving Cursor Within a file


h       move left (backspace)

j       move down

k       move up

l       move right (spacebar)

[return]   move to the beginning of the next line

$       last column on the current line

0       move cursor to the first column on the
current line

^       move cursor to first nonblank column on the
current line

w       move to the beginning of the next word or
punctuation mark

W       move past the next space

b       move to the beginning of the previous word
or punctuation mark

B       move to the beginning of the previous word,
ignores punctuation

        e       end of next word or punctuation mark

        E       end of next word, ignoring punctuation

        H       move cursor to the top of the screen

        M       move cursor to the middle of the screen

        L       move cursor to the bottom of the screen



 Finding Patterns in a File

?       finds a word going backwards

/       finds a word going forwards

        f       finds a character on the line under the
cursor going forward

        F       finds a character on the line under the
cursor going backwards

        t       find a character on the current line going
forward and stop one character before it

T       find a character on the current line going
backward and stop one character before it

; repeat last f, F, t, T



Screen Movement

       G        move to the last line in the file

       xG       move to line x

       z+       move current line to top of screen

       z        move current line to the middle of screen

       z-       move current line to the bottom of screen

       ^F       move forward one screen

       ^B       move backward one line

       ^D       move forward one half screen

       ^U       move backward one half screen

       ^R       redraw screen
( does not work with VT100 type terminals )

       ^L       redraw screen
( does not work with Televideo terminals )

:# move to line #

:$ move to last line of file



Inserting character in a File

       r        replace character under cursor with next
character typed

       R        keep replacing character until [esc] is hit

       i        insert before cursor

       a        append after cursor

       A        append at end of line

       O        open line above cursor and enter append mode



Deleting words and characters within a file

x       delete character under cursor

dd      delete line under cursor

        dw      delete word under cursor

        db      delete word before cursor



Useful Miscellaneous Commands

. repeat last command

u undoes last command issued

U undoes all commands on one line

xp deletes first character and inserts after
second (swap)

J join current line with the next line

^G display current line number

% if at one parenthesis, will jump to its mate

mx mark current line with character x

'x find line marked with character x

NOTE: Marks are internal and not written to the file.

        yy      (yank)'copies' line which may then be put by
the p(put) command. Precede with a count for
multiple lines.



Put Command
        brings back previous deletion or yank of lines,
words, or characters

        P       bring back before cursor

        p       bring back after cursor



Reading Files
copies (reads) filename after cursor in file
currently editing

:r filename



Shell Escape
executes 'cmd' as a shell command.

:!'cmd'

Read more ...

5 Steps to Move Control File from File System to ASM Disk

Moving Control File to ASM



Moving controlfile from filesystem to ASM disk using RMAN in RAC.


You can migrate controlfile from file system to asm disk or to different diskgroup in ASM. For that you have to stop the database and startup in nomount state.


STEP 1: Stop the Database and startup in nomount state
SQL> shutdown immediate;
SQL> startup nomount;


STEP 2:Connect the target database using RMAN
$ rman
RMAN>connect target /
RMAN>restore controlfile to '<DISKGROUP_NAME>' from '<OLD_PATH>';
RMAN> restore controlfile to '+DATA' from '/oradatao1/test11/oradata/san/control01.ctl';

You can also multiplex controlfile to FRA like:
RMAN> restore controlfile to '+FRA' from '/oradatao1/test11/oradata/san/control01.ctl';


STEP 3: Show Location Of New Control Files
ASMCMD> find -t controlfile . *
+DATA/DG/CONTROLFILE/current.321.780791421
+FRA/DG/CONTROLFILE/current.368.870851527


STEP 4: On the database side:
 Modify init.ora or spfile, replacing the new path to the init parameter control_files.
 if using init<SID>.ora, just modify the control_files parameter and restart the database.
 If using spfile, Change Parameter for new locations.
alter system set control_files='+DATA/DG/CONTROLFILE/current.321.780791421','+FRA/DG/CONTROLFILE/current.368.870851527' scope=spfile;


STEP 5: Shutdown the database and open for use
SQL>shutdown immediate
SQL> alter database open;


Verify that new control file has been recognized. If the new controlfile was not used, the complete procedure needs to be repeated.

If you do not use ASM and If you want to new control file in file system, you can copy – paste controlfile to clone after stop database. And you have to change control_files parameter when database is nomount mode or stop.

Read more ...

Top 10 Commands to Check CPU Information on Linux

CPU info includes detailed information about the processor, like it's architecture, vendor name, model, number of cores, speed of each core etc. In Linux, there are many command line or GUI-based tools that can be used to show detailed information about your CPU hardware, however we are exploring some of the best and useful commands using which you can get much more detailed information about Linux CPU.

Get CPU info using /proc/cpuinfo on Linux

Linux /proc/cpuinfo file contains details about individual cpu cores. Proc (/proc) file system provides information about CPU and their speed which is a pseudo-filesystem. It is used as an interface to kernel data structures. It is commonly mounted at /proc. You can use command like more, less or grep to see the contents of this file.

Commands to Get CPU Details on Linux


$ less /proc/cpuinfo
siblings        : 16
core id         : 0
cpu cores       : 8
apicid          : 0
initial apicid  : 0
fpu             : yes
fpu_exception   : yes
cpuid level     : 13
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm dca sse4_1 sse4_2 x2apic popcnt aes xsave avx f16c rdrand lahf_lm ida arat xsaveopt pln pts dts tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms
bogomips        : 5199.62
clflush size    : 64
cache_alignment : 64
address sizes   : 46 bits physical, 48 bits virtual
power management:
processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
................ etc

You can also get details using more and cat command like:
$ more /proc/cpuinfo
$ cat /proc/cpuinfo


To display number of processors in the system
Every processor or core is listed separately and the various details about speed, cache size and model name are included in the description. To count the number of processing units use grep command with wc.
$cat /proc/cpuinfo | grep processor | wc -l
32
$ grep processor /proc/cpuinfo 
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
processor       : 8
........... ...........
processor       : 29
processor       : 30
processor       : 31 

Note: The number of processors shown by /proc/cpuinfo might be different from the actual number of cores on the processor. For example a processor with 2 cores and hyperthreading would be reported as a processor with 4 cores.


To get the actual number of cores, check the core id for unique values
$ cat /proc/cpuinfo | grep 'core id'
$ cat /proc/cpuinfo | grep 'core id'| wc -l
32


lscpu
lscpu is a small and quick command that does not need any options. It would simply print the cpu hardware details in a human readable format.
$ lscpu


To Find CPU vendor 
If you’re interested in just knowing the CPU vendor, go with cat /proc/cpuinfo along with with the grep command.
$ cat /proc/cpuinfo | grep vendor | uniq
vendor_id       : GenuineIntel


To Find Model Name
$ cat /proc/cpuinfo | grep 'model name' | uniq
model name      : Intel(R) Xeon(R) CPU E5-2650 v2 @ 2.60GHz


Hardinfo 
Hardinfo is a gtk based gui utility that generates reports about various hardware components including memory, storage, PCI devices, storage, USB devices etc plus information on the OS, kernel, and networking. But it can also run from the command line only if there is no gui display available.

To install hardinfo
If hardinfo is not installed on your Linux box, you can do so with the following command on your Ubuntu system.
$ sudo apt-get install hardinfo
Let's Look into this command
$ hardinfo | less
It would produce a large report about many hardware parts, by reading files from the /proc directory. The cpu information is towards the beginning of the report. The report can also be written to a text file. Hardinfo also performs a few benchmark tests taking a few minutes before the report is displayed.


To find the number of processing units available
 The nproc command just prints out the number of processing units available. Note that the number of processing units might not always be the same as number of cores.
$ nproc
4


To Display name of the Operating System.
$ uname -a
Linux 2.6.39-400.215.10.el5uek #1 SMP Tue Sep 10 22:51:46 PDT 2014 x86_64 x86_64 x86_64 GNU/Linux


Inxi
 One of my all time favorite command line tools and I have it running on all my Linux systems. This is an excellent script that provides information in an easy to understand format.

To install Inix on Ubuntu
$ sudo apt-get install inxi

To install Inix on CentOS/Fedora
$ sudo yum install inxi

Print out cpu/processor related information 
$ inxi -C


dmidecode
The dmidecode command displays some information about the cpu, which includes the socket type, vendor name and various flags. Following command with type id 4 will get the information about CPU of the system.
# dmidecode -t 4
# dmidecode 2.9
$sudo demidecode -t processor
$ sudo dmidecode -t 4
Get BIOS information using dmidecode
# dmidecode -t bios
# dmidecode 2.9
View Manufacturer, Model and Serial number of the equipment using dmidecode
# dmidecode -t system
# dmidecode 2.9


cpuid
The cpuid command fetches CPUID information about Intel and AMD x86 processors.

This program can be installed with apt on ubuntu
$ sudo apt-get install cpuid

To install cpuid on Fedora and CentOS distributions.
$ sudo yum install cpuid

And here is sample output
$ cpuid

Run the command with less to get a readable output.
$ cpuid | less


You can also do R&D with grep command to find more cpu info in Linux/Unix. From the readers, your comment is valuable to us. Please share if you have more valuable commands to get more detailed output.


Other similar sources:

nixCraft: Number of CPUs and Their Speed
redhax: /proc/cpuinfo.html
linuxquestions.org
Read more ...

ORA-27211: Failed to load Media Management Library

RMAN backup failed With below error:

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of allocate command on ch1 channel at 06/20/2015 09:17:05
ORA-19554: error allocating device, device type: SBT_TAPE, device name:
ORA-27211: Failed to load Media Management Library
Additional information: 4005


How to fix ORA-19554 and ORA-27211 errors?


CAUSE:

Before using RMAN with a media manager, media management software must be installed and configured on the target host or production network.

When allocating or configuring channels for RMAN to use to communicate with a media manager, specify the SBT_LIBRARY parameter to provide the path to the media management software library. When RMAN allocates channels to communicate with a media manager, it attempts to load the library indicated by the SBT_LIBRARY parameter.

If you do not provide a value for this parameter, RMAN looks in a platform-specific default location. On Linux/UNIX, the default library filename is $ORACLE_HOME/lib/libobk.so, with the extension name varying according to platform: .so, .sl, .a, and so on. On Windows the default library location is %ORACLE_HOME%\bin\orasbt.dll.

If the database is unable to locate a media management library in the location specified by the SBT_LIBRARY parameter or the default location, then RMAN issues an ORA-27211 error and exits.


Resolving "Failed to load Media Management Library" Issue

Link libobk.so to your backup vendor supplied rman library using symbolic link.

Go to <ORACLE_HOME/lib/> directory.

$ pwd
/ora/app/oracle12c/product/12.1.0.2/dbhome_1/lib
$ cd  /usr/openv/netbackup/bin
$ ls -ltr libobk.so64
-r-xr-xr-x 1 root bin 1567895 Jun  20  2015 libobk.so64

$ cd /ora/app/oracle12c/product/12.1.0.2/dbhome_1/lib
$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.so
$ ls -ltr libobk.so
lrwxrwxrwx 1 oracle dba 36 Jun 20 09:27 libobk.so -> /usr/openv/netbackup/bin/libobk.so64

Now start backup, if it gets completed successfully then no issues, if fail again then create below link in the same location as above.

$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.a
$ ln -s /usr/openv/netbackup/bin/libobk.so64 libobk.so64
$ ls -lrt libobk*
lrwxrwxrwx 1 oracle dba 36 Jun 20 09:45 libobk.so -> /usr/openv/netbackup/bin/libobk.so64
lrwxrwxrwx 1 oracle dba 36 Jun 20 10:00 libobk.a -> /usr/openv/netbackup/bin/libobk.so64
lrwxrwxrwx 1 oracle dba 36 Jun 20 10:00 libobk.so64 -> /usr/openv/netbackup/bin/libobk.so64


For "ORA-19554: error allocating device, device type: SBT_TAPE" 
and "ORA-27211: Failed to load Media Management Library" you can get more info at: Backup and Recovery

Read more ...

Resolving ORA-19588: archived log recid stamp is no longer valid

ORA-19588: archived log recid 14859 stamp 747949646 is no longer valid

channel dev_0: starting archive log backupset
released channel: dev_0
RMAN-00571: ===============================================
RMAN-00569: ============ ERROR MESSAGE STACK FOLLOWS =====
RMAN-00571: ===============================================
RMAN-03009: failure of backup command on dev_0 channel at 05/20/2015 07:22:55
ORA-19588: archived log recid 14859 stamp 747949646 is no longer valid



ORA-19588: archived log stamp is not longer valid


There are few possible causes for ORA-19588

-----------------------------------------------------------------------
  • Archive logfile which this process is trying to take backup, is already been backed up by another process and file is deleted.
  • Invalid or deleted records in the controlfile. 


This situation occur if both archive backup job and full database backup (including archives) are executing at the same time or two archive backup jobs executing at same time.


Look at the below command
---------------------------------------
RMAN> backup archivelog all archivelog until time 'sysdate -1' delete input ; 
             
The backup command being used is correct by 'syntax', however incorrect by 'logic' because RMAN will try to backup some archivelogs (archivelogs which completed till 'sysdate-1')  twice in the same command:

Here both jobs are trying to backup and delete the SAME archivelog set, one of which failed eventually as the other job had already backed up and deleted the log.

If we don't specify 'DELETE INPUT', the command will be succeeded, however, backup twice (ful archivelog and completed one day before) doesn't seem to be the intention of above command.


SOLUTION
-----------------------
Run the below command to synchronize the controlfile with the current status of the backup-related information.
RMAN> crosscheck archivelog all;


No concurrent RMAN backups
-----------------------------------------
Make sure that concurrent backups of the archivelogs of the SAME database are not run. You can find it using the below command.
$ ps -ef | grep rman

Don’t schedule archive backup job during full database backup (including archivelog). Always make sure you have only one RMAN backup in process.


Useful Commands

If we want to take backup of all archivelogs, then:
------------------------------------------------------------------
RMAN> backup archivelog all delete input ;


If we want to take backup of all archivelogs until time 'sysdate -1', then:
--------------------------------------------------------------------------------------------
RMAN> backup archivelog until time 'sysdate -1' delete input ;


Note
ORA-19588 may be seen with 'datafile copy' as well
like:
.
RMAN-03009: failure of backup command on ch01 channel at 02/01/2013 21:30:59
ORA-19588: datafile copy RECID 1019958 STAMP 806188828 is no longer valid
Read more ...

35 Practical Find Command Examples in Linux

Find Command is one of the powerful Unix / Linux utility used for searching the files in a directory hierarchy from the command line. It can be used to find files based on various search criteria like permissions, user ownership, modification date/time, size etc.
In this post we shall learn to use the find command along with various options that it supports.


Find Command Best Examples


The basic syntax syntax of find command is:
find [pathnames] [conditions]


You have several options for matching criteria:

-atime n : File was accessed n days ago
-mtime n : File was modified n days ago
-size n : File is n in size (a block is 512 bytes)
-type c : Specifies file type: f=text file, d=directory
-fstype : Specifies file system type example nfs
-name : Name of the filen you want to search
-user : Specifies file's owner
-group : Specifies file's group owner
-perm p : File's access mode

Some examples based on the above criteria:

-mtime +7 : Matches files modified more than seven days ago.
-atime -2 : Matches files accessed less than two days ago
-size +100 : Matches files larger than 100 blocks (50KB)
-mmin -60 : find all the files which are modified in last 1 hour
-cmin -60 : find all the files which are changed in last 1 hour


Most Frequently Used Find Command Examples in Linux



Find Files Under Home Directory
Find all the files under /home directory with name foo.txt.
# find /home -name foo.txt
/home/foo.txt


Find Files Using Name in Current Directory
Find all the files whose name is foo.txt in a current working directory.
# find . -name foo.txt
./foo.txt


Find files starting from the root directory
# find / -name passwd
This command will find passwd file under all sub-directories starting from root directory.


Find Files Using Name and Ignoring Case
Find all the files whose name is ora.txt and contains both capital and small letters in /home directory.
# find /home -iname Foo.txt
./Foo.txt
./Foo.txt


Find and remove single File
To find a single file called ora.txt and remove it.
# find . -type f -name "ora.txt" -exec rm -f {} \;


Find and remove Multiple File with same extension
To find and delete all files of a specific extension such as .txt, .gz use.
# find . -type f -name "*.txt" -exec rm -f {} \; 


Find Directories Using Name
Find all directories whose name is foo in / directory.
# find / -type d -name foo
/foo


Find hidden files
Hidden files on linux begin with a period (.).  list all hidden files. This command will list all hidden files in the specific directory like temp etc.
# find /tmp -type f -name ".*"
# find ~ -type f -name ".*"
Note: Use proper directory path.


Finding top 10 largest files in Linux
The following command will display the top 10 biggest file in the current directory and its subdirectory. This may take a while to execute depending on the total number of files and size of the files.
# find . -type f -exec ls -s {} \; | sort -n -r | head -10 


Finding the Top 10 Small Files
The following command will display the top 10 smaller file in the current directory and its subdirectory. but the only difference the sort is ascending order.
# find . -type f -exec ls -s {} \; | sort -n -r | head -5 

In the above command, you will see ZERO byte files also ( empty files ). So,  you can use the following command to list the smaller files other than the ZERO byte.
# find . -not -empty -type f -exec ls -s {} \; | sort -n  | head -5 


Finding Files based on Modification and accessed time


Find files modified 20 days back
To find all the files which are modified 20 days back.
# find / -mtime 20


Find files accessed in last 20 days
Find all files that were accessed in the last 20 days.
# find / -atime 20


Find files modified in a range of days
Find all files that were modified between 50 to 100 days ago.
# find / -mtime +50 –mtime -100 


Find Changed Files in Last 1 Hour
To find all the files which are changed in last 1 hour.
# find / -cmin -60


Find Modified Files in Last 1 Hour
To find all the files which are modified in last 1 hour.
# find / -mmin -60 


Find Accessed Files in Last 1 Hour
To find all the files which are accessed in last 1 hour.
# find / -amin -60 


Finding Files based on Size
Using the -size option you can find files by size.


Find files bigger than 100M
# find ~ -size +100M 


Find files smaller than 100M
# find ~ -size -100M 


Find 50MB Files
To find all files matches the exact given size i.e, 50M
# find / -size 50M 


Find Size between 50MB – 100MB
To find all the files which are greater than 50MB and less than 100MB.
# find / -size +50M -size -100M 


Find and Delete 100MB Files
To find all 100MB files and delete them using one single command.
# find / -size +100M -exec rm -rf {} \; 


Find Files and Directories based on type using option -type


Find only the normal files
# find . -type f 


Find all directories
# find . -type d 


Find only the socket files.
# find . -type s 


Find all the hidden files
# find . -type f -name ".*" 


Find all the hidden directories
# find -type d -name ".*" 


Find Specific Files and Delete
Find all .mp3 files with more than 10MB and delete them using one single command.
# find / -type f -name *.mp3 -size +10M -exec rm {} \; 


Find all Empty Directories
To file all empty directories under specific path.
# find /tmp -type d -empty 


Finding Files based on Permissions

Find Files having 777 Permissions
Find all the files whose permissions are 777
# find . -type f -perm 0777 -print 


Find Files Without 777 Permissions
Find all the files without permission 777.
# find / -type f ! -perm 777 


Find SGID Files with 644 Permissions
Find all the SGID bit files whose permissions set to 644.
# find / -perm 2644 


Find Sticky Bit Files with 551 Permissions
Find all the Sticky Bit set files whose permission are 551.
# find / -perm 1551 


Find SUID Files
Find all SUID set files.
# find / -perm /u=s 


Find SGID Files
Find all SGID set files.
# find / -perm /g+s 


Find Read Only Files
Find all Read Only files.
# find / -perm /u=r 


Find Executable Files
Find all Executable files.
# find / -perm /a=x 


Find Files with 777 Permissions and Chmod to 644
Find all 777 permission files and use chmod command to set permissions to 644.
# find / -type f -perm 0777 -print -exec chmod 644 {} \; 


Find Directories with 777 Permissions and Chmod to 755
Find all 777 permission directories and use chmod command to set permissions to 755.
# find / -type d -perm 777 -print -exec chmod 755 {} \;
Read more ...

Top 20 Practical Examples of RPM Commands in Linux

RPM is a default open source package management utility for installing, updating, uninstalling, querying and verifying software packages on Linux based operating systems.  RPM stands for Red Hat Package Manager which keeps the information of all the installed packages under /var/lib/rpm database.  It is mostly used in  RHEL, CentOS and Fedora.

Best Practical Examples of RPM Commands in Linux

RPM has five basic modes of operation which includes:


Install: It is used to install RPM package.
Uninstall:  It is used to remove or uninstall RPM package.
Upgrade: It is used to update the existing RPM package.
Verify: It is used to query about different RPM packages.
Query: It is used for the verification of any RPM package.


 Each software package consists of an archive of files along with information about the package like its name, version, and a description,

Sources From Where you can find and download RPM packages
Below are the list of sites where you can find and download all RPM packages.

http://www.rpmfind.net/
www.redhat.com/
http://freshrpms.net/ 
http://rpm.pbone.net/

1. To install a RPM package, use the following command:

# rpm -ivh foo-1.0-2.i386.rpm

Preparing...           ############################## [100%]

   1:foo               ############################## [100%]

Structure of the package includes the following:

  • File of names like foo-1.0-2.i386.rpm
  • Package name - foo
  • Version - 1.0 
  • Release - 2  
  • Architecture - i386

2. To remove an installed RPM package, use RPM with -e option
After uninstallation, you can query using rpm -qa to verify the uninstallation
# rpm -ev foo
 
Notice that we used the package name “foo”, not the name of the original package file “foo-
1.0-2.i386.rpm”.


3. To query a particular RPM package, use this command with -q option
This command will print the package name, version, and release number of the installed package foo. Use this command to verify that a package is or is not installed on your system.
# rpm -q foo
foo-2.3-8


To Query all RPM packages using rpm -qa
# rpm -qa
This command will list all the installed packages on your system. To filter particular package you can combine this with grep command.
# rpm -qa | grep BitTorrent


4. To upgrade a RPM package, use with -Uvh option
With this command, RPM automatically uninstalls the old version of installed package for example  foo and installs the new version. Always use rpm -Uvh to install packages, since it works fine even when there are no previous versions of the package installed.
# rpm -Uvh foo-1.0-2.i386.rpm
foo ##################################################


5. To display package information, use the command
This command displays package information; includes name, version and description of the
installed program. Use this command to get information about the installed package.
# rpm -qi foo
Name : foo Relocations: none
Version : 2.3 Vendor: OpenNA.com, Inc.
Release : 8 Build Date: Thu 24 Aug 2000 11:16:53 AM EDT
Install date: Mon 12 Feb 2001 01:17:24 AM EST Build Host: openna.com
Group : Applications/Archiving Source RPM: foo-2.3-8.src.rpm
Size : 271467 License: distributable
Packager : OpenNA.com, Inc. <http://www.openna.com/>
Summary : Here will appears summary of the package.
Description : Here will appears the description of the package.


6. To display package information before installing the program
This command displays package information before installing on your system which includes name, version, and description of the program. Use this command to get information about a package before you install it on your system. For example, the following option -qip (query info package) will print the information of a package.
# rpm -qpi foo-2.3-8.i386.rpm
Name : foo Relocations: none
Version : 2.3 Vendor: OpenNA.com, Inc.
Release : 8 Build Date: Thu 24 Aug 2000 11:16:53 AM EDT
Install date: Mon 12 Feb 2001 01:17:24 AM EST Build Host: openna.com
Group : Applications/Archiving Source RPM: foo-2.3-8.src.rpm
Size : 271467 License: distributable
Packager : OpenNA.com, Inc. <http://www.openna.com/>
Summary : Here will appears summary of the package.
Description : Here will appears the description of the package.


7. To check dependencies of RPM Package before Installation
To view the list of packages on which this package depends you can use rpm -qpR command. This command will display the list of all packages on which installing package depends before installing or upgrading a package. This is the best way to do a dependency check before installing or upgrading a package.
# rpm -qpR <package_name>
# rpm -qpR BitTorrent-5.2.2-1-Python2.4.noarch.rpm

/usr/bin/python2.4
python >= 2.3
python(abi) = 2.4
python-crypto >= 2.0
python-psyco
python-twisted >= 2.0
python-zopeinterface
rpmlib(CompressedFileNames) = 2.6
RPM command and options
-q : Query a package
-p : List capabilities this package provides.
-R: List capabilities on which this package depends.


8. To list files in a installed RPM package, use the command
This command will list all files in a installed RPM package. It works only when the package is
already installed on your system.
# rpm -ql foo
/usr/bin/foo
/usr/bin/foo1
/usr/sbin/foo2


9.  To Query documentation of Installed RPM Package
To get the list of available documentation of an installed package, use the following command with option -qdf (query document file). This command will display the location of all manual pages related to package. Here, for example vmstat.
# rpm -qdf /usr/bin/vmstat

/usr/share/doc/procps-3.2.8/BUGS
/usr/share/doc/procps-3.2.8/COPYING
/usr/share/doc/procps-3.2.8/COPYING.LIB
/usr/share/doc/procps-3.2.8/FAQ
/usr/share/doc/procps-3.2.8/NEWS
/usr/share/doc/procps-3.2.8/TODO


10. To list files in package that is not already installed, use the command
This command will list all files in a RPM package that is not already installed on your system. It is useful when you want to know which components are included in the package before installing it.
# rpm -qpl foo
/usr/lib/foo
/usr/bin/foo1
/usr/sbin/foo2


11. To know which files is part of which package, use the command
# rpm -qf /etc/passwd
setup-2.3.4-1
This command will show you from which RPM package the file comes from. It works only when the package is already installed on your system and it is very useful when you see some files into Linux that you do not and want to get detailed information about it.


12. To check a RPM signature package, use the command
# rpm --checksig foo

  • This command checks the PGP signature of specified package to ensure its integrity and origin.
  • Always use this command first before installing new RPM package on your system.
  • GnuPG or PGPsoftware must be already installed on your system before you can use this command.



13. To examine only the md5sum of the package, use the command
# rpm --checksig --nogpg foo


14. To Rebuild corrupted RPM database
Sometimes RPM database gets corrupted, in that situation you need to rebuild corrupted RPM database. In order to recover from a corrupted RPM database you can use the following command:
First of all remove /var/lib/rpm/__db* files to avoid stale locks and then rebuild rpm using below command:
# cd /var/lib
# rm __db*

Rebuild RPM database:
# rpm --rebuilddb
# rpmdb_verify Packages


15. How to List Recently Installed RPM Packages
Use the following rpm command with -qa (query all) option, this will list all the recently installed rpm packages on your system.
# rpm -qa --last
Some Facts about RPM (RedHat Package Manager) RPM is free and released under GPL (General Public License). RPM keeps the information of all the installed packages under /var/lib/rpm database. RPM is the only way to install packages under Linux systems, if you’ve installed packages using source code, then rpm won’t manage it. RPM deals with .rpm files, which contains the actual information about the packages such as: what it is, from where it comes, dependencies info, version info etc.


16. How to List all Imported RPM GPG keys
To print all the imported GPG keys in your system, use the following command.
# rpm -qa gpg-pubkey 
gpg-pubkey-58f96f56-467e919a
gpg-pubkey-6b8d79e6-3f49413d
gpg-pubkey-849c449f-4cb9ff31
gpg-pubkey-5680b795-4bd22941
 gpg-pubkey-7fac5991-461576f7
 gpg-pubkey-0f2672c8-4cd925ee
gpg-pubkey-c106b9de-4e0fd3a3


17. How to Import an RPM GPG key
To verify RHEL/CentOS/Fedora packages, you must import the GPG key. To do so, execute the following command. It will import CentOS 6 GPG key. 
# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

Additional resources to learn more about rpm.
rpm --help : This command displays a quick reference of RPM parameters.
man rpm : The RPM man page gives more detail about RPM parameters than the rpm --help command.

Useful Websites
The RPM website — http://www.rpm.org/

Read more ...

Top 10 Ways to Get Current Date and Time in Oracle DB

To get the current date and time on the Database Server Oracle has SYSDATE internal value which returns the current date from the operating system on which the database resides. The datatype of the returned value is DATE, and the format returned depends on the value of the NLS_DATE_FORMAT initialization parameter.


Current date and time in Oracle DB


Examples to get the Current Date and Time


SQL> select sysdate from dual;
SYSDATE
---------
18-MAY-15 
The default format that the Oracle database uses is: DD-Mon-YY

SQL> SELECT TO_CHAR
(SYSDATE, 'MM-DD-YYYY HH24:MI:SS') "TODAY"
FROM DUAL; 
TODAY
-------------------
05-18-2015 01:34:25


To get the server TimeZone

SQL> SELECT sessiontimezone FROM dual;

SESSIONTIMEZONE
------------------------------------
+05:30

This will give you the system timezone in this format, Ex: Asia/Calcutta


To get the server time

SQL> SELECT systimestamp FROM dual;

SYSTIMESTAMP
----------------------------------------------------
18-MAY-15 01.42.27.939642 AM -04:00


To Change nls_date_format

ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY MM DD';
select sysdate from dual;

ALTER SESSION SET NLS_DATE_FORMAT = 'HH24:MI:SS';
select sysdate from dual;


 Get Time using the format mask

SQL> select TO_CHAR(sysdate, 'MM/DD/YYYY') TODAY from dual;
TODAY
----------
05/18/2015

SQL> select TO_CHAR(sysdate, 'HH24:MI:SS') TODAY from dual;
TODAY
--------
01:47:22

SQL> select TO_CHAR(sysdate, 'YYYY-MM-DD') TODAY from dual;
TODAY
----------
2015-05-18


Date is stored in the database as a number, you can perform calculations on it.


SQL>  SELECT
     SYSDATE Today,
      SYSDATE + 1 Tomorrow,
     SYSDATE - 1 Yesterday
     from dual;

TODAY        TOMORROW     YESTERDAY
-------------------------------------------------------------
18-MAY-15    19-MAY-15       17-MAY-15


Above given examples are very useful to find the current date and time from sql prompt of Oracle database. If you have more interesting examples, you can share with us.


Read more ...

How to Kill All Sessions of a Specific User in Oracle

Any time request may come like "Can you please kill all the sessions that is on ORAHOW database for user name Tiwary. Killing sessions can be very destructive if you kill the wrong session, so be very careful when identifying the session to be killed. If you kill a session belonging to a background process you will cause an instance crash.

Before killing session gather session information for that user from Oracle.

  • Before killing check which sql being executed by that user.
  • Check for any blocking locks, long running query etc.
  • Find inst_id, sid, serial#, machine, sql_id for that user.


To Find inst_id, sid, serial# for a user
select inst_id, sid, serial#, machine, username status, sql_id from gv$session where username='Tiwary';


To get more detailed information for a particular user
set lines 1234 pages 9999
 col inst_id for a10
col serial# for a10
 col machine for a30
col username for a10
col event for a20
col blocking_session for 999999
col blocking_instance for 999999
 col status for a10
 col INST_ID for 9999
 col SERIAL# for 999999

select inst_id,sid,serial#,machine,username,event,blocking_session,blocking_instance,status,sql_id from gv$session where username='TIWARY';


In RAC @ sign is now required to kill a session or when using an inst_id.
SQL>  alter system kill session '125,640,1';
 alter system kill session '125,640,1'
*
ERROR at line 1:
ORA-00026: missing or invalid session ID

After specifying @inst_id, it works

alter system kill session '125,640,@1';

System altered.

NOTE: If you don't want to put inst_id, then goto the instance from where user is connected and then kill it.


Best way to kill a session is using ALTER SYSTEM DISCONNECT SESSION command.
ALTER SYSTEM DISCONNECT SESSION 'SID,SERIAL#' immediate;
ALTER SYSTEM DISCONNECT SESSION '125,640'immediate;


Finally check once to verify it.
select inst_id, sid, serial#, machine, username status, sql_id from gv$session where username='Tiwary';

no rows selected


Finally we have killed all the sessions for a special user connected to the oracle database. Now there is no active sessions for that user.
Read more ...

ORA-00245: Control File Backup Failed; Target is Likely on a Local File System

In alert log I got an issue ORA-00245: control file backup failed; target is likely on a local file system. Regarding this issue, I checked the snapshot control file location on rman prompt and observed that it was on local file system. In RAC environment, Snapshot control file backup location should be on a shared disk group so that it can be visible or accessible to all RAC nodes.


Check the configured snapshot controlfile default location.


RMAN> show snapshot controlfile name;

starting full resync of recovery catalog
full resync complete
RMAN configuration parameters for database with db_unique_name ORAHOW are:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0.4/dbhome_1/dbs/snapcf_ORAHOW2.f'; # default

Here you can see that controlfile is on a local file system, so to fix this issue configure it to a shared location.

To Configure the snapshot controlfile to a shared disk

Connect to target database, and issue the following command on RMAN prompt.
rman target /

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '<shared_disk>/snapcf_<DBNAME>.f';

Let us take an example,

RMAN> CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+RC_DATA/ORAHOW/snapcf_orahow.f';

new RMAN configuration parameters:
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '+RC_DATA/ORAHOW/snapcf_orahow.f';
new RMAN configuration parameters are successfully stored
starting full resync of recovery catalog
full resync complete


Due to the changes made to the controlfile backup mechanism any instances in the cluster may write to the backup controlfile when making changes to the current controlfile. Therefore, the backup file needs to be visible to all instances.


Read more ...

4 Best Ways to Find Blocking Sessions in Oracle 11g

Blocking sessions occur when one sessions holds an exclusive lock on an object and doesn't release it before another sessions wants to update the same data. This will block the second until the first one has done its work. It mainly happens when a session issues an insert, update or delete command that changes a row. When the change occurs, the row is locked until the session either commits the change or rolls the change back.

When a DML is executed (update/delete/insert,merge, and select .... for update) oracle obtains 2 locks on the table. Row level Lock (TX) - This obtains a lock on the particular row being modified and any other transaction attempting to modify the same row gets blocked, till the one already owning it finishes. Table Level Lock (TM) - When Row lock (TX) is obtained an additional Table lock is also obtained to prevent any DDL operations to occur while a DML is in progress. Example: to avoid truncate and alter operation during table modification.

User can modify different rows of the table at the same time but cannot modify the same row at the same time. During row revel lock oracle acquire lock mode 3. Parallel DML operations and serial insert using direct load operations take exclusive table locks with lock mode 6. Below lock mode 6 lock the whole table and during this lock user even can't modify the rows. This will result in library cache lock. So lock mode 3 is common but avoid using hints during insert because it will lock the whole table.

6   Exclusive (X)              Lock table in exclusive mode
                                         create index    -- duration and timing depend on options used
                                          insert /*+ append */



From the view of the user it will look like the application completely hangs while waiting for the first session to release its lock. You'll often have to identify these sessions in order to improve your application to avoid as many blocking locks as possible.


.You can see where problems might occur, for example a user might make a change and then forget to commit it and leaves for the weekend without logging off the system.


Oracle provide views like, DBA_BLOCKERS and V$LOCK using which we can easily find the blocking locks. Here, we will try to find blocking locks using V$LOCK view which is faster to query and makes it easy to identify the blocking session.

SQL> select * from v$lock ;

ADDR     KADDR           SID TY        ID1        ID2      LMODE    REQUEST    CTIME      BLOCK
-------- -------- ---------- -- ---------- ---------- ---------- ---------- ---------- -------------------------------------
AF8E2C4C AF9E2C50      419 TX     141028      15289      0              6                    675          0
ADDF7EC8 ADDF8EE0    542 TM    77529          0            3              0                    687          0
ADDF7F74 ADDF7F8C     419 TM    77529          0            3              0                    675          0
ADEBEA20 ADEBEB4C   542 TX     141028     152899     6             0                    687          1


Here we are interested in the BLOCK column. If a session holds a lock that's blocking another session, BLOCK=1. Further, you can tell which session is being blocked by comparing the values in ID1 and ID2. The blocked session will have the same values in ID1 and ID2 as the blocking session, and, since it is requesting a lock it's unable to get, it will have REQUEST > 0.

In the query above, we can see that SID 542 is blocking SID 419. SID 542 corresponds to Session 1 in our example, and SID 419 is our blocked Session 2. To avoid having to stare at the table and cross-compare ID1's and ID2's, put this in a query:

 Query to find Blocking sessions using v$lock
SQL> select l1.inst_id,l1.sid, ' IS BLOCKING ', l2.sid,l1.type,l2.type,l1.lmode,l2.lmode,l2.inst_id
from gv$lock l1, gv$lock l2
where l1.block =1 and l2.request > 0
and l1.id1=l2.id1
and l1.id2=l2.id2;


To Get Detailed information on blocking locks
SQL> SELECT 'Instance '||s1.INST_ID||' '|| s1.username || '@' || s1.machine
   || ' ( SID=' || s1.sid || ','|| s1.serial#||s1.status||  '  )  is blocking '
   || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' ||s2.sql_id
    FROM gv$lock l1, gv$session s1, gv$lock l2, gv$session s2
   WHERE s1.sid=l1.sid AND
    s1.inst_id=l1.inst_id AND
    s2.sid=l2.sid AND
    s2.inst_id=l2.inst_id AND
    l1.BLOCK=1 AND
   l2.request > 0 AND
   l1.id1 = l2.id1 AND
   l2.id2 = l2.id2 ;


Finding blocking sessions with v$session
set lines 1234 pages 9999
col inst_id for a10
col serial# for a10
col machine for a30
col username for a10
col event for a20
col blocking_session for 999999
col blocking_instance for 999999
col status for a10
col INST_ID for 9999
col SERIAL# for 999999

SQL> select inst_id,sid,serial#, machine, username, event, blocking_session, blocking_instance, status, sql_id from gv$session where status ='ACTIVE'and username is not null;

Finding SQL_ID from SID using v$session

SQL> select sql_id from v$session where sid=4120;

SQL_ID
-------------


SQL> select sql_fulltext from v$sql where sql_id ='xxxxx';


Killing Oracle Sessions
Be very careful when identifying the session to be killed. If you kill a session belonging to a background process you will cause an instance crash.

There are a number of ways to kill blocking sessions both from Oracle sql prompt and externally.

Identify the Session to be Killed
ALTER SYSTEM KILL SESSION
ALTER SYSTEM DISCONNECT SESSION
The Windows Approach
The UNIX Approach

SQL> ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE;
This does not affect the work performed by the command, but it returns control back to the current session immediately, rather than waiting for confirmation of the kill.

In a RAC environment, you optionally specify the INST_ID, shown when querying the GV$SESSION view. This allows you to kill a session on different RAC node.

SQL> ALTER SYSTEM KILL SESSION 'sid,serial#,@inst_id';

SQL> ALTER SYSTEM DISCONNECT SESSION 'SID,SERIAL#' IMMEDIATE;

The DISCONNECT SESSION command kills the dedicated server process, which is equivalent to killing the server process from the operating system

kill -9 spid

 To identifying blocked objects

The view v$lock we've already used in the queries above exposes even more information. There are differnet kind of locks - check this site for a complete list: http://download.oracle.com/docs/cd/B13789_01/server.101/b10755/dynviews_1123.htm#sthref3198

If you encounter a TM lock is means that two sessions are trying to modify some data but blocking each other. Unless one sessions finished (commit or rollback), you'll never have to wait forever.

The following queries shows you all the TM locks:

SELECT sid, id1 FROM v$lock WHERE TYPE='TM'
SID ID1
92 20127
51 20127

The ID you get from this query refers to the actual database object which can help you to identify the problem, look at the next query:

SELECT object_name FROM dba_objects WHERE object_id=20127

These queries should help you to identify the cause of your blocking sessions!

Read more ...

HTTP Listener Failed at Startup Possible Port Conflict on Port

Few days back I got an alert: Agent is Not Running. Possible port conflict on port(3872): Retrying the operation. Failed to start the agent after 1 attempts. Please check that the port(3872) is available.



Regarding this first check the status of the agent after that we will look into it.
[oracle@orahowracq1] cd /u01/app/oracle/product/12.1.0.2/agent/agent_inst/bin
[oracle@orahowracq1] ./emctl status agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
---------------------------------------------------------------
Status agent Failure:unable to connect to http server at https://orahowracq1.hiw.com:3872/emd/lifecycle/main/. [peer not authenticated]
Agent is Not Running


Above we can see that agent is not running, so first try to start the agent normally as usually you do.
[oracle@orahowracq1] ./emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
Starting agent ................ failed.
HTTP Listener failed at Startup
Possible port conflict on port(3872): Retrying the operation...
Failed to start the agent after 1 attempts.  Please check that the port(3872) is available.
Consult emctl.log and emagent.nohup in: /u01/app/oracle/product/12.1.0.2/agent/agent_inst/sysman/log


During startup we get an error port conflict. Now you can check which process is listening to this port using simple combination of netstat with grep command.
[oracle@orahowracq1] netstat -anp |grep 3872 


Now find the PID of this process. So that we can mark it for kill.
[oracle@orahowracq1] ps -ef|grep agent

    root  6535     1   0   Jun 17 ?      0:02 /opt/opsware/agent/bin/python /opt/opsware/agent/pylibs/shadowbot/daemonbot.pyc
    root  3804     1   0   Jun 17 ?      206:39 /opt/VRTSobc/pal33/bin/vxpal -a actionagent -x
    root  6549  6535   0   Jun 17 ?      178:38 /opt/opsware/agent/bin/python /opt/opsware/agent/pylibs/shadowbot/daemonbot.pyc
    root  9184     1   0   Jun 17 ?      71:57 /opt/Navisphere/bin/naviagent -f /etc/Navisphere/agent.config
    root  8482  8071   0   Jun 17 ?      114:20 /opt/ecc/exec/mstragent -s
  oracle  15627 15547   0   Mar 13 ?      111:40 /u01/app/oracle/product/12.1.0.2/agent/core/12.1.0.2.0/jdk/bin/sparcv9/java -Xm
  oracle 24178  6501   0 23:22:46 pts/1  0:00 grep agent
  oracle 15547     1   0   Mar 13 ?      0:27 /u01/app/oracle/product/12.1.0.2/agent/core/12.1.0.2.0/perl/bin/perl


Make sure that process must be in: /u01/app/oracle/product/12.1.0.2/agent/core/12.1.0.2.0/jdk/bin/sparcv9/java. Finally kill the process having PID 15627 and start up the agent.

[oracle@orahowracq1] kill -9 15627
[oracle@orahowracq1] cd /u01/app/oracle/product/us/agent12c/bin
[oracle@orahowracq1] ./emctl start agent
[oracle@orahowracq1] ./emctl status agent
[oracle@orahowracq1] ./emctl clearstate agent
[oracle@orahowracq1] ./emctl upload 

Example:

./emctl start agent
Oracle Enterprise Manager Cloud Control 12c Release 2
Copyright (c) 1996, 2012 Oracle Corporation.  All rights reserved.
Starting agent ....... failed.
HTTP Listener failed at Startup
Possible port conflict on port(3872): Retrying the operation...
Failed to start the agent after 1 attempts.  Please check that the port(3872) is available.
Consult emctl.log and emagent.nohup in: /oradba/oemagent/product/12.1.0.2/agent/agent_inst/sysman/log

[oracle@orahowracq1] netstat -anp |grep 3872 
tcp   0      0 :::3872         :::*          LISTEN      7507/java

[oracle@orahowracq1 bin]$ ps -ef|grep agent

oracle    7507  7314  1 Apr14 ?        03:10:55 /oradba/oemagent/product/12.1.0.2/agent/core/12.1.0.2.0/jdk/bin/java -Xmx128M -XX:MaxPermSize=96M

[oracle@orahowracq1] kill -9 7507

Read more ...

CONTACT

Name

Email *

Message *