Search Articles

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 ...

CONTACT

Name

Email *

Message *