Oracle Restart – Changing Hostname

Posted on Posted in Oracle, Oracle DB

Welcome to another Sysadmin & DBA Tips, in this post I’ll explain how change the hostname of your cloned Oracle 11.2 VMs thats running on ASM with Oracle Restart.

Pre-Tasks

Before start with the Oracle Restart process you must stop the listener:

[root@DB ~]# crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    DB 
ora.FRA.dg     ora....up.type ONLINE    ONLINE    DB 
ora....ER.lsnr ora....er.type ONLINE    ONLINE    DB
ora.asm        ora.asm.type   ONLINE    ONLINE    DB
ora....stro.db ora....se.type OFFLINE   OFFLINE               
ora.cssd       ora.cssd.type  ONLINE    ONLINE    DB
ora.db11g.db   ora....se.type ONLINE    OFFLINE               
ora.diskmon    ora....on.type ONLINE    ONLINE    DB
[root@DB ~]# lsnrctl stop listener

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 17-APR-2013 22:44:16

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
[root@DB ~]# crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.DATA.dg    ora....up.type ONLINE    ONLINE    DB
ora.FRA.dg     ora....up.type ONLINE    ONLINE    DB
ora....ER.lsnr ora....er.type OFFLINE   OFFLINE               
ora.asm        ora.asm.type   ONLINE    ONLINE    DB
ora....stro.db ora....se.type OFFLINE   OFFLINE               
ora.cssd       ora.cssd.type  ONLINE    ONLINE    DB
ora.db11g.db   ora....se.type ONLINE    OFFLINE               
ora.diskmon    ora....on.type ONLINE    ONLINE    DB

Remove Configuration

Remove the existing configuration calling Oracle Restart as root (with ORACLE_HOME set to the grid home), set GRID environment:

[root@DB ~]# . /home/oracle/bin/oraASM.env 
=====================================================
           XX     XXXXX  XX   XX
            X    X     X  X   X
    X       X    X        XX XX
    X      X X   X        XX XX
    X      X X    XXXXX   X X X
 XXXXXXX  X   X        X  X X X
    X     XXXXX        X  X   X
    X     X   X  X     X  X   X
    X    XXX XXX  XXXXX  XXX XXX
=====================================================
ORACLE_HOME=/u01/app/11.2.0.2/grid
ORACLE_SID=+ASM
=====================================================
[root@DB ~]# $ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/perl/lib -I $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl -delete
2013-04-17 22:44:26: Checking for super user privileges
2013-04-17 22:44:26: User has super user privileges
2013-04-17 22:44:26: Parsing the host name
Using configuration parameter file: /u01/app/11.2.0.2/grid/crs/install/crsconfig_params
CRS resources for listeners are still configured
CRS-2529: Unable to act on 'ora.cssd' because that would require stopping or relocating 'ora.asm', but the force option was not specified
CRS-4000: Command Stop failed, or completed with errors.
CRS-2586: Deletion of a running resource 'ora.cssd' requires the force option
CRS-4000: Command Delete failed, or completed with errors.
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'DB'
CRS-2673: Attempting to stop 'ora.DATA.dg' on 'DB'
CRS-2673: Attempting to stop 'ora.FRA.dg' on 'DB'
CRS-2677: Stop of 'ora.DATA.dg' on 'DB' succeeded
CRS-2677: Stop of 'ora.FRA.dg' on 'DB' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'DB'
CRS-2677: Stop of 'ora.asm' on 'DB' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'DB'
CRS-2677: Stop of 'ora.cssd' on 'DB' succeeded
CRS-2673: Attempting to stop 'ora.diskmon' on 'DB'
CRS-2677: Stop of 'ora.diskmon' on 'DB' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'DB' has completed
CRS-4133: Oracle High Availability Services has been stopped.

Successfully deconfigured Oracle Restart stack

Change Hostname

It’s the moment to change the hostname of your Server

/etc/sysconfig/network

Edit this file and set the new name

cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=DB-DES

/etc/hosts

Update /etc/hosts as appropriate

cat /etc/hosts
127.0.0.1   	localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         	localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.50.4    DB-DES DB-DES.albertolarripa.com

ifcfg-ethX

Change the IP address

[root@DB ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 
DEVICE="eth0"
HWADDR="00:1F:4C:02:A3:02"
ONBOOT="yes"
IPADDR=192.168.50.4
NETMASK=255.255.255.0
GATEWAY=192.168.50.1

listener.ora

Change the hostname in the listener configuration file

cat $ORACLE_HOME/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/11.2.0.2/grid/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = DB-DES.albertolarripa.com)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON              # line added by Agent

Reboot to pickup the changes

Recreate the Configuration

After change the HOSTNAME and Restart the configuration is the moment to re-configure your Grid and Oracle installations.

