Cross Column

Showing posts with label Cloning. Show all posts
Showing posts with label Cloning. Show all posts

Wednesday, June 25, 2014

Oracle Fusion Apps: The port may already be used by another process

After cloning our benchmark (i.e., CRM FUSE) to new servers, the following issue popped up:
The port may already be used by another process
This happened only after I restarted some managed servers in the WebLogic Domain.  In this article, we will describe what happened and how to fix it.

The Issue


The port in conflict was 9020.  As described in a companion article[1], you can use netstat command in Linux to investigate:
$ netstat -an |grep 9020

tcp  0  0 ::ffff:10.214.10.20:7101    ::ffff:10.214.10.20:9020    ESTABLISHED 
tcp  0  0 ::ffff:10.214.10.20:9020    ::ffff:10.214.10.20:7101    ESTABLISHED 

So, port 9020 was truly used by another process.  What happened is that we had many Fusion applications running on the same server and many sockets were created.  For a specific application, it requires to use port 9020 to listen and this port happened to be grabbed by another process dynamically.

In [1], we have documented a way to walk around port-conflict issue—by re-ordering start-up steps.  But, that cannot be guaranteed to work every time.  So, we will look at another approach in this article.

TCP Socket


It is the socket pair that specifies the two endpoints that uniquely identifies each TCP connection in an internet.  Note that an internet connection can use different transport protocols.  Here we only cover TCP connection.

For either local or remote endpoint, it is a combination of an IP address and a port number, much like one end of a telephone connection is the combination of a phone number and a particular extension. Based on this address, TCP sockets deliver incoming data packets to the appropriate application process or thread.

A process that opens a listen port will allow multiple sockets to that port. For example, when tnslsnr listens on port 1521, there will be many sockets where one port is 1521. So that port is shared; it can only be used for connections to that one particular process. The OS will never pick that port for the dynamic side of a connection, and any attempt by another process to listen on that port will fail because the address is in use.

The other port (picked by the OS) can not be shared; it will be used exclusively by the socket assigned to that port.  For the dynamic port, it will be picked up from the ip_local_port_range. For example, on our Linux server,  it was set to be from 9000 to 65500
$cat /proc/sys/net/ipv4/ip_local_port_range
9000    65500

The Solution


Port-conflict happened when a connection tried to pick  an available port (i.e., 9020) from the range (i.e., from 9000 to 65500).  In our case, it has picked 9020, which happened to be required by another managed server.

To prevent port conflicts from happening, we need to raise the lower limit of ip_local_port_range to be higher (say, 11000):
# echo "11000 65500" >/proc/sys/net/ipv4/ip_local_port_range

Note that you need to be the root user to make this change.  If you use Redhat edition, read [2] for more details.

As you can tell, after the ip_local_port_range change, the system tried to pick dynamic ports from 11000-to-65500 range when it connects to a remote socket (note that this remote endpoint happens to be on the same server):
$ netstat -an |grep 7101

tcp  0  0 ::ffff:10.214.10.20:7101   :::*                        LISTEN
tcp  0  0 ::ffff:10.214.10.20:7101   ::ffff:10.214.10.20:19739   ESTABLISHED
tcp  0  0 ::ffff:10.214.10.20:7101   ::ffff:10.214.10.20:20506   ESTABLISHED

Before we end this article, we also want to share two nice-to-know topics:
  • Privileged Ports
  • Which Port Is Configured for AdminServer or Managed Servers

Privileged Ports


The port numbers are divided into three ranges:
  • Well Known Ports: those from 0 through 1023.
  • Registered Ports: those from 1024 through 49151
  • Dynamic and/or Private Ports: those from 49152 through 65535
The TCP/IP port numbers below 1024 are special in that normal users are not allowed to run servers on them. This is a security feature, in that if you connect to a service on one of these ports you can be fairly sure that you have the real thing, and not a fake which some hacker has put up for you.

When you run a server as a test from a non-privileged account, you will normally test it on other ports, such as 2784, 5000, 8001 or 8080, not the well-known port (say, 80).

Which Port Is Configured for AdminServer or Managed Servers


