当前位置:网站首页>Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (2) -- convert database to cluster mode

Migrate Oracle database from windows system to Linux Oracle RAC cluster environment (2) -- convert database to cluster mode

2022-06-25 02:24:00 Rsda DBA_ WGX

hold Oracle Database from Windows System migration to Linux Oracle Rac Cluster environment (2)—— Convert the database to cluster mode

One 、 View database cluster properties

--  View database cluster properties 
SQL> show parameter cluster

NAME				            TYPE	    VALUE
------------------------------------ ----------- ------------------------------
cluster_database		         boolean	 FALSE  --  Cluster switch : close 
cluster_database_instances	     integer	     1   --  The number of instances is 1
cluster_interconnects		     string

--  View the instance properties 
SQL> show parameter instance

NAME				     		TYPE	 VALUE
------------------------------------ ----------- ------------------------------
active_instance_count		     integer
cluster_database_instances	     integer	 	1
instance_groups 		     	string
instance_name			     	string	 	hisdb1
instance_number 		     	integer	 		0   --  Instances of exclusive Edition 
instance_type			     	string	 	RDBMS
open_links_per_instance 	     integer	 	4
parallel_instance_group 	     string
parallel_server_instances	     integer	 	1

Two 、 Modify cluster parameters

1、 At the node rac1 Execute the following command above

-- =================================================================================
alter system set cluster_database=true scope=spfile;
alter system set cluster_database_instances=2 scope=spfile;
alter system set instance_number=1 scope=spfile sid='hisdb1';
alter system set thread=1 scope=spfile sid='hisdb1';
alter system set undo_tablespace=undotbs1 scope=spfile sid='hisdb1';
-- =================================================================================
-- =================================================================================
-- =================================================================================

SQL> 
alter system set cluster_database=true scope=spfile;
alter system set cluster_database_instances=2 scope=spfile;
alter system set instance_number=1 scope=spfile sid='hisdb1';
alter system set thread=1 scope=spfile sid='hisdb1';
alter system set undo_tablespace=undotbs1 scope=spfile sid='hisdb1';

System altered.

2、 Create nodes rac2 The required undo Table space

SQL> show parameter db_creat

NAME				     		TYPE	 VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest		     	string
db_create_online_log_dest_1	     string
db_create_online_log_dest_2	     string
db_create_online_log_dest_3	     string
db_create_online_log_dest_4	     string
db_create_online_log_dest_5	     string

--  Is used to specify the  Oracle  The default path for the database server to create data files 
SQL> alter system set db_create_file_dest='+DATA';
System altered.

--  Create tablespace  undotbs2
SQL> create undo tablespace undotbs2 datafile size 500M;
Tablespace created.

--  View data files 
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/hisdb/datafile/system.270.1107594961
+DATA/hisdb/datafile/sysaux.271.1107594961
+DATA/hisdb/datafile/undotbs1.272.1107594961
+DATA/hisdb/datafile/users.275.1107594963
+DATA/hisdb/datafile/ts001.273.1107594963
+DATA/hisdb/datafile/ts001.274.1107594963
+DATA/hisdb/datafile/undotbs2.280.1107605935

7 rows selected.

3、 Create nodes rac2 Required log files

--  view log file 
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/hisdb/onlinelog/redo05a.log
+DATA/hisdb/onlinelog/redo06a.log
+DATA/hisdb/onlinelog/redo07a.log

--  Create a log file 
alter database add logfile thread 2 group 1 '+data/hisdb/onlinelog/redo01.log' size 50m;
alter database add logfile thread 2 group 2 '+data/hisdb/onlinelog/redo02.log' size 50m;
alter database add logfile thread 2 group 3 '+data/hisdb/onlinelog/redo03.log' size 50m;

--  view log file 
SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/hisdb/onlinelog/redo01.log
+DATA/hisdb/onlinelog/redo02.log
+DATA/hisdb/onlinelog/redo05a.log
+DATA/hisdb/onlinelog/redo06a.log
+DATA/hisdb/onlinelog/redo07a.log
+DATA/hisdb/onlinelog/redo03.log

6 rows selected.

4、 Set nodes rac2 Cluster properties for

-- ============================================================================================
alter system set instance_number=2 scope=spfile sid='hisdb2';
alter system set thread=2 scope=spfile sid='hisdb2';
alter system set undo_tablespace=undotbs2 scope=spfile sid='hisdb2';
alter database enable thread 2;
-- ============================================================================================
-- ============================================================================================
SQL> alter system set instance_number=2 scope=spfile sid='hisdb2';
SQL> alter system set thread=2 scope=spfile sid='hisdb2';
SQL> alter system set undo_tablespace=undotbs2 scope=spfile sid='hisdb2';

SQL> alter database enable thread 2;

5、 At the node rac1 Restart instance , And then in rac2 Boot instance

--  node 1
--  Stop storage 
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
--  Boot instance 
SQL> startup
ORACLE instance started.

Total System Global Area  638853120 bytes
Fixed Size		    2255952 bytes
Variable Size		  494928816 bytes
Database Buffers	  134217728 bytes
Redo Buffers		    7450624 bytes
Database mounted.
Database opened.