GRID

Call Oracle Restart as root (with ORACLE_HOME set to the grid home) to configure your GRID installation, set GRID environment:

[root@DB-DES ~]# . /home/oracle/bin/oraASM.env 
=====================================================
           XX     XXXXX  XX   XX
            X    X     X  X   X
    X       X    X        XX XX
    X      X X   X        XX XX
    X      X X    XXXXX   X X X
 XXXXXXX  X   X        X  X X X
    X     XXXXX        X  X   X
    X     X   X  X     X  X   X
    X    XXX XXX  XXXXX  XXX XXX
=====================================================
ORACLE_HOME=/u01/app/11.2.0.2/grid
ORACLE_SID=+ASM
=====================================================
[root@DB-DES ~]# $ORACLE_HOME/perl/bin/perl -I $ORACLE_HOME/perl/lib -I $ORACLE_HOME/crs/install $ORACLE_HOME/crs/install/roothas.pl
2013-04-17 22:48:56: Checking for super user privileges
2013-04-17 22:48:56: User has super user privileges
2013-04-17 22:48:56: Parsing the host name
Using configuration parameter file: /u01/app/11.2.0.2/grid/crs/install/crsconfig_params
LOCAL ADD MODE 
Creating OCR keys for user 'oracle', privgrp 'oinstall'..
Operation successful.
CRS-4664: Node DB-DES successfully pinned.
Adding daemon to inittab
CRS-4123: Oracle High Availability Services has been started.
ohasd is starting

DB-DES     2013/04/17 22:49:15     /u01/app/11.2.0.2/grid/cdata/basedatosregistro-des/backup_20130417_224915.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server

Listener,ASM,DB,Services

Exit from root user and log-on as oracle (with ORACLE_HOME set to the grid home) add the listener, ASM, database and services into the Oracle Restart configuration.

[oracle@DB-DES ~]$ . oraASM.env
=====================================================
           XX     XXXXX  XX   XX
            X    X     X  X   X
    X       X    X        XX XX
    X      X X   X        XX XX
    X      X X    XXXXX   X X X
 XXXXXXX  X   X        X  X X X
    X     XXXXX        X  X   X
    X     X   X  X     X  X   X
    X    XXX XXX  XXXXX  XXX XXX
=====================================================
ORACLE_HOME=/u01/app/11.2.0.2/grid
ORACLE_SID=+ASM
=====================================================

LISTENER

Add the listener and start it

[oracle@DB-DES ~]$ srvctl add listener
[oracle@DB-DES ~]$ srvctl start listener

ASM diskgroups

The ASM diskgroups (+DATA & +FRA) are not automatically added back to the Oracle Restart configuration add the candidate disks and start ASM:

[oracle@DB-DES ~]$ srvctl add asm -d '/dev/sd[a-h]1'
[oracle@DB-DES ~]$ srvctl start asm

As you can see no diskgroups are added

[oracle@DB-DES ~]$ asmcmd lsdg

You must add it manually:

[oracle@DB-DES ~]$ sqlplus /nolog
SQL> conn / as sysasm
SQL> alter diskgroup data mount;
SQL> alter diskgroup fra mount;
SQL> exit

As shown by the output of srvctl status below, the diskgroup +DATA & +FRA is running on DB-DES

[oracle@DB-DES ~]$ srvctl status diskgroup -g data
Disk Group data is running on DB-DES

[oracle@DB-DES ~]$ srvctl status diskgroup -g fra
Disk Group fra is running on DB-DES
[oracle@DB-DES ~]$ asmcmd lsdg
State    Type    Rebal  Sector  Block       AU  Total_MB  Free_MB  Req_mir_free_MB  Usable_file_MB  Offline_disks  Voting_files  Name
MOUNTED  EXTERN  N         512   4096  1048576     30718    27014                0           27014              0             N  DATA/
MOUNTED  EXTERN  N         512   4096  1048576     30718    25474                0           25474              0             N  FRA/

Database

Add the database to Oracle Restart, and configure:

[oracle@DB-DES ~]$ srvctl add database -d DB11G -o $ORACLE_HOME -n DB11G -p +DATA/DB-DES/spfileDB11G.ora -a DATA,FRA
[oracle@DB-DES ~]$ srvctl config database -d DB11G
Database unique name: DB11G
Database name: DB11G
Oracle home: /u01/app/11.2.0.2/grid
Oracle user: oracle
Spfile: +DATA/DB-DES/spfileDB11G.ora
Domain: 
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Disk Groups: DATA,FRA
Services:

Finally start your Database:

[oracle@DB-DES ~]$ srvctl start database -d DB11G

Leave a Reply

Your email address will not be published. Required fields are marked *