If you are not sure about the port used by Weblogic server's Admin and Managed servers, you can verify it from the configuration file $DOMAIN_HOME/config/config.xml.   For example, port 9020 was reserved for our CRMAnalyticsServer_1:

<machine>slcaf977.us.oracle.com</machine>
    <listen-port>9020</listen-port>
    <cluster>CRMAnalyticsCluster</cluster>
    <web-server>
      <name>CRMAnalyticsServer_1</name>

References

  1. How to Investigate: Failed to Bind to Port on Linux
  2. The ip_local_port_range parameters (Redhat edition)
  3. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)

Wednesday, June 18, 2014

Cloning: Listener won't start after cloning

This article is a companion article to our previous cloning series:
As pointed out in the previous articles, there are limitations and issues with cloning (either of an application or a database). This article describes one of the new issues.

TNS-00525: Insufficient privilege for operation


After cloning our OATS server to a new server, we have seen the following listener error when we restarted OATS' database on the new server:

### Starting tns listener ###

LSNRCTL for Linux: Version 11.2.0.2.0 - Production on 10-JUN-2014 19:48:43
Copyright (c) 1991, 2010, Oracle.  All rights reserved.
Starting /scratch/aime1/app/aime1/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.2.0 - Production

System parameter file is /scratch/aime1/app/aime1/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /scratch/aime1/app/aime1/diag/tnslsnr/myOatsServer/listener/alert/log.xml

Error listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12555: TNS:permission denied
 TNS-12560: TNS:protocol adapter error
  TNS-00525: Insufficient privilege for operation
   Linux Error: 1: Operation not permitted

The Solution


After trying tool such as truss or strace on Linux, it didn't help much.  Then, I have found articles [3,4] which have helped me solve the issue:

bash-3.2$cd /var/tmp

bash-3.2$ ls -la .oracle
total 12
drwxrwxrwt 2 root   root 4096 Mar 17 11:38 .
drwxrwxrwt 3 root   root 4096 Jun 10 18:28 ..
srwxrwxrwx 1 oracle lock    0 Mar 17 11:38 s#16150.1
srwxrwxrwx 1 oracle lock    0 Mar 17 11:38 s#16150.2
srwxrwxrwx 1 oracle lock    0 Feb 24 10:17 s#32488.1
srwxrwxrwx 1 oracle lock    0 Feb 24 10:17 s#32488.2
srwxrwxrwx 1 oracle lock    0 Mar 17 11:38 sEXTPROC1521

As shown above, our new server has an existing folder named .oracle under /var/tmp, which was owned by a different user (i.e. oracle).  After we have backed up our original .oracle folder, we have changed the owner of /var/tmp/.oracle to be aime1 and removed the files within it.  After restarting our listener, here are the new files generated in it:

.oracle:

total 0
srwxrwxrwx 1 aime1 svrtech 0 Jun 18 07:50 s#30309.1
srwxrwxrwx 1 aime1 svrtech 0 Jun 18 07:50 s#30309.2
srwxrwxrwx 1 aime1 svrtech 0 Jun 18 07:50 sEXTPROC1521


References

  1. truss(1) equivalent in Linux ?
  2. 5 simple ways to troubleshoot using Strace
  3. Can't start listener for XE on Redhat Enterprise Linux 5.3 
  4. Listener not starting with TNS-00525: Insufficient privilege for operation
  5. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)

Saturday, February 2, 2013

Cloning Issue—IPv4 vs. IPv6

With two similarly cloned environments, one env works and another env fails. Both of them use /etc/hosts to redirect:
  • idm-db.us.oracle.com
to its own IP address[1]. However, when one of the WLS managed server tried to connect to its Admin Server using the following URL:
  • t3://[2606:a800:2010:4048:221:28ff:fefb:7756]:17001,
it failed.

In this article, we discuss how to trouble shoot and resolve this issue.

Log Messages[2]


WebLogic Server provides handlers for sending log messages to standard out, the server log file, broadcasting messages to the domain log, remote clients, and a memory buffer for tail viewing log events in the WebLogic Server Administration Console. You can achieve volume control for each type of handler by filtering log messages based on severity level and other criteria. The LogMBean, described in Oracle WebLogic Server MBean Reference[3], defines attributes for setting the severity level and specifying filter criteria for WebLogic Server handlers.