--  node 2
SQL> startup
ORACLE instance started.

Total System Global Area  638853120 bytes
Fixed Size		    2255952 bytes
Variable Size		  494928816 bytes
Database Buffers	  134217728 bytes
Redo Buffers		    7450624 bytes
Database mounted.
Database opened.

3、 ... and 、 Add database and instance information to srvctl

about dbca Database created ,srvctl Database and instance information are included in . But for databases restored through backup ,srvctl Database and instance information are not included in . therefore , Need to manually database Information and instance information are added to srvctl Manager .

[[email protected] ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.BAK.dg     ora....up.type ONLINE    ONLINE    rac1        
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1        
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac1        
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1        
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac1        
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora.mydb.db    ora....se.type OFFLINE   OFFLINE               
ora....network ora....rk.type ONLINE    ONLINE    rac1        
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac1        
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1        
ora....SM1.asm application    ONLINE    ONLINE    rac1        
ora....C1.lsnr application    ONLINE    ONLINE    rac1        
ora.rac1.gsd   application    OFFLINE   OFFLINE               
ora.rac1.ons   application    ONLINE    ONLINE    rac1        
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1        
ora....SM2.asm application    ONLINE    ONLINE    rac2        
ora....C2.lsnr application    ONLINE    ONLINE    rac2        
ora.rac2.gsd   application    OFFLINE   OFFLINE               
ora.rac2.ons   application    ONLINE    ONLINE    rac2        
ora.rac2.vip   ora....t1.type ONLINE    ONLINE    rac2        
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac1    

Do the following , Must be in oracle Execute under the user :

#  Switch to a  oracle  user 
[[email protected] admin]$ su - oracle
Password: 
Last login: Mon Jun 20 17:38:23 CST 2022 on pts/0

#  Delete the original database information 
[[email protected] dbs]$ srvctl remove database -d mydb
Remove the database mydb? (y/[n]) y

#  Add database information 
[[email protected] ~]$ srvctl add database -d hisdb -o /u01/app/oracle/product/11.2.0/db_1 -p +DATA/hisdb/spfilehisdb.ora
# -d db_unique_name; -o oracle_home; -p spfile_path

#  Add instance information 
[[email protected] ~]$ srvctl add instance -d hisdb -i hisdb1 -n rac1
[[email protected] ~]$ srvctl add instance -d hisdb -i hisdb2 -n rac2

#  Start database 
[[email protected] dbs]$ srvctl start database -d hisdb

#  Make the database and instance start automatically 
[[email protected] ~]$ srvctl enable database -d hisdb
PRCC-1010 : hisdb was already enabled
PRCR-1002 : Resource ora.hisdb.db is already enabled

[[email protected] ~]$ srvctl enable instance -d hisdb -i hisdb1
[[email protected] ~]$ srvctl enable instance -d hisdb -i hisdb2


[[email protected] ~]$ crs_stat -t
Name           Type           Target    State     Host        
------------------------------------------------------------
ora.BAK.dg     ora....up.type ONLINE    ONLINE    rac1        
ora.DATA.dg    ora....up.type ONLINE    ONLINE    rac1        
ora....ER.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora....N1.lsnr ora....er.type ONLINE    ONLINE    rac1        
ora.OCR.dg     ora....up.type ONLINE    ONLINE    rac1        
ora.asm        ora.asm.type   ONLINE    ONLINE    rac1        
ora.cvu        ora.cvu.type   ONLINE    ONLINE    rac1        
ora.gsd        ora.gsd.type   OFFLINE   OFFLINE               
ora.hisdb.db   ora....se.type ONLINE    ONLINE    rac1        
ora....network ora....rk.type ONLINE    ONLINE    rac1        
ora.oc4j       ora.oc4j.type  ONLINE    ONLINE    rac1        
ora.ons        ora.ons.type   ONLINE    ONLINE    rac1        
ora....SM1.asm application    ONLINE    ONLINE    rac1        
ora....C1.lsnr application    ONLINE    ONLINE    rac1        
ora.rac1.gsd   application    OFFLINE   OFFLINE               
ora.rac1.ons   application    ONLINE    ONLINE    rac1        
ora.rac1.vip   ora....t1.type ONLINE    ONLINE    rac1        
ora....SM2.asm application    ONLINE    ONLINE    rac2        
ora....C2.lsnr application    ONLINE    ONLINE    rac2        
ora.rac2.gsd   application    OFFLINE   OFFLINE               
ora.rac2.ons   application    ONLINE    ONLINE    rac2        
ora.rac2.vip   ora....t1.type ONLINE    ONLINE    rac2        
ora.scan1.vip  ora....ip.type ONLINE    ONLINE    rac1        

Four 、 Generate password file

#  node 1
cd $ORACLE_HOME/dbs
orapwd file=orapwhisdb1 password=oracle

#  node 2
cd $ORACLE_HOME/dbs
orapwd file=orapwhisdb2 password=oracle
原网站

版权声明
本文为[Rsda DBA_ WGX]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206242253453670.html

随机推荐