Archive for the ‘linux’ Category

Automatically backup Oracle APEX applications to Subversion

March 12th, 2012 2 comments

In continue of my previous posts about APEX and Subversion I made a short script using APEXExport utility to automate and backup APEX to Subversion repository.

I’m using Oracle Express Edition 11.2, which by default doesn’t have the APEXExport utility. That’s why you need first to create the directory holding it and then copy the utility there.


Create destination directory holding the utility and copy APEXExport.class there:

mkdir -p $ORACLE_HOME/utilities/oracle/apex


Create backup directory in the SVN project for holding the backup files:

[oracle@dbsrv ~]$ svn mkdir -m "Making a backup dir."

Committed revision 33.

At this point you’ll be asked for password which must be cached in order the automated backup to work correctly. The password itself is written (I assume you’re logged in with oracle user) in file in this directory: /home/oracle/.subversion/auth/svn.simple/


Finally you need to decide where the backup directory will be checked out. This will be used to store all the APEX backups, which will be committed to the SVN repository:

cd /oracle
svn checkout


This is the script for automating the backup of APEX applications, because the formatting is not correct here is download link for the script:


### Automated APEX applications backup to Subversion (SVN), v1
### 2012-03-07
### Svetoslav Gyurov,

# Environment settings for Oracle database and Java
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export JAVA_HOME=/oracle/ora112ee/jdk

export CLASSPATH=$ORACLE_HOME/jdbc/lib/ojdbc5.jar:$ORACLE_HOME/utilities

# How many days/backups should be kept back
export RETENTION=7
export COMPRESS=0

# SVN directory for Oracle APEX

# Get current date and oldest backup
DATE=`date +%Y%m%d`
OLDEST_BACKUP=`date --date="-${RETENTION} days" +%Y%m%d`

# Change to SVN directory and export data
$JAVA_HOME/bin/java oracle.apex.APEXExport -db -user sve -password secret -applicationid 100


# If APEXExport is successfully continue, otherwise fail with message
if [ $exitValue -eq 0 ];
svn update

for i in `ls -1 f*.sql`
if [ $COMPRESS -eq 1 ];
gzip $i
mv $i.gz ${DATE}_$i.gz
svn add ${DATE}_$i.gz

if [ -f ${OLDEST_BACKUP}_$i.gz ];
rm ${OLDEST_BACKUP}_$i.gz
svn remove ${OLDEST_BACKUP}_$i.gz
mv $i ${DATE}_$i
svn add ${DATE}_$i

if [ -f ${OLDEST_BACKUP}_$i ];
svn remove ${OLDEST_BACKUP}_$i

svn commit -m "Daily APEX backup completed and committed."

echo Daily APEX backup completed.

echo "APEX applications could not be exported"

Of course there are few parameters which need to be set. These are ORACLE_HOME, JAVA_HOME, RETENTION period defines how many backups to be kept back and COMPRESS defines whether the exported applications be compressed with gzip. Also don’t forget to change the application id, you could also put the whole workspace to be backed up.


Finally put the script at the crontab:

31 1 * * * /home/oracle/ > /dev/null 2>&1


To check whether the backup was successful run svn info or svn log within the backup directory or just browse the repository:

cd /oracle/Backup
[oracle@dbsvn Backup]$ svn info
Path: .
Repository Root:
Repository UUID: 40fb9d41-50a5-4b10-b803-b133fb623816
Revision: 59
Node Kind: directory
Schedule: normal
Last Changed Author: oracle
Last Changed Rev: 59
Last Changed Date: 2012-03-07 01:31:07 +0200 (Wed, 07 Mar 2012)

[oracle@dbsrv Backup]$ svn log
r59 | oracle | 2012-03-07 01:31:07 +0200 (Wed, 07 Mar 2012) | 1 line

Daily APEX backup completed and commited.


Feel free to modify the script for your own needs.



Categories: linux, oracle Tags: , ,

Unable to create ASM disk under OEL 6.x

February 22nd, 2012 7 comments

It was busy month and I’m behind with my blog posts. First of all Happy New Year to all of you and wish you all the best through the new year!