For example,  a Stdout Handler is provided in WLS—it sends stdout of the JVM in which a WebLogic Server instance runs to server terminal console.  WLS also provides a Stdout Filter which can be configured to filter log events being sent to the standard out.  By default, the Stdout Handler has a NOTICE threshold severity level. Therefore, INFO and DEBUG level messages are not sent to standard out.  There is also an attribute named RedirectStdoutToServerLogEnabled in LogMBean.  When enabled, this redirects the stdout of the JVM in which a WebLogic Server instance runs, to the WebLogic logging system.

For our case, the above-mentioned error message was found in the standard out which was redirected to a file when the WebLogic Server instance was started.

So, we need to figure out why the connection failed and why
  • [2606:a800:2010:4048:221:28ff:fefb:7756]
was referenced in the URL.  After some digging, we have found that [2606...] is the inet6 addr as shown below:

# /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:31:28:FB:88:56
          inet addr:xx.xxx.xx.xxx  Bcast:xx.xxx.xx.255  Mask:255.255.248.0
          inet6 addr: 2606:a800:2010:4048:221:28ff:fefb:7756/64 Scope:Global
          inet6 addr: fe80::521:25ff:fefb:7756/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:251183 errors:0 dropped:0 overruns:0 frame:0
          TX packets:150153 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:61626169 (58.7 MiB)  TX bytes:84744375 (80.8 MiB)
          Memory:df460000-df480000

Cloning Advantage


When you clone a system, you usually have a working system to clone from.  So, if your cloned system failed to start, you can compare the working and non-working systems side-by-side.  For our case, we have found that the system that fails have ipv6 enabled and the one works didn't.

So, the next step for us to take is to disable IPv6 protocol.  First, we have tried it from the JVM level.

Disabling the IPv6 Protocol at JVM Level


Two JVM options are provided in JRockit to enable and disable ipv6 addresses as below:
  • -Djava.net.preferIPv6Addresses=true (or false)
  • -DuseIPv6Address=true (or false)
However, when we tried the above tricks from the command line that started the WLS server instance, it didn't work.  Since we don't own the application (note that we use the application as a benchmark only), we cannot change coding to make it work with IPv6.  So, the next step is for us to disable IPv6 Protocol at kernel level.

Disabling the IPv6 Protocol at Kernel Level


We have followed the instructions described in [4-6] to disable IPv6 protocol at Linux kernel level.  There are two files we (as root) have edited by adding lines as shown below:

# vi /etc/modprobe.conf
alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1


#vi /etc/sysconfig/network
NETWORKING_IPV6=no

After saved and closed files, we rebooted the system. Finally, the above changes help us resolve the issue.  Be warned that your Linux platform (note that our OS is Redhat Linux) may need different configuration from the one described here.

References

  1. Simplify Cloning by Using Hosts File
  2. Configuring WebLogic Logging Services
  3. LogMBean
    • Configures the threshold severity level and filter settings for logging output.
  4. Networking IPv6 User Guide for J2SDK/JRE 1.4
  5. Linux: How To Disable The IPv6 Protocol
  6. RedHat / Centos Disable IPv6 Networking
  7. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  8. Oracle Products: What Patching, Migration, and Upgrade Mean?
  9. DNS and BIND, 5th edition, by Cricket Liu and Paul Albitz
    • What’s this fe80:: address?
      • These are link-local scoped addresses, derived automatically from the interfaces’ hardware addresses. The link-local scope is significant—you can’t access these addresses from anywhere but the local subnet, so don’t use them in delegation, masters substatements, and the like. 
  10. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.

Sunday, January 20, 2013

ORA-03113: end-of-file on communication channel

This article is a follow-up to the previous article:
As pointed out in that article, there are limitations and issues with cloning a database. This article describes one of the issues (see also [234]):
  • ORA-03113: end-of-file on communication channel

ORA-03113


