Category Archives: Linux

After change hostname ASM did not start

On my test environment i changed hostname of Linux machine and after restart ASM did not start.
environment:

OS : Oracle Linux 6.5
DB : Oracle database 11g(11.2.0.3)

so let’s simulate changing hostname and see results:

[root@oel6 ~]# hostname
oel6
[root@oel6 ~]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=testdb
[root@oel6 ~]# vi /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.220.128 testdb

[root@oel6 ~]# reboot

our hostname changed after restart we can check it and try to start ASM instance.
old hostname — oel6 new hostname — testdb

[root@testdb ~]# hostname
testdb
su - grid
-bash-4.1$ srvctl start asm
PRCR-1070 : Failed to check if resource ora.asm is registered
Cannot communicate with crsd

sqlplus / as sysasm

SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 2 14:05:38 2015

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup;
ORA-01078: failure in processing system parameters
ORA-29701: unable to connect to Cluster Synchronization Service

Solution:
ok, ASM will not start because we need to reconfigure HAS(High Availability Service).
with root user go to $GRID_HOME/crs/install and run roothas.pl script for deconfiguration.

cd /u01/app/grid/product/11.2.0/grid/crs/install/
./roothas.pl -deconfig -force

Using configuration parameter file: ./crsconfig_params
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Stop failed, or completed with errors.
CRS-4639: Could not contact Oracle High Availability Services
CRS-4000: Command Delete failed, or completed with errors.
CLSU-00100: Operating System function: opendir failed with error data: 2
CLSU-00101: Operating System error message: No such file or directory
CLSU-00103: error location: scrsearch1
CLSU-00104: additional error information: cant open scr home dir scls_scr_getval
CRS-4544: Unable to connect to OHAS
CRS-4000: Command Stop failed, or completed with errors.
Successfully deconfigured Oracle Restart stack

with root user go to $GRID_HOME/crs/install directory and run the roothas.pl script for reconfiguration

./roothas.pl

Using configuration parameter file: ./crsconfig_params
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node testdb successfully pinned.
Adding Clusterware entries to upstart

testdb     2015/04/02 14:29:27     /u01/app/grid/product/11.2.0/grid/cdata/testdb/backup_20150402_142927.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server

with grid user Register and start the resources

crsctl start resource ora.cssd
CRS-2672: Attempting to start 'ora.cssd' on 'testdb'
CRS-2672: Attempting to start 'ora.diskmon' on 'testdb'
CRS-2676: Start of 'ora.diskmon' on 'testdb' succeeded
CRS-2676: Start of 'ora.cssd' on 'testdb' succeeded

now we can add the listener as a resource and after that we can start it

srvctl add listener -l LISTENER
srvctl start listener
srvctl status listener
Listener LISTENER is enabled
Listener LISTENER is running on node(s): testdb

now we can add the asm we do not need to create spfile for asm. we can use the one before.
if you haven’t spfile you can simple create pfile and then create spfile from this pfile for example create pfile – init+ASM.ora in $GRID_HOME/dbs with parameters:

instance_type=ASM
asm_diskstring='/dev/oracleasm/disks/DATA01'
asm_diskgroups='DG01'

sqlplus / as sysasm
SQL> startup pfile=init+ASM.ora;
SQL> create spfile='+DG01' from pfile='init+ASM.ora';
SQL> shutdown immediate;

with grid user

srvctl add asm -l LISTENER -p "/u01/app/grid/product/11.2.0/grid/dbs/init+ASM.ora"
srvctl start asm
srvctl status asm
ASM is running on testdb

at last we can add database

srvctl add database -d testdb -o /u01/app/oracle/product/11.2.0/dbhome_1 -p +DG01/spfiletestdb.ora -r PRIMARY -s open -t immediate -a "DG01"
srvctl start database -d testdb
srvctl status database -d testdb
Database is running.

that’s all, now we have new hostname and asm is up and running.

srvctl status asm
ASM is running on testdb

Enterprise Manager – perl: warning: Setting locale failed, LC_ALL = (unset)

today we faced warnings when starting agent of enterprise manager grid control.

emctl start agent

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = "en_GB:en",
	LC_ALL = (unset),
	LANG = "en_GB"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

check your locale settings by type locale
solution is very simple in the .bash_profile add LC_ALL=”en_GB.utf8″ :

locale
.........
.........
vi .bash_profile
export LC_ALL="en_GB.utf8"

Configure FTP server on Linux and create user to access only his home directory

Now i’ll show you how to configure ftp server on oracle linux 5.5 and create user, which can access only his home directory for using ftp, let start.
first we need to install rpm package which is on linux disc. you can mount disk and install package
vsftpd-2.0.5-16.el5_4.1 with command:

