25 April 2014

RPM command with examples

RPM (Red Hat Package Manager) command is used for installing, uninstalling, upgrading, querying, listing, and checking RPM packages on your Linux system.
With root privilege, you can use the rpm command with appropriate options to manage the RPM software packages.


Let us take an rpm of Mysql Client and run through all our examples.

1. Installing a RPM package Using rpm -ivh

RPM file name has package name, version, release and architecture name.
For example, In the MySQL-client-3.23.57-1.i386.rpm file:
  • MySQL-client – Package Name
  • 3.23.57 – Version
  • 1 – Release
  • i386 – Architecture
When you install a RPM, it checks whether your system is suitable for the software the RPM package contains, figures out where to install the files located inside the rpm package, installs them on your system, and adds that piece of software into its database of installed RPM packages.
The following rpm command installs Mysql client package.
# rpm -ivh  MySQL-client-3.23.57-1.i386.rpm
Preparing...                ########################################### [100%]
   1:MySQL-client           ########################################### [100%]
rpm command and options
  • -i : install a package
  • -v : verbose
  • -h : print hash marks as the package archive is unpacked.

2. Installing a RPM package without dependency 

Some time we are not able to install RPM due to dependency issue. one RPM is dependent on other. so here is solution, install RPM without checking dependency.


rpm --nodeps -ivh MySQL-client-3.23.57-1.i386.rpm

3. Query all the RPM Packages using rpm -qa

You can use rpm command to query all the packages installed in your system.
# rpm -qa
cdrecord-2.01-10.7.el5
bluez-libs-3.7-1.1
setarch-2.0-1.1
 
  • -q query operation
  • -a queries all installed packages
To identify whether a particular rpm package is installed on your system, combine rpm and grep command as shown below. Following command checks whether cdrecord package is installed on your system.
# rpm -qa | grep 'cdrecord'

4. Query a Particular RPM Package using rpm -q

The above example lists all currently installed package. After installation of a package to check the installation, you can query a particular package and verify as shown below.
# rpm -q MySQL-client
MySQL-client-3.23.57-1
 
# rpm -q MySQL
package MySQL is not installed
Note: To query a package, you should specify the exact package name. If the package name is incorrect, then rpm command will report that the package is not installed.

5. Query RPM Packages in a various format using rpm –query format

Rpm command provides an option –query format, which allows you to give the header tag names, to list the packages. Enclose the header tag with in {}.
# rpm -qa --queryformat '%{name-%{version}-%{release} %{size}\n'
cdrecord-2.01-10.7 12324
bluez-libs-3.7-1.1 5634
setarch-2.0-1.1 235563

6. Which RPM package does a file belong to? – Use rpm -qf

Let us say, you have list of files and you would want to know which package owns all these files. rpm command has options to achieve this.
The following example shows that /usr/bin/mysqlaccess file is part of the MySQL-client-3.23.57-1 rpm.
# rpm -qf /usr/bin/mysqlaccess
MySQL-client-3.23.57-1
  • -f : file name

7. Locate documentation of a package that owns file using rpm -qdf

Use the following to know the list of documentations, for a package that owns a file. The following command, gives the location of all the manual pages related to mysql package.
# rpm -qdf /usr/bin/mysqlaccess
/usr/share/man/man1/mysql.1.gz
/usr/share/man/man1/mysqlaccess.1.gz
/usr/share/man/man1/mysqladmin.1.gz
/usr/share/man/man1/mysqldump.1.gz
/usr/share/man/man1/mysqlshow.1.gz
  • -d : refers documentation.

8. Information about Installed RPM Package using rpm -qi

rpm command provides a lot of information about an installed package using rpm -qi as shown below:
# rpm -qi MySQL-client
Name        : MySQL-client                 Relocations: (not relocatable)
Version     : 3.23.57                           Vendor: MySQL AB
Release     : 1                             Build Date: Mon 09 Jun 2003 11:08:28 PM CEST
Install Date: Mon 06 Feb 2010 03:19:16 AM PST               Build Host: build.mysql.com
Group       : Applications/Databases        Source RPM: MySQL-3.23.57-1.src.rpm
Size        : 5305109                          License: GPL / LGPL
Signature   : (none)
Packager    : Lenz Grimmer
URL         : http://www.mysql.com/
Summary     : MySQL - Client
Description : This package contains the standard MySQL clients.
If you have an RPM file that you would like to install, but want to know more information about it before installing, you can do the following:
# rpm -qip MySQL-client-3.23.57-1.i386.rpm
Name        : MySQL-client                 Relocations: (not relocatable)
Version     : 3.23.57                           Vendor: MySQL AB
Release     : 1                             Build Date: Mon 09 Jun 2003 11:08:28 PM CEST
Install Date: (not installed)               Build Host: build.mysql.com
Group       : Applications/Databases        Source RPM: MySQL-3.23.57-1.src.rpm
Size        : 5305109                          License: GPL / LGPL
Signature   : (none)
Packager    : Lenz Grimmer
URL         : http://www.mysql.com/
Summary     : MySQL - Client
Description : This package contains the standard MySQL clients.
  • -i : view information about an rpm
  • -p : specify a package name