When we tried to startup a cloned database, we saw the following message:

SQL> startup;
ORACLE instance started.

Total System Global Area 1.2827E+10 bytes
Fixed Size                  2240344 bytes
Variable Size            1811939496 bytes
Database Buffers         1.0972E+10 bytes
Redo Buffers               40890368 bytes
Database mounted.
ORA-03113: end-of-file on communication channel
Process ID: 9809
Session ID: 5339 Serial number: 3

It turns out that database has been mounted OK.  But, database failed when it was opened.

ALTER DATABASE OPEN Failed


Oerr is an Oracle utility that extracts error messages with suggested actions from the standard Oracle message files.  Here is the suggested actions from oerr:

$ oerr ORA 03113
03113, 00000, "end-of-file on communication channel"
// *Cause: The connection between Client and Server process was broken.
// *Action: There was a communication error that requires further investigation.
//          First, check for network problems and review the SQL*Net setup. 
//          Also, look in the alert.log file for any errors. Finally, test to 
//          see whether the server process is dead and whether a trace file
//          was generated at failure time.


One of the suggested action is to look in the alert.log file.  To find the location of alert.log, you do:
  1. Find the location of diagnostic destination from the initialization parameter file (i.e., dbs/init<sid>.ora ).  For example, we have this entry:
    • diagnostic_dest=/slot/fiz7865/log
  2. From there, you can find alert.log file in the following sub directory:
    • <diagnostic_dest>/diag/rdbms/<dbname>/<instname>/trace

In the alert_<sid>.log, we have found the following messages:

ALTER DATABASE OPEN
Errors in file /slot/fiz7865/log/diag/rdbms/fiz7865/fiz7865/trace/fiz7865_lgwr_9793.trc:
ORA-00338: log 2 of thread 1 is more recent than control file
ORA-00312: online log 2 thread 1: '/data1/rup3.redolog/log2.dbf'
Errors in file /slot/fiz7865/log/diag/rdbms/fiz7865/fiz7865/trace/fiz7865_lgwr_9793.trc:
ORA-00338: log 2 of thread 1 is more recent than control file
ORA-00312: online log 2 thread 1: '/data1/rup3.redolog/log2.dbf'
Errors in file /slot/fiz7865/log/diag/rdbms/fiz7865/fiz7865/trace/fiz7865_ora_9809.trc:
ORA-00338: log 1 of thread  is more recent than control file
ORA-00312: online log 2 thread 1: '/data1/rup3.redolog/log2.dbf'
USER (ospid: 9809): terminating the instance due to error 338

What Happened?


As stated in ORA-00338, our redo log file is more recent than control file.  This happened because we have cloned control files first and then cloned redo files only after we have found that they were missing.  Note that in between two cloning, we have also restarted our source database.  So, after we have synchronized the control files and the redo files, we were able to start up database successfully.  In the alert.log file, you should find the following messages:

ALTER DATABASE OPEN
Thread 1 opened at log sequence 371
  Current log# 2 seq# 371 mem# 0: /data1/rup3.redolog/log2.dbf
Successful open of redo thread 1

References

  1. Simplify Cloning by Using Hosts File
  2. ORA-00313: open failed for members of log group 1 of thread 1
  3. Using rsync to Clone Local and Remote Systems
  4. ORA-01031: insufficient privileges
  5. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  6. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.

Sunday, January 13, 2013

Cloning Issue—What If Host Name(s) Are Stored in the Database

This article is a follow-up to the previous article:
As pointed out in that article, there are limitations and issues with cloning—either an application or a database. This article describes one of the issues (see also [23, 4]): when host names are stored in the database tables.

Cloning


In [1], we have outlined the cloning tasks step by step.  In this article, we will discuss one of the cloning issues:
  • If host name(s) are stored in the database tables
To do cloning (see [3]), we need to duplicate a software installation from a source to a destination.  As described in [1], you can use /etc/hosts file to simplify the cloning task by redirecting host name resolution on Linux. However, if the host name is stored in the database table and not yet listed in the hosts file, your application can still fail.

In the following section, we will describe one use case that showcases this issue.

ADF Task Flow


