当前位置:网站首页>把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
2022-06-24 22:53:00 【睿思达DBA_WGX】
把 Oracle 数据库从 Windows 系统迁移到 Linux Oracle Rac 集群环境(2)——将数据库转换为集群模式
目录
一、查看数据库集群属性
-- 查看数据库集群属性
SQL> show parameter cluster
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean FALSE -- 集群开关:关闭
cluster_database_instances integer 1 -- 实例数量为1
cluster_interconnects string
-- 查看实例的属性
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 -- 独占版的实例
instance_type string RDBMS
open_links_per_instance integer 4
parallel_instance_group string
parallel_server_instances integer 1
二、修改集群参数
1、在节点 rac1 上执行如下命令
-- =================================================================================
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、创建节点 rac2 所需的 undo表空间
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
-- 用于指定 Oracle 数据库服务器创建数据文件的缺省路径
SQL> alter system set db_create_file_dest='+DATA';
System altered.
-- 创建表空间 undotbs2
SQL> create undo tablespace undotbs2 datafile size 500M;
Tablespace created.
-- 查看数据文件
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、创建节点 rac2 所需的日志文件
-- 查看日志文件
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/hisdb/onlinelog/redo05a.log
+DATA/hisdb/onlinelog/redo06a.log
+DATA/hisdb/onlinelog/redo07a.log
-- 创建日志文件
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;
-- 查看日志文件
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、设置节点 rac2 的集群属性
-- ============================================================================================
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、在节点 rac1 重启实例,然后在 rac2 启动实例
-- 节点1
-- 停库
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
-- 启动实例
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.
-- 节点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.
三、添加数据库与实例信息到 srvctl
对于 dbca 创建的数据库,srvctl 中包含了数据库和实例的信息。但对于通过备份恢复的数据库,srvctl 中不包含数据库和实例信息。所以,需要手动将 database 信息和实例信息添加到 srvctl 管理器中。
[[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
执行以下操作,必须在 oracle 用户下执行:
# 切换为 oracle 用户
[[email protected] admin]$ su - oracle
Password:
Last login: Mon Jun 20 17:38:23 CST 2022 on pts/0
# 删除原来的数据库信息
[[email protected] dbs]$ srvctl remove database -d mydb
Remove the database mydb? (y/[n]) y
# 添加数据库信息
[[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
# 添加实例信息
[[email protected] ~]$ srvctl add instance -d hisdb -i hisdb1 -n rac1
[[email protected] ~]$ srvctl add instance -d hisdb -i hisdb2 -n rac2
# 启动数据库
[[email protected] dbs]$ srvctl start database -d hisdb
# 使数据库和实例自动启动
[[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
四、生成口令文件
# 节点1
cd $ORACLE_HOME/dbs
orapwd file=orapwhisdb1 password=oracle
# 节点2
cd $ORACLE_HOME/dbs
orapwd file=orapwhisdb2 password=oracle
边栏推荐
- 3 years of testing experience. I don't even understand what I really need on my resume. I need 20K to open my mouth?
- 【直播回顾】战码先锋第七期:三方应用开发者如何为开源做贡献
- jwt
- MOS管相关知识
- 2个NPN三极管组成的恒流电路
- 字符串数组转换为list集合
- File system - basic knowledge of disk and detailed introduction to FAT32 file system
- 测试/开发程序员,30而立,你是否觉得迷茫?又当何去何从......
- I've been doing software testing for two years. I'd like to give some advice to girls who are still hesitating
- Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
猜你喜欢

Are programmers from Huawei, Alibaba and other large manufacturers really easy to find?

3 years of testing experience. I don't even understand what I really need on my resume. I need 20K to open my mouth?

【STL源码剖析】STL六大组件功能与运用(目录)

内网学习笔记(7)

入职一家新公司,如何快速熟悉代码?

非凸联合创始人李佐凡:将量化作为自己的终身事业

业务与技术双向结合构建银行数据安全管理体系

Please run IDA with elevated permissons for local debugging.

ProcessOn制作ER过程(自定义)

【直播回顾】战码先锋第七期:三方应用开发者如何为开源做贡献
随机推荐
一线城市软件测试工资——你拖后腿了吗
Kaggle 专利匹配比赛金牌方案赛后总结
Build and train your own dataset for pig face recognition
Four characteristics of actual attack and defense drill
[day 26] given the ascending array nums of n elements, find a function to find the subscript of target in nums | learn binary search
The ecosystem of the yuan universe
同花顺是正规平台吗?同花顺开户安全吗
【Proteus仿真】Arduino UNO+继电器控制照明设备
如何选择正规安全的外汇交易平台?
The role of software security testing, how to find a software security testing company to issue a report?
Intranet learning notes (5)
Intranet learning notes (6)
[I.MX6UL] U-Boot移植(六) 网络驱动修改 LAN8720A
AI服装生成,帮你完成服装设计的最后一步
内网学习笔记(6)
Integration of metersphere open source continuous testing platform and Alibaba cloud cloud cloud efficient Devops
Resolution of cross reference in IDA
放养但没有完全放养(春季每日一题 2)
年已过半,年终立的Flag实现了几个?
Stocking but not completely stocking (daily question 2 in spring)