9. List all the Files in a Package using rpm -qlp

To list the content of a RPM package, use the following command, which will list out the files without extracting into the local directory folder.
$ rpm -qlp ovpc-2.1.10.rpm
/usr/bin/mysqlaccess
/usr/bin/mysqldata
/usr/bin/mysqlperm
.
.
/usr/bin/mysqladmin
  • q : query the rpm file
  • l : list the files in the package
  • p : specify the package name

10. List the Dependency Packages using rpm -qRP

To view the list of packages on which this package depends,
# rpm -qRp MySQL-client-3.23.57-1.i386.rpm
/bin/sh
/usr/bin/perl

11. Find out the state of files in a package using rpm -qsp

The following command is to find state (installed, replaced or normal) for all the files in a RPM package.
# rpm -qsp MySQL-client-3.23.57-1.i386.rpm
normal        /usr/bin/msql2mysql
normal        /usr/bin/mysql
normal        /usr/bin/mysql_find_rows
normal        /usr/bin/mysqlaccess
normal        /usr/bin/mysqladmin
normal        /usr/bin/mysqlbinlog
normal        /usr/bin/mysqlcheck
normal        /usr/bin/mysqldump
normal        /usr/bin/mysqlimport
normal        /usr/bin/mysqlshow
normal        /usr/share/man/man1/mysql.1.gz
normal        /usr/share/man/man1/mysqlaccess.1.gz
normal        /usr/share/man/man1/mysqladmin.1.gz
normal        /usr/share/man/man1/mysqldump.1.gz
normal        /usr/share/man/man1/mysqlshow.1.gz

12. Verify a Particular RPM Package using rpm -Vp

Verifying a package compares information about the installed files in the package with information about the files taken from the package metadata stored in the rpm database. In the following command, -V is for verification and -p option is used to specify a package name to verify.
# rpm -Vp MySQL-client-3.23.57-1.i386.rpm
S.5....T c        /usr/bin/msql2mysql
S.5....T c        /usr/bin/mysql
S.5....T c        /usr/bin/mysql_find_rows
S.5....T c        /usr/bin/mysqlaccess
The character in the above output denotes the following:
  • S file Size differs
  • M Mode differs (includes permissions and file type)
  • 5 MD5 sum differs
  • D Device major/minor number mismatch
  • L readlink(2) path mismatch
  • U User ownership differs
  • G Group ownership differs
  • T mTime differs

13. Verify a Package Owning file using rpm -Vf

The following command verify the package which owns the given filename.
# rpm -Vf /usr/bin/mysqlaccess
S.5....T c /usr/bin/mysql

14. Upgrading a RPM Package using rpm -Uvh

Upgrading a package is similar to installing one, but RPM automatically un-installs existing versions of the package before installing the new one. If an old version of the package is not found, the upgrade option will still install it.
# rpm -Uvh MySQL-client-3.23.57-1.i386.rpm
Preparing...                   ########################################### [100%]
1:MySQL-client          ###########################################

15. Uninstalling a RPM Package using rpm -e

To remove an installed rpm package using -e as shown below. After uninstall, you can query using rpm -qa and verify the uninstall.
# rpm -ev MySQL-client

16. Verifying all the RPM Packages using rpm -Va

The following command verifies all the installed packages.
# rpm -Va
S.5....T c /etc/issue
S.5....T c /etc/issue.net
S.5....T c /var/service/imap/ssl/seed
S.5....T c /home/httpd/html/horde/ingo/config/backends.php
.
.
S.5....T c /home/httpd/html/horde/ingo/config/prefs.php
S.5....T c /etc/printcap

23 April 2014

Reference summary of ASMCMD commands

Reference summary of ASMCMD commands

cd      Changes the current directory to the specified directory.

du      Displays the total disk space occupied by ASM files in the specified ASM directory and all its subdirectories, recursively.

exit    Exits ASMCMD.