A user would like to change the host name of a Redhat Linux which hosts SOASuite and WebCenter.  After following the approach as described in [1] using hosts file.  He found out that his workflow still wasn't working correctly.

When he opened a task, the browser tried to connect to:

and he has found that localhost.localdomain still pointed to the previous host.  Now the server doesn't know how to resolve this name and asks browsers to connect to that host.

After some diggings, he has finally identified that there is a setting in the WFTASKDISPLAY table of SOAINFRA schema, which still keeps the previous host name.  Presumably, when a task was deployed, previous host name was stored there and caused the malfunction of his ADF task flow.

To be honest, this is a case reported by another user.  So, I might have described it wrong.  However, it does point out a potential problem—if you have renamed a server and some other servers may not recognize that old name anymore because the old host name is stored in the database.  So, you need to change hosts file on those machines too to redirect the mapping of the old name to the new IP address.

References

  1. Simplify Cloning by Using Hosts File
  2. ORA-00313: open failed for members of log group 1 of thread 1
  3. Using rsync to Clone Local and Remote Systems
  4. ORA-01031: insufficient privileges
  5. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  6. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.



Wednesday, January 9, 2013

ORA-01031: insufficient privileges

This article is a follow-up to the previous article:
As pointed out in that article, there are limitations and issues with cloning (either an application or a database). This article describes one of the issues (see also [2, 3]) when you clone a database.

Cloning


In [1], we have outlined the cloning tasks step by step.  In this article, we will discuss:
  • How to resolve "ORA-01031: insufficient privileges"
  • What is config.c
To do cloning (see [3]), we need to duplicate a software installation from a source to a destination by preserving its path structure and as the same UNIX user (say "oracle").  However, the same UNIX user can have different effective group ID's in the source and destination servers and this can cause issue such as ORA-01031.

ORA-01031


When we invoked "sqlplus / as sysdba" from the cloned environment, we have seen:

ERROR:
ORA-01031: insufficient privileges


When you clone a database, there could be differences in UNIX user/group setup between source server and destination server.

For example, our source server has the following user/group settings for the sqlplus executable:

-rwxr-x--x 1 oracle oracle 9221 Dec  5 01:25 /export/home/oracle/atg/Oracle11gR2/product/11.2.0/dbhome_1/bin/sqlplus

but, our destination server has different user/group settings for it:

-rwxr-x--x 1 oracle oinstall 9221 Dec  5 01:25 /export/home/oracle/atg/Oracle11gR2/product/11.2.0/dbhome_1/bin/sqlplus

To look into this issue, you can  check the UNIX group ID defined for sqldba adminstrative access in:
  • $ORACLE_HOME/rdbms/lib/config.c

config.c


When you see the following error:
ORA-01031: insufficient privileges

you want to check config.c if your password file is ok and the group is correct for the Oracle account (i.e., "oracle").  This file tells you which UNIX group ID is assigned for sqldba administrative access by this Oracle Installation.


This is the content of config.c from source server:

/*  SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

/* IMPORTANT: this file needs to be in sync with
              rdbms/src/server/osds/config.c, specifically regarding the
              number of elements in the ss_dba_grp array.
 */

#define SS_DBA_GRP "oracle"
#define SS_OPER_GRP ""
#define SS_ASM_GRP ""

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};

However, this is the content of config.c from another working Oracle instance on destination server:

/*  SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access.  */
/*  Refer to the Installation and User's Guide for further information.  */

/* IMPORTANT: this file needs to be in sync with
              rdbms/src/server/osds/config.c, specifically regarding the
              number of elements in the ss_dba_grp array.
 */

#define SS_DBA_GRP "dba"
#define SS_OPER_GRP "oper"
#define SS_ASM_GRP ""

char *ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP};

From the differences, we know that our cloned Oracle binary expects "oracle"  UNIX group ID for sqldba adminstrative access.   However, our "oracle" UNIX user belongs to the following UNIX groups:

  • oinstall
  • dba
  • oper
but, not "oracle".

$id
uid=507(oracle) gid=507(oinstall) groups=507(oinstall),8500(dba),8501(oper)