rpm -Uvh vsftpd-2.0.5-16.el5_4.1.rpm

after that we need to start ftp server with command:

service vsftpd start

now our ftp server is running.
let’s create user ftpdump which can access only his home directory for file transfer.

mkdir -p /ftp
groupadd ftpdump
useradd –s /bin/bash –d /ftp –g ftpdump ftpdump
passwd ftpdump
chown -R ftpdump:ftpdump /ftp
chmod -R 777 /ftp 

for limit user ftpdump to access only his home directory open vsftpd.conf and add next parameters:

vi /etc/vsftpd/vsftpd.conf

chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot.list

Then add each user you want to lock to their home directory to the chroot.
I want that ftpdump user access only his home dir, hence i added it in chroot.list

vi /etc/vsftpd/chroot.list

ftpdump

now we can make test, connect ftp with user ftpdump and try to change directory.

C:\Users\user>ftp #.#.#.#
Connected to #.#.#.#.
220 (vsFTPd 2.0.5)
User (#.#.#.#:(none)): ftpdump
331 Please specify the password.
Password:
230 Login successful.
ftp> pwd
257 "/"
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
test.t
226 Directory send OK.
ftp: 111 bytes received in 0.00Seconds 111000.00Kbytes/sec.
ftp> pwd
257 "/"
ftp> cd /u01
550 Failed to change directory.
ftp>

that’s all, good luck.

Duplicate database from ASM to non ASM Database using RMAN

Operating system — Oracle Linux 6
Database — 11G R2
Today i show you how to duplicate database which is in ASM to non ASM on different host.
Target — database with ASM which is used to create another database on another host.
Destination — database which located on file system will be created from target.

For duplication there is two method: from backup and from active database, here is described active database duplication.

On destination already installed Oracle Software.
1) transfer password file from target to destination.
2) on destination register listener with static registration.
3) on Target, create pfile, transfer it to destination host and modify next parameters:

*.audit_file_dest =/u01/app/oracle/testdup/adump
*.db_name ="testdup"
*.instance_name =testdup
*.control_files =/u01/app/oracle/testdup/control01.ctl
*.db_file_name_convert =("+DATA","/u01/app/oracle/testdup")
*.log_file_name_convert =("+DATA","/u01/app/oracle/testdup")
*.undo_management =AUTO
*.undo_tablespace='UNDOTBS1'
*.db_block_size=8192

4) on destination, create corresponding directories with oracle O/S user.
5) export new sid and start instance;

export ORACLE_SID=testdup
sqlplus / as sysdba
startup nomount pfile=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/inittestdup.ora;

6) on destination:

rman target sys/password@orcl auxiliary sys/password@testdup
duplicate database to testdup from active database;

Possible Errors:
You can get some errors , cann’t restore datafile & onlineredo log files, in this case you need to create directory ,It should be indicate.

testdup/datafile
testdup/onlinelog

That’s all, good luck.

Automatically start oracle database on linux after server reboot

Here i show you how to configure system for automatically start oracle database after server reboot.
oracle database 11g — Oracle Linux 6.3
First of all, you need to make sure that any database instances you want to auto start are set to “Y” in the /etc/oratab file

#
# This file is used by ORACLE utilities.  It is created by root.sh
# and updated by either Database Configuration Assistant while creating
# a database or ASM Configuration Assistant while creating ASM instance.

# A colon, ':', is used as the field terminator.  A new line terminates
# the entry.  Lines beginning with a pound sign, '#', are comments.
#
# Entries are of the form:
#   $ORACLE_SID:$ORACLE_HOME::
#
# The first and second fields are the system identifier and home
# directory of the database respectively.  The third filed indicates
# to the dbstart utility that the database should , "Y", or should not,
# "N", be brought up at system boot time.
#
# Multiple entries with the same $ORACLE_SID are not allowed.
#
#
orcl:/u0/app/oracle/product/11.2.0/dbhome_1:Y

Oracle 11g includes 2 scripts which can be used to start or shut down Oracle databases on Linux. Both scripts are in $ORACLE_HOME/bin and called dbstart and dbshut. We can add some more actions for example start enterprise manager if we create our scripts. Let’s make two scripts db_start.sh and db_stop.sh
vi /u0/app/oracle/db_start.sh

# script to start the Oracle database, listener and dbconsole
. ~/.bash_profile
# start the listener and the database
$ORACLE_HOME/bin/dbstart $ORACLE_HOME
# start the Enterprise Manager db console
$ORACLE_HOME/bin/emctl start dbconsole
exit 0