find    Lists the paths of all occurrences of the specified name (with wildcards) under the specified directory.

help    Displays the syntax and description of ASMCMD commands.

ls        Lists the contents of an ASM directory, the attributes of the specified file, or the names and attributes of all disk groups.

lsct      Lists information about current ASM clients.

lsdg     Lists all disk groups and their attributes.

mkalias Creates an alias for a system-generated filename.

mkdir   Creates ASM directory.

pwd     Displays the path of the current ASM directory.

rm       Deletes the specified ASM files or directories.

rmalias Deletes the specified alias, retaining the file that the alias points to.

ASMCMD cp command fails with ORA-15046

Symptoms

ASMCMD cp command fails with
ORA-15046: ASM file name +DGEXTBK/prod/datafile/tbsext.256.628847401' is not in single-file creation form

Cause

The target file name specified is not a valid file name.
The cp command failed because the ASM file name was not in a form that can be used to create an single file.
The file name should not contain the file number/incarnation.

Example 1
==========
ASMCMD> cp +DGEXT/orcl/datafile/tbsext.256.628847401 +DGEXTBK/prod/datafile/tbsext.256.628847401

source +DGEXT/orcl/datafile/tbsext.256.628847401
target +DGEXTBK/prod/datafile/tbsext.256.628847401
ASMCMD-08015: can not create file->'+DGEXTBK/prod/datafile/tbsext.256.628847401'
ORA-15056: additional error message
ORA-17502: ksfdcre:4 Failed to create file +DGEXTBK/prod/datafile/tbsext.256.628847401
ORA-15046: ASM file name '+DGEXTBK/prod/datafile/tbsext.256.628847401' is not in single-file creation form
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 142
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD-08016: copy source->'+DGEXT/orcl/datafile/tbsext.256.628847401' and target->'+DGEXTBK/prod/datafile/tbsext.256.628847401' failed 

Example 2
==========
ASMCMD> cp +DGEXT/orcl/datafile/tbsext.256.628847401 +DGEXTBK/prod/datafile/tbsext.257.628847401

source +DGEXT/orcl/datafile/tbsext.256.628847401
target +DGEXTBK/prod/datafile/tbsext.257.628847401
ASMCMD-08015: can not create file->'+DGEXTBK/prod/datafile/tbsext.257.628847401'
ORA-15056: additional error message
ORA-17502: ksfdcre:4 Failed to create file +DGEXTBK/prod/datafile/tbsext.257.628847401
ORA-15046: ASM file name '+DGEXTBK/prod/datafile/tbsext.257.628847401' is not in single-file creation form
ORA-06512: at "SYS.X$DBMS_DISKGROUP", line 142
ORA-06512: at line 3 (DBD ERROR: OCIStmtExecute)
ASMCMD-08016: copy source->'+DGEXT/orcl/datafile/tbsext.256.628847401' and target->'+DGEXTBK/prod/datafile/tbsext.257.628847401' failed

Solution

The cp command failed because the ASM file name was not in a form that can be used to create an single file.File name should not contain the file number/incarnation
ASMCMD> cp +DGEXT/orcl/datafile/tbsext.256.628847401 +DGEXTBK/prod/datafile/tbsext
source +DGEXT/orcl/datafile/tbsext.256.628847401
target +DGEXTBK/prod/datafile/tbsext
copying file(s)...file, +DGEXTBK/prod/datafile/tbsext, copy committed.
 



11 April 2014

How to change RMAN Global script

Connect to Catalog database 

rman target / catalog rman/rman@RMAN

Print RMAN global script 

PRINT GLOBAL SCRIPT level0_backup_full;

Print RMAN global script to a text file


PRINT GLOBAL SCRIPT level0_backup_full TO FILE '/usr/tmp/level0_backup_full.txt';

Modify your text file. 

Update global script from modified file.


REPLACE GLOBAL SCRIPT level0_backup_full FROM FILE '/usr/tmp/level0_backup_full.txt';

Verify again new global script

rman target / catalog rman/rman@RMAN


PRINT GLOBAL SCRIPT level0_backup_full;

9 April 2014

How to configure Enterprise Manager in 11gR2 Database

 Steps to configure Enterprise Manager in 11gR2

[oracle@dev1 bin]$ export ORACLE_HOME=/u01/app/oracle/product/11.3.0
[oracle@dev1 bin]$ export ORACLE_SID=PROD
[oracle@dev1 bin]$ cd $ORACLE_HOME/bin
[oracle@dev1 bin]$

De-register database from emconsole repository