Solution


One way to resolve this issue is to create a new group named "oracle" on our destination server.  So, we have created a new group named "oracle" and add our "oracle" user to the "oracle" group (as a "root" user):


#groupadd -g 8502 oracle
#usermod -G oinstall,dba,oper,oracle oracle


For more information, read [4, 5].

References

  1. Simplify Cloning by Using Hosts File
  2. ORA-00313: open failed for members of log group 1 of thread 1
  3. Using rsync to Clone Local and Remote Systems
  4. Thread: ORA-01031: insufficient privileges While trying / as sysdba
  5. Creating and Maintaining a Password File
  6. ORA-27101: shared memory realm does not exist tips
  7. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  8. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.

Tuesday, November 27, 2012

Using rsync to Clone Local and Remote Systems

This article is a follow-up from the previous article:
As pointed out in that article, there are limitations and issues with cloning (either an application or a database). This article describes one of the issues (see also [4]).

Cloning


In [1], we have outlined the cloning tasks step by step.  In this article, we will discuss:
  • How to use rsync utility to transfer and synchronize local and remote systems
  • How to deal with symbolic links
To do cloning, we need to duplicate a software installation from a source to a destination by preserving its path structure.

Symbolic Links


One of the challenges in cloning is that not everything is self-contained in a source tree.  Very often, symbolic links are also involved.  There are two types of symbolic links:
  1. Symbolic links point outwards from the source tree
  2. External symbolic links point towards the source tree
For the cloning, we use rsync utility to do the job. Here are the options that we have used:
  • rsync -az
This command can copy the first type of links appropriately while it cannot handle the second type of links.  That means you need to create extra symbolic links in the destination after the cloning.  So, one of the pre-cloning tasks is to list all symbolic links and their locations in the source.[2]

Why It Happened?


Why the second type of symbolic links exist in the first place?  It depends on each application and the way cloning was done previously.  In our benchmark cloning, we usually clone one environment to multiple destinations in a chain.  For example, someone has set up a good benchmark on machine A.  Then we clone that to machine B followed by cloning it from machine B to C, etc.

On machine B, we often find there is a need to distribute resources on different file systems for load balancing. Because of that, new symbolic links were introduced. Then, when we clone the installation from machine B to C, we will find both types of symbolic links existing in the source.

Rsync Command[3]


One way of copying a directory is using rsync.  The rsync utility has an archive switch -a that allows it to perform a copy of a directory that includes dot files while maintaining all permissions, ownership, and modification times. However, the destination soft links have the modification time of when the copy was performed, but that shouldn't matter much.

When using the following commands, there is a very subtle syntax difference between the two (i.e., the trailing slash), which ends up with quite different results:
  • rsync -az /src/dir/ /dest/dir
    • The contents of /src/dir will be copied to /dest/dir
  • rsync -az /src/dir /dest/dir
    • The directory itself will be copied into /dest/dir. In other words, you’ll end up with /dest/dir/dir

In the command, we have also include a compression switch -z which can be used in the remote transfer to reduce network traffic.

To enable remote transfer, you append "<userLogin>@<serverName>:" to either src or dest path. For example,

  • rsync -az oracle@otherserver:/data/home/oracle/atg/OracleDB_11.2.0.2 /data/home/oracle/atg

will copy the directory named OracleDB_11.2.0.2 from a remote server into /data/home/oracle/atg.

References

  1. Simplify Cloning by Using Hosts File
  2. List symbolic links and location, pointing to a particular directory
  3. Expert Shell Scripting
  4. ORA-00313: open failed for members of log group 1 of thread 1
  5. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  6. To check if the symbolic links are broken in the target system, do:
    • find . -type l -! -exec test -e {} \; -print
  7. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.

Wednesday, November 14, 2012

ORA-00313: open failed for members of log group 1 of thread 1

This article is a follow-up to the previous article:
As pointed out in that article, there are limitations and issues with cloning (either an application or a database). This article describes one of the issues.

ORA-00313


After following the cloning steps as described in [1], we have run into this Oracle database exception when trying to bring up our cloned Oracle.  Obviously, this is our fault because we have not done a thorough planning before the cloning.