vi /u0/app/oracle/db_stop.sh

# script to stop the Oracle database, listener and dbconsole
. ~/.bash_profile
# stop the Enterprise Manager db console
$ORACLE_HOME/bin/emctl stop dbconsole
# stop the listener and the database
$ORACLE_HOME/bin/dbshut $ORACLE_HOME
exit 0

inside script we are calling the .bash_profile file of the user “oracle” for export environment variables, we need it for $ORACLE_HOME.
give execute right:
chmod u+x db_start.sh db_stop.sh
With user root, create a file called “oracle” under /etc/init.d
vi /etc/init.d/oracle

ORA_OWNER=oracle
RETVAL=0
 
case "$1" in
    'start')
        # Start the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/db_start.sh"
        touch /var/lock/subsys/oracle
        ;;
    'stop')
        # Stop the Oracle databases:
        su - $ORA_OWNER -c "/u0/app/oracle/db_stop.sh"
        rm -f /var/lock/subsys/oracle
        ;;
    *)
        echo $"Usage: $0 {start|stop}"
        RETVAL=1
esac
exit $RETVAL

change permission for /etc/init.d/oracle file:
chmod 750 /etc/init.d/oracle
to create service of this script:

chkconfig --add oracle

and now we can start and stop database with:

service oracle stop
service oracle stop

Now it’s time to test our automatically startup procedure, for this reboot your server and check if your database starts automatically after reboot.

Xlib: No protocol specified

It can be frustrating when you try to start xwindow application using Xming XServer on Windows XP/7/Vista but encountering connection refused error. Here is an example of the error:

[oracle@oel5 /]$ dbca
Xlib: connection to "192.168.0.100:0.0" refused by server
Xlib: No protocol specified

Here is a quick tip to fix this issue:
In Windows, look for the shortcut to start Xming. Right click your mouse to go to properties.
add -ac to your XMing shortcut:

"C:\Program Files (x86)\Xming\Xming.exe" :0 -clipboard -multiwindow -ac

The -ac parameter allows everyone to connect.
restart Xming and try again.

Change network device name from eth1 back to eth0 in RHEL6

The interface name of a network device increases if the mac address of the physical or virtual network card changes. A common case is if you made a clone of a virtual machine for example via VMware or replaced a physical network card in a non virtualized server.

If it’s a RHEL 6 machine you need to change 2 files to rename the interface for example from eth1 back to eth0.

One file is the udev rule for network devices which is located here:

    /etc/udev/rules.d/70-persistent-net.rules

Copy the new mac address to the line of your eth0 rule and delete the new rule for eth1.

    # PCI device 0x15ad:0x07b0 (vmxnet3)
    SUBSYSTEM==”net”, ACTION==”add”, DRIVERS==”?*”, ATTR{address}==”00:50:56:b2:23:e0″, ATTR{type}==”1″, KERNEL==”eth*”, NAME=”eth0″

Modify the network configuration located under:

    /etc/sysconfig/network-scripts/ifcfg-eth0

and replace the old ip with the new one and the old mac address with the new mac address, after that restart network service.

# service network restart

To be sure everything works fine reboot your machine.

How to Change the Hostname of a Linux System

Normally we will set the hostname of a system during the installation process. but if we need to change hostname what can we do?

On any Linux system you can change its hostname with the command
hostname new_name.

[oracle@oel6 ~]$ hostname
oel6
[oracle@oel6 ~]$ hostname aaa
hostname: you must be root to change the host name
[oracle@oel6 ~]$ su - 
Password: 
[root@oel6 ~]# hostname aaa
[root@oel6 ~]# hostname
aaa

This new name will be until the system rebooted. To permanent change in Red Hat base systems we need to change hostname in /etc/sysconfig/network file.

[root@oel6 ~]# vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=oel6

and change hostname in file.

that’s all.

Bug: /dev/shm does not use /etc/fstab attributes after reboot in RHEL 6

There is a bug in Red Hat Linux 6 and Oracle Enterprise Linux 6 (UEK and RHEL-kernel).
When you need more memory for SGA/PGA when using MEMORY_MAX_TARGET, you need to resize /dev/shm. By default this is 50% of total memory and Oracle tells you to add the following to /etc/fstab:

tmpfs    /dev/shm     tmpfs   defaults,size=3G  0 0

This works after a remount:

mount -o remount /dev/shm

but it doesn’t work after a reboot.
Fix:
add

mount -o remount /dev/shm

in /etc/rc.d/rc.sysinit file and /dev/shm has attributes from /etc/fstab after reboot.