This is a short note for installing Oracle Database with ASM under Oracle Enterprise Linux 6.x, which is not certified YET!

If you are running ASM with ASMLib you may get the following error when try to create ASM disk:

[root@db-app2 ~]# oracleasm createdisk DISK01 /dev/mapper/data01
Writing disk header: done
Instantiating disk: failed
Clearing disk header: done


Writing the header on the disk fails without obvious reason. Well, it turned out that Security Linux was blocking the access to the disk. Because configuration of SELinux is not part of the startup configuration any more I just forgot it.

To disable the SELinux edit file /etc/selinux/config and configure SELINUX=disabled. Then reboot your system and run getenforce to confirm that SELinux is disabled:

[root@db-app2 ~]# /usr/sbin/getenforce


The ASM disk is created successfully this time:

[root@db-app2 ~]# oracleasm createdisk DISK01 /dev/mapper/data01
Writing disk header: done
Instantiating disk: done



Categories: linux, oracle Tags: ,

Database 11.2 bug causes huge number of alert log entries

December 22nd, 2011 5 comments

Few days ago I received a call from customer about problem with their EM console and messages about file system full. They run DB on OEL 5.7 and had only binaries installation at that file system and the database itself was using ASM. I quickly logged on to find out the file system was really full and after looking around I figure out that all the free space was eaten by alert and trace diagnostic directories. The trace directory was full of 10MB files and the alertlog file was quick growing with following messages:

 WARNING: failed to read mirror side 1 of virtual extent 2917 logical extent 0 of file 271 in group [1.2242406296] from disk DATA_0000 allocation unit 24394 reason error; if possible,will try another mirror side
Errors in file /oracle/app/oracle/diag/rdbms/baandb/baandb/trace/baandb_ora_17785.trc:
WARNING: Read Failed. group:1 disk:0 AU:24394 offset:1007616 size:8192
WARNING: failed to read mirror side 1 of virtual extent 2917 logical extent 0 of file 271 in group [1.2242406296] from disk DATA_0000 allocation unit 24394 reason error; if possible,will try another mirror side
Errors in file /oracle/app/oracle/diag/rdbms/baandb/baandb/trace/baandb_ora_17785.trc: 

At first I though there is a storage problem, but looking at the ASM views everything seemed to be all right and these seemed to be false messages. I deleted all the trace files, but then few minutes later the file system became again full. It turned out that generated log per minute were more than 60MBor around 7GB for two hours, because of this huge number of messages the machine was already loaded.

Then after quick MOS search I found that this is a Bug 10422126: FAILED TO READ MORROR SIDE 1 and there is a 70KB patch for

The following MOS notes are also useful:
WARNING: ‘Failed To Read Mirror Side 1’ continuously reported in the alert log [ID 1289905.1]
Huge number of alert log entries: ‘WARNING: IO Failed…’ ‘WARNING: failed to read mirror side 1 of virtual extent …’ [ID 1274852.1]

After applying the patch everything became normal and no more false messages appeared in the logs. The bug is fixed in


Categories: linux, oracle Tags: ,

Configuring PHP with Oracle support on Oracle Enterprise Linux

November 17th, 2011 No comments

In case you need to run PHP with Oracle support this is how to do it with Oracle Enterprise Linux 5.x. I assume that Apache and PHP are already installed.

First you need to download the source of latest version of oci8 driver, here. Also you need to download and install the latest version of Oracle Instant Client Packages – Basic and SDK, here.

The next step is to install both packages on the system:

rpm -ivh oracle-instantclient11.2-basic-
rpm -ivh oracle-instantclient11.2-devel-


After installing the instant client, you have to build the oci8:

tar xfzv oci8-1.4.6.tgz
cd oci8-1.4.6
./configure -with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
make install

Module will be installed in PHP modules directory, which is /usr/lib64/php/modules/.

Edit php.init and add the following line to make oci8 driver to be loaded by PHP:

After restarting the web server,  you now have Oracle support enabled in PHP. Oracle support could be tested from command line without restarting the web server, with this simple script:

cat > /tmp/oracle.php

$username = "scott";
$passwd = "tiger";
$conn = OCILogon($username,$passwd,$db);
if (!$conn)
    echo "Connection failed";
    echo "Error Message: [" . OCIError($conn) . "]";
    echo "Connected!";