What this exception tells us is:
  • The online log cannot be opened.

What Is the Redo Log?


The most crucial structure for Oracle recovery operations is the redo log, which consists of two or more preallocated files that store all changes made to the database as they occur. Every instance of an Oracle Database has an associated redo log to protect the database in case of an instance failure.

Where Did We Find This ORA-00313?


From the initialization parameter file (i.e., dbs/init<sid>.ora ) , we have traced down the location of diagnostic destination[3]:
  • diagnostic_dest=/slot/fiz7865/log
From there, we went down to a folder named:
  • <diagnostic_dest>/diag/rdbms/<dbname>/<instname>/trace
In there, there is a file named:
  • alert_fiz7865.log
From that file, we have found the following entries:
  Lost write protection disabled
  Completed: ALTER DATABASE   MOUNT
  Wed Nov 14 09:42:55 2012
  ALTER DATABASE OPEN
  Errors in file <diagnostic_dest>/diag/rdbms/<dbname>/<instname>/trace/fiz7865_lgwr_25410.trc:
  ORA-00313: open failed for members of log group 1 of thread 1
  ORA-00312: online log 1 thread 1: '/data1/rup3.redolog/log3.dbf'

Note that Oracle will write the alert_<instname>.log file to the directory as specified by the BACKGROUND_DUMP_DEST parameter[4]. So, you can also find out its location by:
SQL> show parameter BACKGROUND_DUMP_DEST

NAME                   TYPE        VALUE
---------------------- ----------- ------------------------------
background_dump_dest   string     /slot/fiz7865/log/diag/rdbms/fiz7865/fiz7865/trace

What Happened?


When we do the cloning, not everything is contained in a single source directory.  For example, redo log files have been reallocated to another file system (i.e., /data1) which is outside the source directory.  For the Oracle to be fully functional, original redo logs need to be reopened.  If they are not found, an ORA-00313 will be thrown.

How to Find the Redo Log Location


Before you do the cloning, keep the source database up and running.  Then query the logfile location by:
  • select * from V$LOGFILE;

References

  1. Simplify Cloning by Using Hosts File
  2. Managing the Redo Log
  3. DIAGNOSTIC_DEST
  4. Alert Log
  5. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  6. Oracle Products: What Patching, Migration, and Upgrade Mean?

Wednesday, November 7, 2012

Simplify Cloning by Using Hosts File

Oftentimes, you will find there is a need to install a same application on different systems.  In our case, we have a multi-tier setup for benchmark:
  • Oracle Application Testing Suite (OATS)
  • Application Server
  • Database Server
This means that individual server need to communicate with other servers using their domain names.

In this article, we will discuss the simplest way of cloning an application from one environment to another.

Hosts File


The hosts file allows you to define which domain names (websites) are linked to which IP addresses. On some platforms, it takes precedence over your DNS servers.  However, the hosts file is under the direct control of the local computer's administrator unlike the DNS. So your DNS servers may say oracle.com is linked to a specific IP address, but you can have oracle.com go anywhere you want by using hosts file.

In Microsoft Windows, hosts file is located at locations depending on your OS.  For example, for NT, 2000, XP (x86 & x64), 2003, Vista, 7and 8, it is located at:
  • %SystemRoot%\system32\drivers\etc\hosts
    • Need to have write permission on this file for the editing user
In Linux, hosts file is located at:
  • /etc/hosts
Hosts file is a plain text file and you can use any text editor to modify it as long as you are given the permission. After modification, it will take effect immediately without rebooting. So, you can restart your application to see the new changes right away.

Redirection


In its function of resolving host names, the hosts file may be used to define any host name or domain name for use in the local system. This may be used either beneficially or maliciously for various effects.  In this article, we will discuss using the mapping to redirect a website (i.e., source of cloning) to another website (i.e., destination of cloning) during the cloning of a multi-tier environment.  Because our multi-tier environment exists in a private network, there is no security concern for us.  However, it is possible for you to face serious security attacks if your hosts file is compromised[3].