[oracle@dev1 bin]$ ./emca -deconfig dbcontrol db -repos drop

STARTED EMCA at Apr 9, 2014 11:47:46 AM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

Enter the following information:
Database SID: PROD
Listener port number: 1521
Password for SYS user:
Password for SYSMAN user:
Password for SYSMAN user:
----------------------------------------------------------------------
WARNING : While repository is dropped the database will be put in quiesce mode.
----------------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Apr 9, 2014 11:48:00 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/PROD/emca_2014_04_09_11_47_46.log.
Apr 9, 2014 11:48:00 AM oracle.sysman.emcp.EMDBPreConfig performDeconfiguration
WARNING: EM is not configured for this database. No EM-specific actions can be performed. Some of the possible reasons may be:
 1) EM is configured with different hostname then physical host. Set environment variable ORACLE_HOSTNAME=<hostname> and re-run EMCA script
 2) ORACLE_HOSTNAME is set. Unset it and re-run EMCA script
Apr 9, 2014 11:48:00 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Dropping the EM repository (this may take a while) ...
Apr 9, 2014 11:49:57 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully dropped
Enterprise Manager configuration completed successfully
FINISHED EMCA at Apr 9, 2014 11:49:57 AM
[oracle@dev1 bin]$

Register database from emconsole repository

[oracle@dev1 bin]$ ./emca -config dbcontrol db -repos create

STARTED EMCA at Apr 9, 2014 11:50:32 AM
EM Configuration Assistant, Version 11.2.0.3.0 Production
Copyright (c) 2003, 2011, Oracle.  All rights reserved.

Enter the following information:
Database SID: PROD
Listener port number: 1521
Listener ORACLE_HOME [ /u01/app/oracle/product/11.3.0 ]:
Password for SYS user:
Password for DBSNMP user:
Password for SYSMAN user:
Email address for notifications (optional):
Outgoing Mail (SMTP) server for notifications (optional):
-----------------------------------------------------------------

You have specified the following settings

Database ORACLE_HOME ................ /u01/app/oracle/product/11.3.0

Local hostname ................ dev1.localdomain.com
Listener ORACLE_HOME ................ /u01/app/oracle/product/11.3.0
Listener port number ................ 1521
Database SID ................ PROD
Email address for notifications ...............
Outgoing Mail (SMTP) server for notifications ...............

-----------------------------------------------------------------
Do you wish to continue? [yes(Y)/no(N)]: Y
Apr 9, 2014 11:51:24 AM oracle.sysman.emcp.EMConfig perform
INFO: This operation is being logged at /u01/app/oracle/cfgtoollogs/emca/PROD/emca_2014_04_09_11_50_31.log.
Apr 9, 2014 11:51:25 AM oracle.sysman.emcp.EMReposConfig createRepository
INFO: Creating the EM repository (this may take a while) ...
Apr 9, 2014 11:59:04 AM oracle.sysman.emcp.EMReposConfig invoke
INFO: Repository successfully created
Apr 9, 2014 11:59:27 AM oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository
INFO: Uploading configuration data to EM repository (this may take a while) ...
Apr 9, 2014 12:00:49 PM oracle.sysman.emcp.EMReposConfig invoke
INFO: Uploaded configuration data successfully
Apr 9, 2014 12:00:58 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Securing Database Control (this may take a while) ...
Apr 9, 2014 12:01:09 PM oracle.sysman.emcp.util.DBControlUtil secureDBConsole
INFO: Database Control secured successfully.
Apr 9, 2014 12:01:09 PM oracle.sysman.emcp.util.DBControlUtil startOMS
INFO: Starting Database Control (this may take a while) ...
Apr 9, 2014 12:02:21 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: Database Control started successfully
Apr 9, 2014 12:02:21 PM oracle.sysman.emcp.EMDBPostConfig performConfiguration
INFO: >>>>>>>>>>> The Database Control URL is https://dev1.localdomain.com:5500/em <<<<<<<<<<<
Apr 9, 2014 12:02:23 PM oracle.sysman.emcp.EMDBPostConfig invoke
WARNING:
************************  WARNING  ************************

Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.  The encryption key has been placed in the file: /u01/app/oracle/product/11.3.0/dev1.localdomain.com_PROD/sysman/config/emkey.ora. Ensure this file is backed up as the encrypted data will become unusable if this file is lost.

***********************************************************
Enterprise Manager configuration completed successfully
FINISHED EMCA at Apr 9, 2014 12:02:24 PM
[oracle@dev1 bin]$