Running the script shows that it is connecting successfully to the database:

[root@app tmp]# php oracle.php


There is also manual at PHP for installation and configuration of OCI8, which could be found here.


Categories: linux, oracle Tags:

How to integrate Oracle SQL Data Modeler with Subversion

November 15th, 2011 8 comments

It’s not necessary to work on a big project to use SVN. Keeping your design into SVN repository is very useful and good practice. By doing so you could easily see what changes you’ve made to the design and in case of accident you could restore any older version and correct the problem.

After you successfully setup Subversion (here) it’s time to start integrating tools with SVN. Integration of Oracle SQL Data Modeler is really easy and it’s done in few simple steps:

1. Integrated Oracle SQL Data Modeler with SVN:
Start Oracle SQL Data Modeler
Go to View -> Team -> Versioning Navigator
At the Versioning Navigator window, right click on Subversion and then New Repository Connection.
Populate the fileds at new window Create Subversion Connection with repository URL, username, password and name for the repository.

2. Import files to the repository:
Once configured you have to import all the files on which you are working, including the database design to the repository. For this purpose you could use Data Modeler itself, but I prefer TortoiseSVN to create the repository structure and then import all the files in it. As I mention in preventions post, the best practice is to create three directories trunk, branch and tags and then import your working directories to trunk.

When these files are imported you should delete them from your hard drive and checkout the same files from the repository so you have a working copy.

3. Start using Oracle SQL Data Modeler and SVN:
Checking out from the repository could be done by TortoiseSVN or by Oracle SQL Data Modeler -> Versioning menu -> Checkout. Once you have a working copy you could open the design and start working on it.

Next time you make a change and save the design you’ll be able to commit these changes to the repository, again by going to Versioning menu and then Commit. Using comments is also good idea so you could easily track when and what changes you’ve made to the design.


Categories: linux, oracle Tags:

Setup Subversion on Oracle Enterprise Linux

November 1st, 2011 5 comments

As I mentioned in my previous post I’m using Subversion to keep my SQL design, APEX application and all application serving files. Concurrent Versions System are not something new and they are must for big projects. Although I’m single person, I’m finding SVN very useful for many reasons:

  • All my files are kept at one place. At any time I could checkout the whole application and deploy it on different server.
  • I have a history (revisions) of my changes. If I know something worked yesterday I could just checkout the file from yesterday and get it working.
  • Using APEXExport I’m doing daily backups of my applications.
  • Oracle SQL Developer and SQL Data Modeler are easy to integrate with SVN.
  • When the time comes, I’ll create a branch, stable version of my application, by doing so I’ll have at any time a working and stable copy of my application.
  • Having branches I could still develop and improve the application itself, if a bug appears I’ll be fixing it in the branch not in the main version (trunk).
  • At any time more people could join the project and this would not stop the development process.

Just saw today, that Eddie Award retweeted Subversion Best Practices: Repository Structure, so I recommend you to get familiar with SVN first, before start using it.

Usually I’m using Debian for CVS systems, but in this case I’m installing Subversion on OEL 5.6, the procedure is the same for OEL 6.x.

First of all you need to install web server and svn packages. Assuming you have a configured repository, this is how to installed the packages:
yum install httpd mod_dav_svn subversion

If you want to change specific parameters you could edit Apache configuration file /etc/httpd/conf.d/httpd.conf, otherwise it’s not necessary.

Next you configure the SVN repository and authentication, the repository itself will be created next.

Edit file vi /etc/httpd/conf.d/subversion.conf and paste following:
<Location /svn>
DAV svn
SVNParentPath /var/www/svn
SVNListParentPath on
SVNIndexXSLT “/repos-web/view/repos.xsl”
AuthType Basic
AuthName “Oracle Repository authentication required”
AuthUserFile /etc/httpd/conf.d/svn.users
Require valid-user

Create users who can access the repository:
htpasswd -cm /etc/httpd/conf.d/svn.users oracle
New password:
Re-type new password:
Adding password for user oracle
[root@db ~]# cat /etc/httpd/conf.d/svn.users