As we all know, to deploy and configure any web application is a non trivial task.  As performance engineers, we often need to create similar systems on different set of servers.  Instead of  deploying and configuring web applications from scratch, it will be easier to just do the cloning.

After cloning the application from one system to another, you then need to fix platform-specific part in the cloned image.  For example, you need to change the domain names referenced in the URLs from old server's to new server's.  Domain names can also be embedded in configuration files, scripts, etc.  Either you can do a global search and replace them or you can modify hosts file to map same host names to the new IP addresses.  The latter is easier.

Cloning[4]


Cloning can be done in three stages and the most important stage is the preparation or pre-cloning.  In the following, we cover the tasks involved in these stages for Linux platforms.  For Windows, the steps are similar.
  • Pre-cloning Stage
    • nohup
      • Cloning can take hours to finish.  
        • If you use "putty" to access Linux box, remember to use "nohup" command
          • nohup is used to run a command that is immune to hangups
          • For example, you can prefix your cloning command with nohup and redirect the stderr and stdout to cloning.out file:
            • nohup {cloning command} &> cloning.out &
    • Be the right user that has the privilege to do the cloning.  
      • Sometimes, you may need to be the "root" user to do the cloning.  After the cloning, you can then reduce the accessibility to the correct level.
    • Create the same path structure on the destination as source's
      • Create symbolic links if needed
        • You may need to be root user to create the path.  But, reduce the accessibility to the correct level later.
    • Find the file system (or disk) that is big enough to hold the cloned image
      • Free space left should allow application data to grow after it starts running
    • Hosts file
      • Save the original hosts file
    • Shutdown server instances before cloning
  • Cloning Stage
    • Copy everthing needed from source machine to destination machine.  This can include
      • Server installation
      • Scripts
      • hosts file
        • Copy the new hosts file from source to destination machine and make appropriate changes
        • Validate the changes.  For example, you can use ping command to test 
    • Use rsync command to clone
      • Syntax:
        • rsync -az aroot@sourceServer:/export/home/bench/ATG/RUP3 /export/home/bench/ATG/
      • Don't forget to use nohup for the rsync
      • Try the command out with a small copy first
      • Be patient—the cloning could take hours
  • Post-cloning Stage
    • Verify that your cloned environment work as expected
      • You can test this by stages.  For example, you can
        1. Run your front end (or OATS) against original Application Server and Database Server first.  After verifying that your front end system is working correctly, move to next.
        2. Run your application server against original Databasse Server. After verifying that your middle tier is working correctly, move to next.
        3. Verifying your database server is working correctly.
        4. Run your application server against your new database server.
        5. And so on.
    • Document what you have done

Warning


Cloning applications seems to be straightforward.  But, there are limitations and caveats. You can read [5,6,9,10] for such details.  If you are cloning Oracle Fusion Middleware, read [7].  If you are moving from a test to a production environment, read [8].  Finally, you must pay attention to the license-violations-and-compliance issue when you plan a cloning.

References

  1. Oracle Application Testing Suite
  2. 6 Surprising Uses For The Windows Hosts File
  3. Hosts (Wikipedia)
  4. Cloning Application Server Middle-Tier Instances
  5. General Considerations and Limitations for Cloning
  6. ORA-00313: open failed for members of log group 1 of thread 1
  7. Cloning Oracle Fusion Middleware (Chapter 20)
  8. Moving from a Test to a Production Environment (Chapter 21)
  9. Cloning Issue—What If Host Name(s) Are Stored in the Database
  10. ORA-01031: insufficient privileges
  11. Migrating Oracle B2B from Test to Production (T2P) (Chap 10 of the Book "Getting Started with Oracle SOA B2B Integration: A Hands-On Tutorial")
    • This section provides a real-world scenario to replicate (clone) the test environment to production for Oracle SOA.
    • Oracle Fusion Middleware provides a series of scripts for this task.
  12. Oracle Products: What Patching, Migration, and Upgrade Mean? (Xml and More)
    • For your Oracle production systems, follow official recommendations as shown in this article.

© Travel for Life Guide. All Rights Reserved.

Analytical Insights on Health, Culture, and Security.