当前位置:网站首页>把 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
边栏推荐
- What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
- [mobile terminal] design size of mobile phone interface
- 探索C语言程序奥秘——C语言程序编译与预处理
- 软件测试人员的7个等级,据说只有1%的人能做到级别7
- 转行软件测试2年了,给还在犹豫的女生一点建议
- 进入阿里做测试员遥不可及?这里或许有你想要的答案
- Explanation of FTP protocol
- 3年测试经验,连简历上真正需要什么都没搞明白,张口就要20k?
- 中信证券手机开户是靠谱的吗?安全吗
- 折叠屏将成国产手机分食苹果市场的重要武器
猜你喜欢

Pit entry machine learning: I. Introduction

元宇宙的生态圈

记一次beego通过go get命令后找不到bee.exe的坑

What is the reason for the disconnection of video playback due to the EHOME protocol access of easycvr platform?
Cusdis - lightweight, privacy first open source comment system | chain of the city

会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?

都2022年了,你还不了解什么是性能测试?

JS array object to object

Hashcat 的使用
![[live review] battle code pioneer phase 7: how third-party application developers contribute to open source](/img/ad/26a302ca724177e37fe123f8b75e4e.png)
[live review] battle code pioneer phase 7: how third-party application developers contribute to open source
随机推荐
计算机三级(数据库)备考题目知识点总结
Android Internet of things application development (smart Park) - set sensor threshold dialog interface
实战攻防演练中的四大特点
Multimodal emotion recognition_ Research on emotion recognition based on multimodal fusion
字符串数组转换为list集合
产业互联网的概念里有「互联网」字眼,但却是一个和互联网并不关联的存在
Pit entry machine learning: I. Introduction
I've been doing software testing for two years. I'd like to give some advice to girls who are still hesitating
How to quickly familiarize yourself with the code when you join a new company?
都2022年了,你还不了解什么是性能测试?
【Proteus仿真】Arduino UNO+继电器控制照明设备
Dataease template market officially released
|遇到bug怎么分析,专业总结分析来了
【STL源码剖析】配置器(待补充)
Please run IDA with elevated permissons for local debugging.
Sumati GameFi生态纵览,神奇世界中的元素设计
Four characteristics of actual attack and defense drill
Folding screen will become an important weapon for domestic mobile phones to share the apple market
云原生数据库VS传统数据库
左手梦想 右手责任 广汽本田不光关注销量 还有儿童安全