Create the SVN repository:
mkdir /var/www/svn/
cd /var/www/svn/
svnadmin create oracle
chown -R apache:apache oracle

Finally restart apache and make sure it starts after reboot:
/etc/init.d/httpd restart
chkconfig httpd on

In case you see the following error then most probably you’ve omitted the SVNListParentPath parameter:
Could not fetch resource information.  [403, #0]
(2)No such file or directory: The URI does not contain the name of a repository.  [403, #190001]

These is also an issue if you use SVNListParentPath and AuthzSVNAccessFile, bug description and workaround could be found here.

Now you are ready to create you’re first project and start using SVN to maintain the source code of your applications. Given the example, the access URL would be http://hostname/svn/oracle or locally svn info file:///var/www/svn/oracle/. For maintaining the code you could use TortoiseSVN, which is excellent client for Windows.

The parameter I specified early SVNIndexXSLT will define the repository style once opened in a web browser. In my case I used a package called repo-style, which could be found here.

This is how my repository looks like:

plus the repository history looks really cool 🙂

It’s much better than the default one:



Categories: linux, oracle Tags: , ,

Installing Oracle Enterprise Manager Cloud Control 12 on OEL 6.1

October 7th, 2011 2 comments

Few days ago Oracle announced the release of Oracle Enterprise Manager Cloud Control 12c. I tried to summarize most of the information in my post so I’ll not discuss any details here, but I’ll go only with few details regarding EM12c installation.

For the purpose I have setup a VMWare virtual machine with 2 CPUs, 4GB RAM and 32 GB HDD, one network interface. Installed Oracle Enterprise Linux 6.1 (64 bit) with following parameters:

  • Perform custom disk layout, I dedicated 4GB for swap and the rest for the root (/) file system and formatted it with ext4.
  • Perform default installation, needed packages will be installed later.
  • Set hostname, timezone and root password.
  • After installation disable the firewall and most of some of the services, like IPV6.

After installation the network adapter won’t be available that why you have to install several packages and then compile the VMWare tools. Insert the installation DVD/ISO and install the following packages:

mount /dev/cdrom /mnt
rpm -ivh -ivh gcc-4.4.5-6.el6.x86_64.rpm cloog-ppl-0.15.7-1.2.el6.x86_64.rpm cpp-4.4.5-6.el6.x86_64.rpm glibc-devel-2.12-1.25.el6.x86_64.rpm
glibc-headers-2.12-1.25.el6.x86_64.rpm kernel-uek-headers-2.6.32-100.34.1.el6uek.x86_64.rpm ppl-0.10.2-11.el6.x86_64.rpm
mpfr-2.4.1-6.el6.x86_64.rpm kernel-uek-devel-2.6.32-100.34.1.el6uek.x86_64.rpm
umount /dev/cdrom

Then disconnect the drive and from the console go to VM->Guest->Install/Upgrade VMWare Tools, then install the guest additions:

cp /mnt/VMwareTools-8.3.2-257589.tar.gz /tmp
umount /mnt
cd /tmp
tar xfz VMwareTools-8.3.2-257589.tar.gz
cd vmware-tools-distrib

At this point you should be able to configure the network interfaces.

Before starting the installation, download the packages from OTN and transfer them to the server. The installation consist of two zip packages, which are 5.5GB total, but this includes Oracle Weblogic Server 10.3.5, which is installed by default from the wizard.


Oracle Enterprise Manager Cloud Control 12c installation prerequisites

For the installation of Enterprise Manager Cloud Control I’m following the documentation:
Oracle® Enterprise Manager Cloud Control Basic Installation Guide 12c Release 1 (

1. From Oracle Database onwards, all versions are certified for Management Repository. The last two releases and do not need additional patches for it to be configured successfully. For the rest of the version additional patches are needed, refer to MOS for more information.

Except the support for Management Repository few more parameters are needed to be set. They could be set before or after the installation. For setting database initialization parameters refer to Table-6 or Table-7 from Appendix A at the documentation.

Once you are ready you could run the EM Prerequisite Kit which is run by the wizard during the installation.

2. According to the Oracle documentation for small environment, you need following servers parameters:
For the OMS: 2 CPUs, 4 GB RAM and 7 GB space excluding the installation which is 5.5 GB.
For the Management Repository: 2 CPUs, 2 GB RAM and 50 GB space.

3. Packages and kernel parameters required for OMS:
The following packages should be installer, either from ISO or from public yum server:

yum install make.x86_64 binutils.x86_64 libaio.x86_64 glibc-common.x86_64 libstdc++.x86_64 sysstat.x86_64 glibc-devel.i686 glibc-devel.x86_64

The shmmax kernel parameter should be set to value bigger than 4GB. In OEL 6.1 this parameter is far beyond and it’s set to 64GB. Its current value could be retrieved by following command:

cat /proc/sys/kernel/shmmax

4. Create group and user for the installation of Enterprise Manager 12c
The installation could not be done by root and oracle user has to be created. I’m using the same group id and user id as they would be created by oracle-validated package (which is not yet available for OEL 6.x).

groupadd -g 54321 oinstall
useradd -u 54321 -g oinstall -s /bin/bash -d /home/oracle -m oracle
passwd oracle

5. Configure limits.conf file:
The following two parameter has to be set in /etc/security/limits.conf file
oracle soft nofile 4096
oracle hard nofile 4096


Oracle Enterprise Manager Cloud Control 12c installation

Proceed with default installation and following the installation wizard.

If the wizard gives you warning at “Checking whether required GLIBC installed on system” although you have installed all the prerequisites you could ignore the warning. The installer is checking whether the package glibc-devel.i386 is installed, but you have already installed glibc-devel.i686.

Supply the repository details and please be sure to check whether the database control doesn’t exists. Otherwise you’ll get an error after supplying the database credentials to drop the database control of the repository database:
$ORACLE_HOME/bin/emca -deconfig dbcontrol db -repos drop -SYS_PWD <sys_password> -SYSMAN_PWD <sysman_password>

Once the installation is complete you’ll get a screen with installation summary and details how to access the console.

Then you could login and select default home page. This is how the console look like:


Meanwhile I just saw two useful installation guides:


Categories: linux, oracle Tags: , , ,

No ethernet adapters with OEL6 under VMware ESX 4.1

May 13th, 2011 3 comments

I was playing around with Oracle Database 11.2 on OEL6.0 guest machine running on VMware ESX 4.1 and after installation I had no ethernet adapters. I didn’t notice that before, because I always set the network to E1000 and now it was VMXNET3. Here is the description of the networks from the VMware manual:

E1000: An emulated version of the Intel 82545EM Gigabit Ethernet NIC. A driver for this NIC is not included with all guest operating systems. Typically Linux versions 2.4.19 and later, Windows XP Professional x64 Edition and later, and Windows Server 2003 (32-bit) and later include the E1000 driver.

VMXNET 3: The VMXNET 3 adapter is the next generation of a paravirtualized NIC designed for performance, and is not related to VMXNET or VMXNET 2. It offers all the features available in VMXNET 2, and adds several new features like multiqueue support (also known as Receive Side Scaling in Windows), IPv6 offloads, and MSI/MSI-X interrupt delivery. VMXNET 3 is supported only for virtual machines version 7 and later, with a limited set of guest operating systems:

* 32 and 64bit versions of Microsoft Windows XP, 2003, 2003 R2, 2008,and 2008 R2.
* 32 and 64bit versions of Red Hat Enterprise Linux 5.0 and later
* 32 and 64bit versions of SUSE Linux Enterprise Server 10 and later
* 32 and 64bit versions of Asianux 3 and later
* 32 and 64bit versions of Debian 4
* 32 and 64bit versions of Ubuntu 7.04 and later
* 32 and 64bit versions of Sun Solaris 10 U4 and later

So it turns out that it should be supported by Oracle Enterprise Linux and I need to install the vmware tools.

Here is how to do it with default installation of OEL6:
– Connect the OEL installation media to the guest

– mount the media:
mount /dev/cdrom /mnt

– change directory to installation packages and install the following packages:
cd /mnt/Packages

rpm -ivh gcc-4.4.4-13.el6.x86_64.rpm cloog-ppl-0.15.7-1.2.el6.x86_64.rpm glibc-devel-2.12-1.7.el6.x86_64.rpm cpp-4.4.4-13.el6.x86_64.rpm ppl-0.10.2-11.el6.x86_64.rpm mpfr-2.4.1-6.el6.x86_64.rpm glibc-headers-2.12-1.7.el6.x86_64.rpm kernel-uek-headers-2.6.32-100.28.5.el6.x86_64.rpm kernel-uek-devel-2.6.32-100.28.5.el6.x86_64.rpm

* Because OEL6 ships by default with Oracle Enterprise Linux Kernel, kernel-uek-devel should be installed for proper compilation of the vmware tools.

– Umount the installation media and install vmware tools:
umount /mnt
VM -> Guest -> Install/Upgrade Vmware tools

– Mount the vmware tools media and copy the packages:
mount /dev/cdrom /mnt
cp /mnt/VMwareTools-8.3.2-257589.tar.gz /tmp
umount /mnt
cd /tmp
tar xfz VMwareTools-8.3.2-257589.tar.gz
cd vmware-tools-distrib

Answer by default to all the questions, if all the packages are installed the compilation should finish in a minute and network interfaces should become available.

After susccefful installation the following could be seen in dmesg:

VMware PVSCSI driver – version
VMware memory control driver initialized
vmmemctl: started kernel thread pid=14962

VMware vmxnet3 virtual NIC driver – version
eth0: NIC Link is Up 10000 Mbps


For OEL 5.6 the following packages has to be installed, rest is the same:
rpm -ivh gcc-4.1.2-50.el5.x86_64.rpm glibc-headers-2.5-58.x86_64.rpm glibc-devel-2.5-58.x86_64.rpm kernel-uek-headers-2.6.32-100.26.2.el5.x86_64.rpm kernel-uek-devel-2.6.32-100.26.2.el5.x86_64.rpm



Categories: linux, virtualization Tags:

LVM adventures with SLES 10 SP2

February 16th, 2011 No comments

Recently I was asked to move one database and few files systems from one storage system to another, they all resided on one server. The source storage system was EVA4400 with FATA and destination was again EVA4400, but running with FC drives. Both storage systems were having 8Gbits connection. The storage layout was: three physical volumes 2TB each and one PV 2.5 TB, these were separate in three volume groups and were created five logical volumes on top of them.

For completing the task I had several options:
1. Regular file system copy (offline)
2. Using dd (offline)
3. Using BCV (almost online)
4. LVM mirroring (online)

So I started testing and giving pros and cons of every option:

1. Because I had already moved files on other systems I knew the speed of coping files from one file system to another. Doing to calculations it turned out that we need three or at least two ways and half for coping data from one file system (FATA) to another (FC). Another good point was the count of files in one of the file systems, it was 3M (a lot of small) files! which means that probably three ways wasn’t to be enough for process to complete. On top of this the process should be offline because of database consistency.

2. The other choice was doing dd for all of the volumes. Doing dd would be better than file system copy, but again it has to be offline and we have no control of the process. What’s more some we had LUNs which are bigger than 2TB on the first system, but were unable to create bigger  LUNs than 2TB on the second storage system, because of the firmware issue. It’s something I’m going to blog latter, by the same reason were unable to use Busineess Copy (snapshots and snapclones).

3. We had an option to move data to the same storage system using BCV, with snapclone we could move data from one disk group to another. This would be definitely the fastest ways and a little downtime would be required just to remount the new file systems and start the database and applications. Because using the latest firmware we had LUNs which were bigger than 2TB we were unable to do any replication solutions with them. Again, I’ll blog about this one soon.

4. So the last technology left was the LVM mirroring. I’ve had a lot of experience with LVM on the HP-UX systems and I really like it. I’ve decided to give it a try on the Linux, well I’ve worked with LVM on Linux, but nothing more than create/extend and resize. From here I started a month process with adventures:

The first difference with HP-UX was that I need one additional disk for mirror log (?). In Linux LVM if you want to create mirror, additional disk is need or else the log is written to memory and if the server is restarted, the process must be repeated. The error message is following:
sles10:/ # lvconvert -m1 vg01/lvtest /dev/sdc
Not enough PVs with free space available for parallel allocation.
Consider –alloc anywhere if desperate.
sles10:/ # lvconvert -m1 vg01/lvtest /dev/sdc /dev/sdd
Logical volume lvtest converted.

What’s disturbing is that I wasn’t able to find what should be the size of the mirror log. It’s not in the docs, some folks at the forums said that it should be 1% of the size of the mirrored logical volume. Actually it’s one extend big:
[lvtest_mlog]     vg01 lwi-ao    1 linear  4.00M /dev/sdd(0)

After I spent one week in creating virtual disks and mirroring logical volumes and got to the point where I should break the mirror and remove the physical volumes from the first storage system. For this purpose I had two options:
4.1. lvconvert (online)
4.2. vgsplit (almost online)

4.1. Using lvconvert -m0 I was supposed to remove the first physical volume and leave the file system on the second storage system. With no obvious reason I got the following error when I try to break the mirror i.e. convert the logical volume to linear:
sles10:/ # lvconvert -m0 vg01/lvtest /dev/sdc
No free extents on physical volume “/dev/sdc”
No specified PVs have space available

Sure I don’t have free extents, but why do I need them when I’m currently breaking and not creating the mirror ? I search a lot and didn’t found any solution, probably this is a bug of the current version of the SLES. Either way I decided to test this in a lab environment and figure out what could be done to finish the process. I created one group with two physical volumes, 1GB each and then created logical volume with exact same size. It was the same, I wasn’t able to break the mirror:
— Physical volumes —
PV Name               /dev/sdb
Total PE / Free PE    256 / 0
PV Name               /dev/sdc

Total PE / Free PE    256 / 0

I wasn’t able to remove the first physical volume, if I execute just lvconvert -m0 /dev/sdb, without the third argument then I’m at starting point.

I’ve got it literally, I don’t have enough physical extents, I’ve decided to test this in a lab environment and resizing the first physical volume just by one extent resolved the problem:
— Logical volume —
LV Name                /dev/vg01/lvtest
Current LE             257
— Physical volumes —
PV Name               /dev/sdb
Total PE / Free PE    258 / 1
PV Name               /dev/sdc
Total PE / Free PE    257 / 0

sles10:~ # lvconvert -m0 vg01/lvtest /dev/sdb
Logical volume lvtest converted.

I was hopeful that I will get over this error by just resizing the LUNs with its minimal step (in EVA this is 1 GB), but this was not possible. Again because of firmware issues I was not able to extent the LUNs. At this point I decided to do it the hard way, which is unpresent the LUNs from the first storage system without breaking the mirror. This worked great, just by unpresenting the LUNs the LVM detected this and removed the failed physical volumes, all the file systems continued working without interruption.

This was possible with four of the LUNs, but the last one was bigger and it spanned across two logical volumes. Because of this or some other reason unpresenting just the LUN didn’t worked out and I decided to go on with the last option.

4.2. Using vgsplit sounds promising, some of the manuals in Internet showed that this is the way to break a mirror. The steps are almost the same, using lvconvert remove the mirror from the second physical volume, delete any left lvol_mimage_X volumes and then using vgsplit create another volume group with the second physical volume. If the file systems are opened during lvconvert then lvol_mimage volume will reside for sure. After spliting the volume group the same logical volumes with exactly the same count of logical extents has to be created. At this point regular file system check would be enough and the file systems could be mounted. Well, it took me more than an hour to check 2TB the file system, but otherwise everything is fine.

As a conclusion I would say that BCV would be fastest for moving data within the same storage system. Of course we are only talking about online or almost online replication so the other option is using LVM mirroring. Depending on the Linux/Unix distribution this could be done with lvconvert to reduce the volume group with the first physical volume or using vgsplit to move the second physical volume to another volume group and recreate the logical volumes.



Categories: linux, storage Tags:

Cannot drop the first disk group in ASM 11.2

October 11th, 2010 2 comments

I’ve been using ASM for long time in different configurations, with pfile, with spfile and in some configurations on shared raw device. Playing with ASM 11gR2 (Grid Infrastructure) it happens to me that I cannot neither drop neither dismount the first disk group.

The following error can be seen in asmca when try to dismount the first disk group:

Dismounting DiskGroup DATA failed with the following message:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup "DATA" precludes its dismount

If you go to sqlplus and try to drop the disk group, there is an error that the disk group is actually still active:

SQL> drop diskgroup data including contents;
drop diskgroup data including contents
ERROR at line 1:
ORA-15039: diskgroup not dropped
ORA-15027: active use of diskgroup "DATA" precludes its dismount

So, let’s try to dismount it:

SQL> alter diskgroup all dismount;
alter diskgroup all dismount
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15027: active use of diskgroup "DATA" precludes its dismount

Lets see why the active group is still active. Query of v$asm_file shows all files located at this disk group:

SQL> select group_number, file_number, bytes, type from v$asm_file;
------------ ----------- ---------- --------------------
1         253       1536 ASMPARAMETERFILE

It seems that the ASM instance server parameter file is located in the first created disk group and thats why I cannot dismount it.

Quick check confirms that:

SQL> show parameter spfile
NAME      TYPE         VALUE
--------- ----------- ------------------------------
spfile    string       +DATA/asm/asmparameterfile/registry.253.731706127

srvctl command also can be used to confirm that:

[oracle@oradb /]$ srvctl config asm
Spfile: +DATA/asm/asmparameterfile/registry.253.731706127

I made an experiment and I just installed the grid infrastructure software. Then I went with asmca to create ASM instance. There is a button ASM Parameters and then Show Advanced Parameters. There is clearly written that the parameter file is located in $ORACLE_HOME/dbs/spfile+ASM.ora

It seems that after the installation the file is moved to the disk group. So if you really want to drop the disk group you should move the spfile from the disk group to the file system (or other disk group), then shutdown and startup the ASM instance and then drop the disk group. The traditional way would be to create pfile from spfile and then start the instance with pfile. There are couple of commands in ASM 11.2 available in asmcmd, one of them is spmove. It gives you the ability to move the spfile and automatically updates Grid Plug and Play (GPnP) profile. Another one is spget which gives you the current location of the ASM instance server parameter file.

Start the asmcmd utility and execute spget to get the current spfile, then spmove to move the spfile from the disk group to the file system:

[oracle@oradb ~]$ asmcmd
ASMCMD> spget 
ASMCMD> spmove '+DATA/asm/asmparameterfile/registry.253.731706127' '/oracle/grid11g/dbs/spfile+ASM.ora';
ORA-15032: not all alterations performed
ORA-15028: ASM file '+DATA/asm/asmparameterfile/registry.253.731706127' not dropped; currently being accessed (DBD ERROR: OCIStmtExecute)
ASMCMD> spget

I get the error that the file is still being used, but actually the file is copied to the file system and the profile is updated. Now shutdown and startup the ASM instance:

SQL> shutdown immediate
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area  283930624 bytes
Fixed Size		    2212656 bytes
Variable Size		  256552144 bytes
ASM Cache		   25165824 bytes
ASM diskgroups mounted
SQL> show parameter spfile;

----------  ----------- ------------------------------
spfile	    string	 /oracle/grid11g/dbs/spfile+ASM.ora;

spget command also can be used to get the current spfile location from GPnP profile:

[oracle@oradb ~]$ asmcmd
ASMCMD> spget

So now we have the same behavior of ASM prior 11gR2, the server parameter file is in the file system and finally we can drop the disk group:

SQL> alter diskgroup data mount;

Diskgroup altered.
SQL> drop diskgroup data including contents;
Diskgroup dropped.

This behavior of placing the spfile of the ASM instance inside ASM disk group is now recommended by Oracle. This is accomplished by the ASM background process ASMB, which reads the spfile from the disk group and starts the instance itself. Whats more if you want this behavior or use the new spmove/spcopy/spset/spget/spbackup commands, the disk group attribute COMPATIBLE.ASM must be set to 11.2

At the end I found that there is also MOS note about this problem:
11gR2 ( ORA-15027: active use of diskgroup precludes its dismount (With no database clients connected) [ID 1082876.1]

Categories: linux, oracle Tags: ,