Golden Gate:-
A) Setting up Unidirectional replication - Initial Load
Secnario 1)
Replicating between two database on the same host.
Source db - test11
Target db - layatest
HostNam - rhel.manzoor.com
Steps :-
------
a) Go to OTN http://edelivery.oracle.com
b) Select Oracle Fusion Middleware and select the platform accordinfly.
c) Download the latest version of GG software.
d) ftp, winscp the gg software to the linux machine.
e) Create a gg home directory
$ mkdir -p /u01/oracle/product/11.2.0/gg
d) Add the below environment variables in .bash_profile.
$ vi .bash_profile
export ORACLE_GG=/u01/oracle/product/11.2.0/gg
export PATH=$ORACLE_HOME/bin:$ORACLE_GG:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_GG
e) Copy the gg software to gg home and unzip the file and then untar the file
$ tar -xvf fbo_ggs_Linux_x86_ora11g_32bit.tar
f) Connect to golden gate command line interface and create the necessary directories.
[oracle@rhel u01] cd $ORALE_GG
[oracle@rhel gg]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.2.1.0.1 OGGCORE_11.2.1.0.1_PLATFORMS_120423.0230_FBO
Linux, x86, 32bit (optimized), Oracle 11g on Apr 23 2012 08:09:25
Copyright (C) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
GGSCI (rhel.manzoor.com) 2> CREATE SUBDIRS
Creating subdirectories under current directory /u01/oracle/product/11.2.0/gg
Parameter files /u01/oracle/product/11.2.0/gg/dirprm: created
Report files /u01/oracle/product/11.2.0/gg/dirrpt: created
Checkpoint files /u01/oracle/product/11.2.0/gg/dirchk: created
Process status files /u01/oracle/product/11.2.0/gg/dirpcs: created
SQL script files /u01/oracle/product/11.2.0/gg/dirsql: created
Database definitions files /u01/oracle/product/11.2.0/gg/dirdef: created
Extract data files /u01/oracle/product/11.2.0/gg/dirdat: created
Temporary files /u01/oracle/product/11.2.0/gg/dirtmp: created
Stdout files /u01/oracle/product/11.2.0/gg/dirout: created
GGSCI (rhel.manzoor.com) 3> exit
g) Create a golden gate user which will be used by Manager / Extract / Replicate Process. Create the user and grant the necessary privileges.
DB : Execute the below on both the database (test11 & layatest)
sql> create tablespace gg_tblspc datafile '/orafiles/test11/ggs_tblspc01.dbf' size 100m;
sql> create user ggowner identified by ggowner default tablespace gg_tblspc temporary tablespace temp;
sql> grant create session to ggowner;
sql> grant connect, resource to ggowner;
sql> grant select any dictionary, select any table, insert any table to ggowner;
sql> grant select any table, update any table, delete any table, insert any table to ggowner;
sql> grant flashback any table to ggowner;
sql> grant execute on dbms_flashback to ggowner;
sql> grant execute on utl_file to ggowner;
sql> grant create table to ggowner;
-- Enable the supplemental logging, If supplemental log is not enabled it may cause extract process to handle key update incorrectly if key column is not in first row piece.
sql> alter database add supplemental log data (all) columns;
Database altered
h) Test whether you can able to connect to the db using the above crediantials.
GGSCI (rhel.manzoor.com) 3> dblogin userid ggowner@test11, password ggowner
Successfully logged into database.
GGSCI (rhel.manzoor.com) 4> dblogin userid ggowner@layatest, password ggowner
Successfully logged into database.
i) Configure the Manager process and start it.
Port -
The only mandatory parameter that we need to specify is the PORT which defines the port on the local system where the manager process is running. The default port is 7809 and we can either specify the default port or some other port provided the port is available and not restricted in any way.
AUTOSTART -
Some other recommended optional parameters are AUTOSTART which which automatically
start the Extract and Replicat processes when the Manager starts.
USERID PASSWORD
The USERID and PASSWORD parameter and required if you enable GoldenGate DDL support and this is the Oracle user account that we created for the Manager(and Extract/Replicat).
PURGEOLDEXTRACTS
The Manager process can also clean up trail files from disk when GoldenGate has finished processing them via the PURGEOLDEXTRACTS parameter. Used with the USECHECKPOINTS clause, it will ensure that until all processes have fnished using the data contained in the trail files, they will not be deleted.
GGSCI (rhel.manzoor.com) 5> EDIT PARAMS MGR
PORT 7809
USERID ggowner, PASSWORD ggowner
PURGEOLDEXTRACTS /u01/oracle/product/11.2.0/gg/dirdat/ex, USECHECKPOINTS
- The Manager process can be started using - START MANAGER
and stopped using - STOP MANAGER
and the status can be checked using - INFO MANAGER
Now start the Manager process.
GGSCI (rhel.manzoor.com) 2> START MANAGER
Manager started.
GGSCI (rhel.manzoor.com) 3> INFO MANAGER
Manager is running (IP port rhel.manzoor.com.7809).
## Initial data load.
Here we are going to replicate the manzoor.emp table which is in test11 to manzoor.emp in layatest
On source db we need to create a extract process, the process should be defined with
group name, in this example we use the group name as LDTESTDB
db: test11
SQL> select count(*) from manzoor.emp;
COUNT(*)
----------
100000
db : layatest
SQL> select count(*) from manzoor.emp;
COUNT(*)
----------
0
GGSCI (rhel.manzoor.com) 8> ADD EXTRACT LDTESTDB, SOURCEISTABLE
EXTRACT added.
-- Here the data is present in the table and not in the archive/redo log files, hence
we need to mention SOURCEISTABLE.
Create parameter file for the extract process.
EXTRACT : name of the extract group
USERID/PASSWORD : the database user which has been configured earlier for Extract ( this user is created in the source database)
RMTHOST : This will be the IP address or hostname of the target system
MGRPORT : the port where the Manager process is running
TABLE : specify the table which is being extracted and replicated. This can be specified in a number of ways
using wildcard characters to include or exclude tables as well as entire schemas.
GGSCI (rhel.manzoor.com) 10> EDIT PARAMS LDTESTDB
EXTRACT LDTESTDB
USERID ggowner@test11, PASSWORD ggowner
RMTHOST rhel.manzoor.com, MGRPORT 7809
RMTTASK replicat, GROUP LDLAYADB
TABLE manzoor.emp;
## Now create the replicate proces, the group should be the name which we have speicified in the extract process parameters using RMTTASK , GROUP. which is LDLAYADB
GGSCI (rhel.manzoor.com) 15> ADD REPLICAT LDLAYADB, SPECIALRUN
REPLICAT added.
-- Since it is a special run we need to include the keyword SPECIALRUN.
Create the parameter file for the replicat process.
REPLICAT : name of the Replicat group created for the initial data load
USERID/PASSWORD : database credentials for the Replicat user (this user is created in the target database)
ASSUMETARGETDEFS : this means that the source table structure exactly matches the target database table structure.
MAP : with GoldenGate we can have the target database structure entirely differ from that of the source in terms of table names as well as the column definitions of the tables. This parameter provides us the mapping of the source and target tables which is same in this case
GGSCI (rhel.manzoor.com) 4> EDIT PARAMS LDLAYADB
REPLICAT LDLAYADB
USERID ggowner@layatest, PASSWORD ggowner
ASSUMETARGETDEFS
MAP manzoor.emp, TARGET manzoor.emp;
## Now we can start the extract process for the initial load.
GGSCI (rhel.manzoor.com) 1> START EXTRACT LDTESTDB
Sending START request to MANAGER ...
EXTRACT LDTESTDB starting
## Check the status using the info command.
GGSCI (rhel.manzoor.com) 2> INFO EXTRACT LDTESTDB
EXTRACT LDTESTDB Initialized 2012-07-27 19:35 Status RUNNING
Checkpoint Lag Not Available
Log Read Checkpoint Not Available
First Record Record 0
Task SOURCEISTABLE
## On the info we can see that the status shows as RUNNING.
## For any error we can view the error by viewing the report.
GGSCI (rhel.manzoor.com) 3> VIEW REPORT LDTESTDB
GGSCI (rhel.manzoor.com) 1> INFO EXTRACT LDTESTDB
EXTRACT LDTESTDB Last Started 2012-07-28 09:19 Status STOPPED
Checkpoint Lag Not Available
Log Read Checkpoint Table MANZOOR.EMP
2012-07-28 09:22:18 Record 100000
Task SOURCEISTABLE
## Now the status shows stopped and the record shows 100000, let have a check
on record cound on the target table.
SQL> select count(*) from manzoor.emp;
COUNT(*)
----------
100000
-- Target table has been replicated correctly as per the source.
Tried to Put Some information about Oracle Database.
Friday, July 27, 2012
Saturday, March 17, 2012
Creating a RAC Database manaully
Creating a RAC Database.
DB Name : layatest
Instance 1 : layatest1
Instance 2 : layatest2
ASM Diskgroups - DATA1 and DATA3
1) Create the Required directories in both the nodes
mkdir -p /u01/app/oracle/admin/layatest/adump
mkdir -p /u01/app/oracle/admin/layatest/bdump
mkdir -p /u01/app/oracle/admin/layatest/cdump
mkdir -p /u01/app/oracle/admin/layatest/udump
mkdir -p /u01/app/oracle/admin/layatest/pfile
2) Create a parameter file.
###########################################
log_archive_dest_1='LOCATION=+DATA2/'
log_archive_format=%t_%s_%r.dbf
db_block_size=8192
db_file_multiblock_read_count=16
open_cursors=300
db_name=layatest
background_dump_dest=/u01/app/oracle/admin/layatest/bdump
core_dump_dest=/u01/app/oracle/admin/layatest/cdump
user_dump_dest=/u01/app/oracle/admin/layatest/udump
db_create_file_dest=+DATA1
compatible=10.2.0.3.0
processes=150
sga_target=285212672
audit_file_dest=/u01/app/oracle/admin/layatest/adump
remote_login_passwordfile=exclusive
pga_aggregate_target=94371840
undo_management=AUTO
control_files=("+DATA1","+DATA3")
cluster_database_instances=2
#cluster_database=true
layatest1.instance_number=1
layatest2.instance_number=2
layatest2.thread=2
layatest1.undo_tablespace=UNDOTBS1
layatest1.thread=1
3) Create password file in one node and copy that to all the nodes.
rhelrac1-> cd $ORACLE_HOME/dbs
rhelrac1-> orapwd file=orapwlayatest1 password=admin entries=5
rhelrac1-> scp orapwlayatest1 oracle@rhelrac2:/u01/app/oracle/product/10.2.0/db_1/dbs/orapwlayatest2
4) Create spfile using the pfile and the edit the init ora parameter to point the spfile in both the instance.
rhelrac1-> export ORACLE_SID=+ASM1
rhelrac1-> asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED EXTERN N N 512 4096 1048576 3858 3760 0 3760 0 DATA1/
MOUNTED NORMAL N N 512 4096 1048576 3765 3483 1255 1114 0 DATA2/
MOUNTED EXTERN N N 512 4096 1048576 3000 2903 0 2903 0 DATA3/
MOUNTED EXTERN N N 512 4096 1048576 3858 3760 0 3760 0 FLASH/
MOUNTED EXTERN N N 512 4096 1048576 1137 1044 0 1044 0 ORADATA/
MOUNTED NORMAL N N 512 4096 1048576 1928 1742 0 871 0 ORANORMAL/
ASMCMD> cd data2
ASMCMD> ls
ASMCMD> mkdir layatest
ASMCMD> cd layatest
ASMCMD> mkdir spfile
ASMCMD> cd spfile
ASMCMD> pwd
+data2/layatest/spfile
Crate the spfile in the above location +DATA2/layatest/spfile
rhelrac1-> export ORACLE_SID=layatest1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 14:47:25 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> create spfile='+DATA2/layatest/spfile/spfilelayatest.ora' from pfile='/u01/app/oracle/admin/layatest/pfile/initlayatest.ora';
File created.
SQL> exit
Now edit the pfiles in the oracle home location and point to the spfile. Repeat the same in all the nodes.
rhelrac1-> cd $ORACLE_HOME/dbs
rhelrac1-> vi initlayatest1.ora
spfile=+DATA2/layatest/spfile/spfilelayatest.ora
:wq!
rhelrac2-> cd $ORACLE_HOME/dbs
rhelrac2-> vi initlayatest2.ora
spfile=+DATA2/layatest/spfile/spfilelayatest.ora
4) Startup the instance in node1.
rhelrac1-> export ORACLE_SID=layatest1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 14:52:30 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 92277380 bytes
Database Buffers 188743680 bytes
Redo Buffers 2924544 bytes
SQL> create database layatest
2 datafile '+DATA1' size 500m extent management local
3 sysaux datafile '+DATA1' size 500m
4 default temporary tablespace temp tempfile '+DATA1' size 100m
5 undo tablespace undotbs1 datafile '+DATA1' size 100m
6 logfile
7 group 1 ('+DATA1','+DATA2') size 10m,
8 group 2 ('+DATA1','+DATA2') size 10m
9 /
Database created.
SQL> @?/rdbms/admin/catalog.sql;
PL/SQL procedure successfully completed.
SQL> @?/rdbms/admin/catproc.sql;
PL/SQL procedure successfully completed.
-- Create undo tablespace for the 2nd node.
SQL> create undo tablespace undotbs2 datafile '+DATA1' size 100m;
Tablespace created.
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='layatest2';
System altered.
-- Enable the cluster database.
SQL> alter system set cluster_database=true scope=spfile sid='*';
System altered.
--Create online redo log file for the 2nd node.
SQL> alter database add logfile thread 2 group 3 ('+DATA1','+DATA3') size 10m;
Database altered.
SQL> alter database add logfile thread 2 group 4 ('+DATA1','+DATA3') size 10m;
Database altered.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
--Startup the database.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 96471684 bytes
Database Buffers 184549376 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened.
-- Enable the thread 2
SQL> alter database enable public thread 2;
Database altered.
--Create RAC specific Views.
SQL> @?/rdbms/admin/catclust.sql;
PL/SQL procedure successfully completed.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
-- Register the databse in OCR.
rhelrac1-> srvctl add database -d layatest -o /u01/app/oracle/product/10.2.0/db_1 -p +DATA2/layatest/spfile/spfilelayatest.ora
rhelrac1-> srvctl add instance -d layatest -i layatest1 -n rhelrac1
rhelrac1-> srvctl add instance -d layatest -i layatest2 -n rhelrac2
rhelrac1-> srvctl config database -d layatest
rhelrac1 layatest1 /u01/app/oracle/product/10.2.0/db_1
rhelrac2 layatest2 /u01/app/oracle/product/10.2.0/db_1
rhelrac1-> srvctl start database -d layatest
rhelrac1-> srvctl status database -d layatest
Instance layatest1 is running on node rhelrac1
Instance layatest2 is running on node rhelrac2
--End of Database creation.
--Enable the archive log mode.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination +DATA2
Oldest online log sequence 42
Current log sequence 43
--Disable the cluster database.
SQL> alter system set cluster_database = false scope=spfile sid='layatest1';
System altered.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
-- Stop the database and mount the database in the node1
rhelrac1-> srvctl stop database -d layatest
-- Mount the database exclusively in node 1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 15:32:47 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 96471684 bytes
Database Buffers 184549376 bytes
Redo Buffers 2924544 bytes
Database mounted.
--enable archive log
SQL> alter database archivelog;
Database altered.
--Enable the cluster database.
SQL> alter system set cluster_database = true scope=spfile sid='layatest1';
System altered.
SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
rhelrac1-> srvctl start database -d layatest
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 15:35:01 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +DATA2
Oldest online log sequence 42
Next log sequence to archive 43
Current log sequence 43
SQL>exit
-------------------------------------------------------------------------------------
Setting local listeners:-
------------------------
alter system set local_listener = 'listener_layatest1' scope=spfile sid='layatest1';
alter system set local_listener = 'listener_layatest2' scope=spfile sid='layatest2';
srvctl stop database -d layatest
tnsnames.ora on both nodes
--------------------------
layatest1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
)
listener_layatest1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
)
layatest2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest2))
)
listener_layatest2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest2))
)
layatest =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(LOAD_BALANCE = yes)
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest2 (INSTANCE_NAME = layatest2))
)
Listener.ora in node1
---------------------
lsnrlayatest_rhelrac1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = extproc_layatest1))
(ADDRESS = (PROTOCOL = TCP)(HOST = rhelrac1-vip)(PORT = 1532) (IP = FIRST))
)
)
ADMIN_RESTRICTIONS_lsnrlayatest_rhelrac1=ON
--------------------------------------------
Start the listener:-
lsnrctl start lsnrlayatest_rhelrac1
Listener.ora in node2
---------------------
lsnrlayatest_rhelrac2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = extproc_layatest2))
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532) (IP = FIRST))
)
)
ADMIN_RESTRICTIONS_lsnrlayatest_rhelrac2=ON
--------------------------------------------
Start the Listener
lsnrctl start lsnrlayatest_rhelrac2
-----------------------------------
start the database.
-------------------
srvctl start database -d layatest
DB Name : layatest
Instance 1 : layatest1
Instance 2 : layatest2
ASM Diskgroups - DATA1 and DATA3
1) Create the Required directories in both the nodes
mkdir -p /u01/app/oracle/admin/layatest/adump
mkdir -p /u01/app/oracle/admin/layatest/bdump
mkdir -p /u01/app/oracle/admin/layatest/cdump
mkdir -p /u01/app/oracle/admin/layatest/udump
mkdir -p /u01/app/oracle/admin/layatest/pfile
2) Create a parameter file.
###########################################
log_archive_dest_1='LOCATION=+DATA2/'
log_archive_format=%t_%s_%r.dbf
db_block_size=8192
db_file_multiblock_read_count=16
open_cursors=300
db_name=layatest
background_dump_dest=/u01/app/oracle/admin/layatest/bdump
core_dump_dest=/u01/app/oracle/admin/layatest/cdump
user_dump_dest=/u01/app/oracle/admin/layatest/udump
db_create_file_dest=+DATA1
compatible=10.2.0.3.0
processes=150
sga_target=285212672
audit_file_dest=/u01/app/oracle/admin/layatest/adump
remote_login_passwordfile=exclusive
pga_aggregate_target=94371840
undo_management=AUTO
control_files=("+DATA1","+DATA3")
cluster_database_instances=2
#cluster_database=true
layatest1.instance_number=1
layatest2.instance_number=2
layatest2.thread=2
layatest1.undo_tablespace=UNDOTBS1
layatest1.thread=1
3) Create password file in one node and copy that to all the nodes.
rhelrac1-> cd $ORACLE_HOME/dbs
rhelrac1-> orapwd file=orapwlayatest1 password=admin entries=5
rhelrac1-> scp orapwlayatest1 oracle@rhelrac2:/u01/app/oracle/product/10.2.0/db_1/dbs/orapwlayatest2
4) Create spfile using the pfile and the edit the init ora parameter to point the spfile in both the instance.
rhelrac1-> export ORACLE_SID=+ASM1
rhelrac1-> asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED EXTERN N N 512 4096 1048576 3858 3760 0 3760 0 DATA1/
MOUNTED NORMAL N N 512 4096 1048576 3765 3483 1255 1114 0 DATA2/
MOUNTED EXTERN N N 512 4096 1048576 3000 2903 0 2903 0 DATA3/
MOUNTED EXTERN N N 512 4096 1048576 3858 3760 0 3760 0 FLASH/
MOUNTED EXTERN N N 512 4096 1048576 1137 1044 0 1044 0 ORADATA/
MOUNTED NORMAL N N 512 4096 1048576 1928 1742 0 871 0 ORANORMAL/
ASMCMD> cd data2
ASMCMD> ls
ASMCMD> mkdir layatest
ASMCMD> cd layatest
ASMCMD> mkdir spfile
ASMCMD> cd spfile
ASMCMD> pwd
+data2/layatest/spfile
Crate the spfile in the above location +DATA2/layatest/spfile
rhelrac1-> export ORACLE_SID=layatest1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 14:47:25 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> create spfile='+DATA2/layatest/spfile/spfilelayatest.ora' from pfile='/u01/app/oracle/admin/layatest/pfile/initlayatest.ora';
File created.
SQL> exit
Now edit the pfiles in the oracle home location and point to the spfile. Repeat the same in all the nodes.
rhelrac1-> cd $ORACLE_HOME/dbs
rhelrac1-> vi initlayatest1.ora
spfile=+DATA2/layatest/spfile/spfilelayatest.ora
:wq!
rhelrac2-> cd $ORACLE_HOME/dbs
rhelrac2-> vi initlayatest2.ora
spfile=+DATA2/layatest/spfile/spfilelayatest.ora
4) Startup the instance in node1.
rhelrac1-> export ORACLE_SID=layatest1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 14:52:30 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 92277380 bytes
Database Buffers 188743680 bytes
Redo Buffers 2924544 bytes
SQL> create database layatest
2 datafile '+DATA1' size 500m extent management local
3 sysaux datafile '+DATA1' size 500m
4 default temporary tablespace temp tempfile '+DATA1' size 100m
5 undo tablespace undotbs1 datafile '+DATA1' size 100m
6 logfile
7 group 1 ('+DATA1','+DATA2') size 10m,
8 group 2 ('+DATA1','+DATA2') size 10m
9 /
Database created.
SQL> @?/rdbms/admin/catalog.sql;
PL/SQL procedure successfully completed.
SQL> @?/rdbms/admin/catproc.sql;
PL/SQL procedure successfully completed.
-- Create undo tablespace for the 2nd node.
SQL> create undo tablespace undotbs2 datafile '+DATA1' size 100m;
Tablespace created.
SQL> alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='layatest2';
System altered.
-- Enable the cluster database.
SQL> alter system set cluster_database=true scope=spfile sid='*';
System altered.
--Create online redo log file for the 2nd node.
SQL> alter database add logfile thread 2 group 3 ('+DATA1','+DATA3') size 10m;
Database altered.
SQL> alter database add logfile thread 2 group 4 ('+DATA1','+DATA3') size 10m;
Database altered.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
--Startup the database.
SQL> startup
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 96471684 bytes
Database Buffers 184549376 bytes
Redo Buffers 2924544 bytes
Database mounted.
Database opened.
-- Enable the thread 2
SQL> alter database enable public thread 2;
Database altered.
--Create RAC specific Views.
SQL> @?/rdbms/admin/catclust.sql;
PL/SQL procedure successfully completed.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
-- Register the databse in OCR.
rhelrac1-> srvctl add database -d layatest -o /u01/app/oracle/product/10.2.0/db_1 -p +DATA2/layatest/spfile/spfilelayatest.ora
rhelrac1-> srvctl add instance -d layatest -i layatest1 -n rhelrac1
rhelrac1-> srvctl add instance -d layatest -i layatest2 -n rhelrac2
rhelrac1-> srvctl config database -d layatest
rhelrac1 layatest1 /u01/app/oracle/product/10.2.0/db_1
rhelrac2 layatest2 /u01/app/oracle/product/10.2.0/db_1
rhelrac1-> srvctl start database -d layatest
rhelrac1-> srvctl status database -d layatest
Instance layatest1 is running on node rhelrac1
Instance layatest2 is running on node rhelrac2
--End of Database creation.
--Enable the archive log mode.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination +DATA2
Oldest online log sequence 42
Current log sequence 43
--Disable the cluster database.
SQL> alter system set cluster_database = false scope=spfile sid='layatest1';
System altered.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
-- Stop the database and mount the database in the node1
rhelrac1-> srvctl stop database -d layatest
-- Mount the database exclusively in node 1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 15:32:47 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1267068 bytes
Variable Size 96471684 bytes
Database Buffers 184549376 bytes
Redo Buffers 2924544 bytes
Database mounted.
--enable archive log
SQL> alter database archivelog;
Database altered.
--Enable the cluster database.
SQL> alter system set cluster_database = true scope=spfile sid='layatest1';
System altered.
SQL> shut immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
rhelrac1-> srvctl start database -d layatest
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Sat Mar 17 15:35:01 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +DATA2
Oldest online log sequence 42
Next log sequence to archive 43
Current log sequence 43
SQL>exit
-------------------------------------------------------------------------------------
Setting local listeners:-
------------------------
alter system set local_listener = 'listener_layatest1' scope=spfile sid='layatest1';
alter system set local_listener = 'listener_layatest2' scope=spfile sid='layatest2';
srvctl stop database -d layatest
tnsnames.ora on both nodes
--------------------------
layatest1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
)
listener_layatest1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
)
layatest2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest2))
)
listener_layatest2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest2))
)
layatest =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac1-vip) (PORT = 1532))
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532))
(LOAD_BALANCE = yes)
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest) (INSTANCE_NAME = layatest1))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = layatest2 (INSTANCE_NAME = layatest2))
)
Listener.ora in node1
---------------------
lsnrlayatest_rhelrac1 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = extproc_layatest1))
(ADDRESS = (PROTOCOL = TCP)(HOST = rhelrac1-vip)(PORT = 1532) (IP = FIRST))
)
)
ADMIN_RESTRICTIONS_lsnrlayatest_rhelrac1=ON
--------------------------------------------
Start the listener:-
lsnrctl start lsnrlayatest_rhelrac1
Listener.ora in node2
---------------------
lsnrlayatest_rhelrac2 =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC) (KEY = extproc_layatest2))
(ADDRESS = (PROTOCOL = TCP) (HOST = rhelrac2-vip) (PORT = 1532) (IP = FIRST))
)
)
ADMIN_RESTRICTIONS_lsnrlayatest_rhelrac2=ON
--------------------------------------------
Start the Listener
lsnrctl start lsnrlayatest_rhelrac2
-----------------------------------
start the database.
-------------------
srvctl start database -d layatest
Tuesday, March 13, 2012
Oracle support period
Saturday, January 14, 2012
Oracle Database Product Licensing..
Good article on understanding the oracle database products licensing...written by
Alan Swahn.
Check the below link.
http://blogs.flexerasoftware.com/elo/oracle-software-licensing/
Alan Swahn.
Check the below link.
http://blogs.flexerasoftware.com/elo/oracle-software-licensing/
Monday, January 9, 2012
Convert Single Instance DB to RAC DB
Converting single instance DB to RAC DB.
a) Login to the single instance server, shutdown the db and take the cold backup using rman.
1) Create a rman script as below
$ vi fullbkpofdb.rcv
connect target /
shutdown immediate;
startup mount;
run
{
allocate channel a1 device type disk;
allocate channel a2 device type disk;
backup database format 'datafiles_%t_%d_%U.bkp' tag='Full_Database';
backup current controlfile format 'ctrlfile_%t_%d_%U.bkp' tag='ctrl_file';
backup spfile format 'spfile_%t_%d_%U.bkp' tag='spfilebkp';
release channel a1;
release channel a2;
}
exit;
2) Run the script.
$ rman cmdfile 'fullbkpofdb.rcv' log 'backup.log'
3) Once the backup is completed, copy the backup to the primary node
4) Create the password for the database in both the instance
Execute the below in node1
$ orapwd file=$ORACLE_HOME/dbs/orapwmanzy1 password=****** entries=20
Execute the below in node2
$ orapwd file=$ORACLE_HOME/dbs/orapwmanzy2 password=****** entries=20
5) Startup the instance using rman to restore db, rman will create a dummy pfile and starts the instance inorder to restore the spfile.
Now restore the spfile.
rhelrac1-> export ORACLE_SID=manzy1
rhelrac1-> rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jan 6 19:19:12 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/10.2.0/db_1/dbs/initmanzy.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 01/06/2012 19:19:33
ORA-00205: error in identifying control file, check alert log for more info
#### Restore the spfile to an pfile.
RMAN> restore spfile to pfile '/u01/initmanzy1.ora' from '/u01/backupofmanzy/spfile_771874551_MANZY_0kn03nnn_1_1.bkp';
Starting restore at 09-JAN-12
using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: /u01/backupofmanzy/spfile_771874551_MANZY_0kn03nnn_1_1.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 09-JAN-12
RMAN> exit;
##### Now create the directories in asm diskgroup to store your spfile,controlfile, datafiles and onlinelogfiles.
$ export ORACLE_SID=+ASM1
$ asmcmd
ASMCMD> lsdg
State Type Rebal Unbal Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Name
MOUNTED EXTERN N N 512 4096 1048576 3858 675 0 675 0 DATA1/
MOUNTED NORMAL N N 512 4096 1048576 3765 2361 1255 553 0 DATA2/
MOUNTED NORMAL N N 512 4096 1048576 3858 3075 1286 894 0 DATA3/
MOUNTED EXTERN N N 512 4096 1048576 3858 3304 0 3304 0 FLASH/
#### Once the pfile is restored edit the pfile with appropirate RAC parameter as below.
*.cluster_database_instances=2
*.cluster_database=TRUE
*.control_files='+DATA1/manzy/controlfiles/control01.ctl','+DATA1/manzy/controlfiles/control02.ctl'
manzy1.instance_name='manzy1'
manzy2.instance_name='manzy2'
manzy1.instance_number=1
manzy2.instance_number=2
manzy1.thread=1
manzy2.thread=2
manzy1.undo_tablespace='undotbs1'
manzy2.undo_tablespace='undotbs2'
Note : Also change the adump, bdump, cdump, udump directories accordingly.
###### After editing the pfile, create a spfile using the modified pfile.
rhelrac1-> export ORACLE_SID=manzy1
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 9 19:38:25 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> create spfile='+DATA1/manzy/spfiles/spfilemanzy.ora' from pfile = '/u01/initmanzy1.ora';
File created.
SQL> shut immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
###### Now create a pfile in $ORACLE_HOME/dbs location on both the instance pointing to the
same spfile.
Node 1
$ cd $ORACLE_HOME/dbs
$ vi initmanzy1.ora
### add the below line alone in the pfile.
spfile=+DATA1/manzy/spfiles/spfilemanzy.ora
Node 2
$ cd $ORACLE_HOME/dbs
$ vi initmanzy2.ora
### add the below line alone in the pfile.
spfile=+DATA1/manzy/spfiles/spfilemanzy.ora
### Now restore the controlfile in node1.
rhelrac1-> rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Mon Jan 9 19:43:54 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 444596224 bytes
Fixed Size 1267980 bytes
Variable Size 130025204 bytes
Database Buffers 310378496 bytes
Redo Buffers 2924544 bytes
RMAN> restore controlfile from '/u01/backupofmanzy/contfiles_771874550_MANZY_0jn03nnm_1_1.bkp';
Starting restore at 09-JAN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=150 instance=manzy1 devtype=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:16
output filename=+DATA1/manzy/controlfiles/control01.ctl
output filename=+DATA1/manzy/controlfiles/control02.ctl
Finished restore at 09-JAN-12
##### Mount the controlfile
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
##### Now remove all the details of backup repository which is stored in this controfile
RMAN> crosscheck backup;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/datafiles_771873888_MANZY recid=1 stamp=771873889
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/u01/datafiles_771873913_MANZY recid=2 stamp=771873913
RMAN> delete noprompt expired backup;
using channel ORA_DISK_1
List of Backup Pieces
BP Key BS Key Pc# Cp# Status Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
1 1 1 1 EXPIRED DISK /u01/datafiles_771873888_MANZY recid=1 stamp=771873889
2 2 1 1 EXPIRED DISK /u01/datafiles_771873913_MANZY recid=2 stamp=771873913
deleted backup piece
backup piece handle=/u01/datafiles_771873888_MANZY recid=1 stamp=771873889 recid=15 stamp=771874538
deleted backup piece
backup piece handle=/u01/datafiles_771873913_MANZY recid=2 stamp=771873913 recid=16 stamp=771874527
Deleted 2 EXPIRED objects
RMAN> list backup;
RMAN>
#### Now catalog the backup files which we have taken from the single instance.
RMAN> catalog start with '/u01/backupofmanzy/';
searching for all files that match the pattern /u01/backupofmanzy/
List of Files Unknown to the Database
=====================================
File Name: /u01/backupofmanzy/contfiles_771874550_MANZY_0jn03nnm_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874526_MANZY_0fn03nmu_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874533_MANZY_0hn03nn5_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874526_MANZY_0gn03nmu_1_1.bkp
File Name: /u01/backupofmanzy/spfile_771874551_MANZY_0kn03nnn_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874538_MANZY_0in03nna_1_1.bkp
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/backupofmanzy/contfiles_771874550_MANZY_0jn03nnm_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874526_MANZY_0fn03nmu_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874533_MANZY_0hn03nn5_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874526_MANZY_0gn03nmu_1_1.bkp
File Name: /u01/backupofmanzy/spfile_771874551_MANZY_0kn03nnn_1_1.bkp
File Name: /u01/backupofmanzy/datafiles_771874538_MANZY_0in03nna_1_1.bkp
##### Now restore the datafiles to the asm diskgroup use the set newname command to rename the datafiles.
RMAN> run
2> {
3> set newname for datafile '/optware/oracle/oradata/manzy/system01.dbf' to '+DATA2/manzy/datafiles/system01.dbf';
4> set newname for datafile '/optware/oracle/oradata/manzy/undotbs01.dbf' to '+DATA2/manzy/datafiles/undotbs01.dbf';
5> set newname for datafile '/optware/oracle/oradata/manzy/sysaux01.dbf' to '+DATA3/manzy/datafiles/sysaux01.dbf';
6> set newname for datafile '/optware/oracle/oradata/manzy/users01.dbf' to '+DATA3/manzy/datafiles/users01.dbf';
7> restore database;
8> switch datafile all;
9> }
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 09-JAN-12
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00002 to +DATA2/manzy/datafiles/undotbs01.dbf
restoring datafile 00003 to +DATA3/manzy/datafiles/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backupofmanzy/datafiles_771874526_MANZY_0gn03nmu_1_1.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/backupofmanzy/datafiles_771874526_MANZY_0gn03nmu_1_1.bkp tag=FULL_DB
channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to +DATA2/manzy/datafiles/system01.dbf
restoring datafile 00004 to +DATA3/manzy/datafiles/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backupofmanzy/datafiles_771874526_MANZY_0fn03nmu_1_1.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/backupofmanzy/datafiles_771874526_MANZY_0fn03nmu_1_1.bkp tag=FULL_DB
channel ORA_DISK_1: restore complete, elapsed time: 00:00:47
Finished restore at 09-JAN-12
datafile 1 switched to datafile copy
input datafile copy recid=5 stamp=772142636 filename=+DATA2/manzy/datafiles/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=6 stamp=772142636 filename=+DATA2/manzy/datafiles/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=7 stamp=772142637 filename=+DATA3/manzy/datafiles/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=8 stamp=772142637 filename=+DATA3/manzy/datafiles/users01.dbf
RMAN> exit;
### Now we have restored the database to the new location i.e. asm diskgroup, now we need to rename the
online logfiles for that connect to the sqlplus and rename the files.
rhelrac1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jan 9 20:04:55 2012
Copyright (c) 1982, 2007, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
SQL> select status from V$instance;
STATUS
------------
MOUNTED
SQL> select member from V$logfile;
MEMBER
--------------------------------------------------------------------------------
/optware/oracle/oradata/manzy/redo03.log
/optware/oracle/oradata/manzy/redo02.log
/optware/oracle/oradata/manzy/redo01.log
#### Rename the logfiles to point to the asm diskgroups.
SQL> alter database rename file '/optware/oracle/oradata/manzy/redo01.log' to '+FLASH/manzy/onlinelogfiles/redo01.log';
Database altered.
SQL> alter database rename file '/optware/oracle/oradata/manzy/redo02.log' to '+FLASH/manzy/onlinelogfiles/redo02.log';
Database altered.
SQL> alter database rename file '/optware/oracle/oradata/manzy/redo03.log' to '+FLASH/manzy/onlinelogfiles/redo03.log';
Database altered.
#### Now add the logfiles which will be used by the instance 2.
SQL> select * from V$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 1 52428800 1 NO CURRENT 464631 06-JAN-12
3 1 0 52428800 1 YES UNUSED 0
2 1 0 52428800 1 YES UNUSED 0
SQL> alter database add logfile thread 2 group 4 '+FLASH/manzy/onlinelogfiles/redo04.log' size 52428800;
Database altered.
SQL> alter database add logfile thread 2 group 5 '+FLASH/manzy/onlinelogfiles/redo05.log' size 52428800;
Database altered.
SQL> alter database add logfile thread 2 group 6 '+FLASH/manzy/onlinelogfiles/redo06.log' size 52428800;
Database altered.
#### Open the database with resetlogs option.
SQL> alter database open resetlogs;
Database altered.
#### Recreate the temporary tablespace
SQL> create temporary tablespace temp2 tempfile '+DATA3/manzy/datafiles/temp02.dbf' size 50m;
Tablespace created.
SQL> alter database default temporary tablespace temp2;
Database altered.
SQL> drop tablespace TEMP including contents and datafiles;
Tablespace dropped.
### Enable the thread for the instance 2
SQL> alter database enable thread 2;
Database altered.
### Create the undo tablespace for the instance 2
SQL> create undo tablespace undotbs2 datafile '+DATA3/manzy/datafiles/undotbs02.dbf' size 50m;
Tablespace created.
SQL> exit;
##### Now add the database to the cluster registry (OCR) using the srvctl command.
$ srvctl add database -d manzy -o /u01/app/oracle/product/10.2.0/db_1 -p +DATA1/manzy/spfiles/spfilemanzy.ora
$ srvctl add instance -d manzy -i manzy1 -n rhelrac1
$ srvctl add instance -d manzy -i manzy2 -n rhelrac2
### Shutdown the database and start it using srvctl
$ srvctl stop database -d manzy
$ srvctl start database -d manzy
### Check the status of the instance.
$ srvctl status database -d manzy
Instance manzy1 is running on node rhelrac1
Instance manzy2 is running on node rhelrac2
#### Configure the tnsnames and listerners.
##### End of converting single instance to RAC Instance.
Thursday, December 15, 2011
Steps to Increase the swap space in linux
Procedure to add a swap file
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
$ mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
$ swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
$ vi /etc/fstab
Append following line to the above file:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
$ free -m
You need to use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.
a) Login as the root user
b) Type following command to create 512MB swap file (1024 * 512MB = 524288 block size):
$ dd if=/dev/zero of=/swapfile1 bs=1024 count=524288
c) Set up a Linux swap area:
$ mkswap /swapfile1
d) Activate /swapfile1 swap space immediately:
$ swapon /swapfile1
e) To activate /swapfile1 after Linux system reboot, add entry to /etc/fstab file. Open this file using text editor such as vi:
$ vi /etc/fstab
Append following line to the above file:
/swapfile1 swap swap defaults 0 0
So next time Linux comes up after reboot, it enables the new swap file for you automatically.
g) How do I verify swap is activated or not?
Simply use free command:
$ free -m
Sunday, December 11, 2011
Creating LVM in Linux
Creating Lvm in linux:-
======================
a) I have a disk named /dev/sdb which is of 25GB, using this We will
be creating a LVM. First we need to create physical volume, then
volume group then the logical volumes.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
b. First will be creating 3 partition using the device /dev/sdb
[root@rhel ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 3133.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3133, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-3133, default 3133): +10204M
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 1e Hidden W95 FAT1 75 PC/IX be Solaris boot
1 FAT12 24 NEC DOS 80 Old Minix bf Solaris
2 XENIX root 39 Plan 9 81 Minix / old Lin c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 82 Linux swap c4 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 83 Linux c6 DRDOS/sec (FAT-
5 Extended 41 PPC PReP Boot 84 OS/2 hidden C: c7 Syrinx
6 FAT16 42 SFS 85 Linux extended da Non-FS data
7 HPFS/NTFS 4d QNX4.x 86 NTFS volume set db CP/M / CTOS / .
8 AIX 4e QNX4.x 2nd part 87 NTFS volume set de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1243-3133, default 1243):
Using default value 1243
Last cylinder or +size or +sizeM or +sizeK (1243-3133, default 3133): +10204M
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2485-3133, default 2485):
Using default value 2485
Last cylinder or +size or +sizeM or +sizeK (2485-3133, default 3133):
Using default value 3133
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 83 Linux
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
c) Now we have created 3 Partition of type Linux LVM, then execute the partproble cmd
to inform the changes made on the partition table.
[root@rhel ~]# partprobe
d) Create the physical volume using the 3 partition which we have created now
[root@rhel ~]# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdb3" successfully created
e) Check the list of physical volumes.
pvs - report information about physical volumes
[root@rhel ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 -- 9.51G 9.51G
/dev/sdb2 lvm2 -- 9.51G 9.51G
/dev/sdb3 lvm2 -- 4.97G 4.97G
f) Then create a volumne gruoup using these physical volumes, the attribute -p defines the maximum no.
of physical volumes can be added in this volume group, the /dev/orahome defines the name of the
volumes group.
[root@rhel ~]# vgcreate -s 32 -p 100 /dev/orahome /dev/sdb1 /dev/sdb2 /dev/sdb3
Volume group "orahome" successfully created
e) Display and check the properties of the volume group which we have created.
[root@rhel ~]# vgdisplay -v orahome
Using volume group(s) on command line
Finding volume group "orahome"
--- Volume group ---
VG Name orahome
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 100
Cur PV 3
Act PV 3
VG Size 23.97 GB
PE Size 32.00 MB
Total PE 767
Alloc PE / Size 0 / 0
Free PE / Size 767 / 23.97 GB
VG UUID zMQhxU-3Epq-UV54-QKkU-YpkI-mNIj-6UGxI1
--- Physical volumes ---
PV Name /dev/sdb1
PV UUID itUG6n-E9Ug-AW27-s0JI-iinC-Z8BZ-f3XzDG
PV Status allocatable
Total PE / Free PE 304 / 304
PV Name /dev/sdb2
PV UUID 3Dr36J-QLNT-PkIL-iIHE-3wKM-wcFs-3ntguB
PV Status allocatable
Total PE / Free PE 304 / 304
PV Name /dev/sdb3
PV UUID ukv2D3-hfkO-nKYX-7bk6-gu2T-OEHO-uiiTgH
PV Status allocatable
Total PE / Free PE 159 / 159
f) Create the logical volumes using the volume group.
[root@rhel ~]# lvcreate -L 23G -n orabin /dev/orahome
Logical volume "orabin" created
g) Check the properties of the lvm.
[root@rhel ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
orabin orahome -wi-a- 23.00G
h) Now make the file system using the logical volume.
[root@rhel ~]# mke2fs -j /dev/orahome/orabin
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3014656 inodes, 6029312 blocks
301465 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=8388608
184 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
i) Create an directory and mount the lvm to the directory
[root@rhel /]# mkdir optware
[root@rhel /]# mount /dev/orahome/orabin /optware
[root@rhel /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 626M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 506M 0 506M 0% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 70M 15G 1% /orafiles
/dev/mapper/orahome-orabin
23G 77M 22G 1% /optware
j) Add the entry in fstab system file.
[root@rhel /]# vi /etc/fstab
/dev/orahome/orabin /optware ext3 defaults 0 0
h) un mount the mount point and check whether it is mounting properly.
[root@rhel /]# umount /optware
[root@rhel /]# mount -a
[root@rhel /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 626M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 506M 0 506M 0% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 70M 15G 1% /orafiles
/dev/mapper/orahome-orabin
23G 77M 22G 1% /optware
i) Now the lvm is ready to use
II) Steps to increase the size of the logical volume.
a) As per the above the size of the /optware mount point is 23G, we will
add another 2 GB to the mount point.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
b) We have device /dev/sdc with 2 GB , we need to add this to the existing
VG inorder to increase the Logical volume.
c) Create partition on the /dev/sdc.
[root@rhel ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 1e Hidden W95 FAT1 75 PC/IX be Solaris boot
1 FAT12 24 NEC DOS 80 Old Minix bf Solaris
2 XENIX root 39 Plan 9 81 Minix / old Lin c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 82 Linux swap c4 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 83 Linux c6 DRDOS/sec (FAT-
5 Extended 41 PPC PReP Boot 84 OS/2 hidden C: c7 Syrinx
6 FAT16 42 SFS 85 Linux extended da Non-FS data
7 HPFS/NTFS 4d QNX4.x 86 NTFS volume set db CP/M / CTOS / .
8 AIX 4e QNX4.x 2nd part 87 NTFS volume set de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 261 2096451 8e Linux LVM
c) Run the partprobe to inform the kernel about the modified partition.
d) Create a physical volume.
[root@rhel ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@rhel ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 orahome lvm2 a- 9.50G 0
/dev/sdb2 orahome lvm2 a- 9.50G 0
/dev/sdb3 orahome lvm2 a- 4.97G 992.00M
/dev/sdc1 lvm2 -- 2.00G 2.00G
e) Increase the VG using the vgextend cmd.
[root@rhel ~]# vgextend orahome /dev/sdc1
Volume group "orahome" successfully extended
[root@rhel ~]# vgdisplay -v orahome
--- Volume group ---
VG Name orahome
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 100
Cur PV 4
Act PV 4
VG Size 25.94 GB
PE Size 32.00 MB
Total PE 830
Alloc PE / Size 736 / 23.00 GB
Free PE / Size 94 / 2.94 GB
VG UUID zMQhxU-3Epq-UV54-QKkU-YpkI-mNIj-6UGxI1
f) As per the above the total size of the VG is 25.94 GB , and the allocated
size is 23 GB and the free size is 2.94 GB.
g) Now increase the lvm using the lvextend cmd.
[root@rhel ~]# lvextend -L 25G /dev/orahome/orabin
Extending logical volume orabin to 25.00 GB
Logical volume orabin successfully resized
h) Now resize the mount point. You can try to resize online , if it failures
the un mount the file sysem then resize and then mount again.
[root@rhel ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.5G 93M 99% /
/dev/sda1 494M 17M 453M 4% /boot
none 760M 0 760M 0% /dev/shm
/dev/sda3 2.0G 1.3G 637M 67% /software
/dev/sda6 494M 13M 457M 3% /tmp
/dev/sda7 15G 6.5G 7.7G 46% /orafiles
/dev/mapper/orahome-orabin
23G 8.3G 14G 39% /optware
[root@rhel ~]# umount /optware
[root@rhel ~]# resize2fs /dev/orahome/orabin
resize2fs 1.35 (28-Feb-2004)
Please run 'e2fsck -f /dev/orahome/orabin' first.
[root@rhel ~]# e2fsck -f /dev/orahome/orabin
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/orahome/orabin: 58274/3014656 files (1.7% non-contiguous), 2259610/6029312 blocks
[root@rhel ~]# resize2fs /dev/orahome/orabin
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/orahome/orabin to 6553600 (4k) blocks.
The filesystem on /dev/orahome/orabin is now 6553600 blocks long.
[root@rhel ~]# mount /dev/orahome/orabin /optware/
[root@rhel ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.5G 93M 99% /
/dev/sda1 494M 17M 453M 4% /boot
none 760M 0 760M 0% /dev/shm
/dev/sda3 2.0G 1.3G 637M 67% /software
/dev/sda6 494M 13M 457M 3% /tmp
/dev/sda7 15G 6.5G 7.7G 46% /orafiles
/dev/mapper/orahome-orabin
25G 8.3G 16G 35% /optware
Now the /optware shows 25G.
======================
a) I have a disk named /dev/sdb which is of 25GB, using this We will
be creating a LVM. First we need to create physical volume, then
volume group then the logical volumes.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
b. First will be creating 3 partition using the device /dev/sdb
[root@rhel ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 3133.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-3133, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-3133, default 3133): +10204M
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 1e Hidden W95 FAT1 75 PC/IX be Solaris boot
1 FAT12 24 NEC DOS 80 Old Minix bf Solaris
2 XENIX root 39 Plan 9 81 Minix / old Lin c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 82 Linux swap c4 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 83 Linux c6 DRDOS/sec (FAT-
5 Extended 41 PPC PReP Boot 84 OS/2 hidden C: c7 Syrinx
6 FAT16 42 SFS 85 Linux extended da Non-FS data
7 HPFS/NTFS 4d QNX4.x 86 NTFS volume set db CP/M / CTOS / .
8 AIX 4e QNX4.x 2nd part 87 NTFS volume set de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1243-3133, default 1243):
Using default value 1243
Last cylinder or +size or +sizeM or +sizeK (1243-3133, default 3133): +10204M
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 83 Linux
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2485-3133, default 2485):
Using default value 2485
Last cylinder or +size or +sizeM or +sizeK (2485-3133, default 3133):
Using default value 3133
Command (m for help): p
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 83 Linux
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
c) Now we have created 3 Partition of type Linux LVM, then execute the partproble cmd
to inform the changes made on the partition table.
[root@rhel ~]# partprobe
d) Create the physical volume using the 3 partition which we have created now
[root@rhel ~]# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3
Physical volume "/dev/sdb1" successfully created
Physical volume "/dev/sdb2" successfully created
Physical volume "/dev/sdb3" successfully created
e) Check the list of physical volumes.
pvs - report information about physical volumes
[root@rhel ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 lvm2 -- 9.51G 9.51G
/dev/sdb2 lvm2 -- 9.51G 9.51G
/dev/sdb3 lvm2 -- 4.97G 4.97G
f) Then create a volumne gruoup using these physical volumes, the attribute -p defines the maximum no.
of physical volumes can be added in this volume group, the /dev/orahome defines the name of the
volumes group.
[root@rhel ~]# vgcreate -s 32 -p 100 /dev/orahome /dev/sdb1 /dev/sdb2 /dev/sdb3
Volume group "orahome" successfully created
e) Display and check the properties of the volume group which we have created.
[root@rhel ~]# vgdisplay -v orahome
Using volume group(s) on command line
Finding volume group "orahome"
--- Volume group ---
VG Name orahome
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 100
Cur PV 3
Act PV 3
VG Size 23.97 GB
PE Size 32.00 MB
Total PE 767
Alloc PE / Size 0 / 0
Free PE / Size 767 / 23.97 GB
VG UUID zMQhxU-3Epq-UV54-QKkU-YpkI-mNIj-6UGxI1
--- Physical volumes ---
PV Name /dev/sdb1
PV UUID itUG6n-E9Ug-AW27-s0JI-iinC-Z8BZ-f3XzDG
PV Status allocatable
Total PE / Free PE 304 / 304
PV Name /dev/sdb2
PV UUID 3Dr36J-QLNT-PkIL-iIHE-3wKM-wcFs-3ntguB
PV Status allocatable
Total PE / Free PE 304 / 304
PV Name /dev/sdb3
PV UUID ukv2D3-hfkO-nKYX-7bk6-gu2T-OEHO-uiiTgH
PV Status allocatable
Total PE / Free PE 159 / 159
f) Create the logical volumes using the volume group.
[root@rhel ~]# lvcreate -L 23G -n orabin /dev/orahome
Logical volume "orabin" created
g) Check the properties of the lvm.
[root@rhel ~]# lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
orabin orahome -wi-a- 23.00G
h) Now make the file system using the logical volume.
[root@rhel ~]# mke2fs -j /dev/orahome/orabin
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
3014656 inodes, 6029312 blocks
301465 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=8388608
184 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
i) Create an directory and mount the lvm to the directory
[root@rhel /]# mkdir optware
[root@rhel /]# mount /dev/orahome/orabin /optware
[root@rhel /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 626M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 506M 0 506M 0% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 70M 15G 1% /orafiles
/dev/mapper/orahome-orabin
23G 77M 22G 1% /optware
j) Add the entry in fstab system file.
[root@rhel /]# vi /etc/fstab
/dev/orahome/orabin /optware ext3 defaults 0 0
h) un mount the mount point and check whether it is mounting properly.
[root@rhel /]# umount /optware
[root@rhel /]# mount -a
[root@rhel /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.0G 626M 87% /
/dev/sda1 494M 17M 453M 4% /boot
none 506M 0 506M 0% /dev/shm
/dev/sda3 2.0G 36M 1.9G 2% /software
/dev/sda6 494M 11M 458M 3% /tmp
/dev/sda7 15G 70M 15G 1% /orafiles
/dev/mapper/orahome-orabin
23G 77M 22G 1% /optware
i) Now the lvm is ready to use
II) Steps to increase the size of the logical volume.
a) As per the above the size of the /optware mount point is 23G, we will
add another 2 GB to the mount point.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn't contain a valid partition table
b) We have device /dev/sdc with 2 GB , we need to add this to the existing
VG inorder to increase the Logical volume.
c) Create partition on the /dev/sdc.
[root@rhel ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
0 Empty 1e Hidden W95 FAT1 75 PC/IX be Solaris boot
1 FAT12 24 NEC DOS 80 Old Minix bf Solaris
2 XENIX root 39 Plan 9 81 Minix / old Lin c1 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 82 Linux swap c4 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 83 Linux c6 DRDOS/sec (FAT-
5 Extended 41 PPC PReP Boot 84 OS/2 hidden C: c7 Syrinx
6 FAT16 42 SFS 85 Linux extended da Non-FS data
7 HPFS/NTFS 4d QNX4.x 86 NTFS volume set db CP/M / CTOS / .
8 AIX 4e QNX4.x 2nd part 87 NTFS volume set de Dell Utility
9 AIX bootable 4f QNX4.x 3rd part 8e Linux LVM df BootIt
a OS/2 Boot Manag 50 OnTrack DM 93 Amoeba e1 DOS access
b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS e4 SpeedStor
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a5 FreeBSD ee EFI GPT
10 OPUS 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor a9 NetBSD f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fe LANstep
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT
1c Hidden W95 FAT3
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 65 522081 83 Linux
/dev/sda2 66 702 5116702+ 83 Linux
/dev/sda3 703 963 2096482+ 83 Linux
/dev/sda4 964 3263 18474750 5 Extended
/dev/sda5 964 1224 2096451 82 Linux swap
/dev/sda6 1225 1289 522081 83 Linux
/dev/sda7 1290 3263 15856123+ 83 Linux
Disk /dev/sdb: 25.7 GB, 25769803776 bytes
255 heads, 63 sectors/track, 3133 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1242 9976333+ 8e Linux LVM
/dev/sdb2 1243 2484 9976365 8e Linux LVM
/dev/sdb3 2485 3133 5213092+ 8e Linux LVM
Disk /dev/sdc: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 261 2096451 8e Linux LVM
c) Run the partprobe to inform the kernel about the modified partition.
d) Create a physical volume.
[root@rhel ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@rhel ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb1 orahome lvm2 a- 9.50G 0
/dev/sdb2 orahome lvm2 a- 9.50G 0
/dev/sdb3 orahome lvm2 a- 4.97G 992.00M
/dev/sdc1 lvm2 -- 2.00G 2.00G
e) Increase the VG using the vgextend cmd.
[root@rhel ~]# vgextend orahome /dev/sdc1
Volume group "orahome" successfully extended
[root@rhel ~]# vgdisplay -v orahome
--- Volume group ---
VG Name orahome
System ID
Format lvm2
Metadata Areas 4
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 1
Max PV 100
Cur PV 4
Act PV 4
VG Size 25.94 GB
PE Size 32.00 MB
Total PE 830
Alloc PE / Size 736 / 23.00 GB
Free PE / Size 94 / 2.94 GB
VG UUID zMQhxU-3Epq-UV54-QKkU-YpkI-mNIj-6UGxI1
f) As per the above the total size of the VG is 25.94 GB , and the allocated
size is 23 GB and the free size is 2.94 GB.
g) Now increase the lvm using the lvextend cmd.
[root@rhel ~]# lvextend -L 25G /dev/orahome/orabin
Extending logical volume orabin to 25.00 GB
Logical volume orabin successfully resized
h) Now resize the mount point. You can try to resize online , if it failures
the un mount the file sysem then resize and then mount again.
[root@rhel ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.5G 93M 99% /
/dev/sda1 494M 17M 453M 4% /boot
none 760M 0 760M 0% /dev/shm
/dev/sda3 2.0G 1.3G 637M 67% /software
/dev/sda6 494M 13M 457M 3% /tmp
/dev/sda7 15G 6.5G 7.7G 46% /orafiles
/dev/mapper/orahome-orabin
23G 8.3G 14G 39% /optware
[root@rhel ~]# umount /optware
[root@rhel ~]# resize2fs /dev/orahome/orabin
resize2fs 1.35 (28-Feb-2004)
Please run 'e2fsck -f /dev/orahome/orabin' first.
[root@rhel ~]# e2fsck -f /dev/orahome/orabin
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/orahome/orabin: 58274/3014656 files (1.7% non-contiguous), 2259610/6029312 blocks
[root@rhel ~]# resize2fs /dev/orahome/orabin
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/orahome/orabin to 6553600 (4k) blocks.
The filesystem on /dev/orahome/orabin is now 6553600 blocks long.
[root@rhel ~]# mount /dev/orahome/orabin /optware/
[root@rhel ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 4.9G 4.5G 93M 99% /
/dev/sda1 494M 17M 453M 4% /boot
none 760M 0 760M 0% /dev/shm
/dev/sda3 2.0G 1.3G 637M 67% /software
/dev/sda6 494M 13M 457M 3% /tmp
/dev/sda7 15G 6.5G 7.7G 46% /orafiles
/dev/mapper/orahome-orabin
25G 8.3G 16G 35% /optware
Now the /optware shows 25G.
Subscribe to:
Posts (Atom)
