有一套Windows下运行的Oracle11G单机环境,表空间分配1.3T,实际数据量在700-800G左右;出于服务器稳定和数据库性能方面的考虑,客户需要将数据库迁移至Linux环境,并在合适时机进行切割。
(一)
当前服务器环境
OS | CPU/Mem | 磁盘 |
---|---|---|
Windows Server2008 R2 | 16c/120G | 6*500G*SSD |
数据库环境
版本 | 归档 | 备份 | 数据量 | 在线日志 |
---|---|---|---|---|
11.2.0.4 | 关闭 | EXPDP | 750G | 3*1*50M |
(二)
打开归档
同开发商沟通得知,不打开归档的原因是因为数据库更新比较频繁,在活动期间会产生大量的归档,有时会达到1T,对磁盘的读写性能要求较高,所以关闭了归档。
在取得数据库的访问权限后,查询了当前在线日志的切换频率,发现日志量还是可控的,在双12活动期间在线日志切换4205次,预估产生归档量4205*50M/1024M~210G左右;而双12是年度最大的一次活动。
根据获得的情况,反馈开发商,建议客户购买并挂载足量磁盘(1T以上)存储归档日志;并建议开发商新增日志文件组(500M)、制定归档及时删除策略、RMAN备份策略。
开发商在磁盘挂载之后,申请了维护时间窗口,开启归档;根据最近观察,日常归档产生量在100G左右。
(三)
备库资源规划
CentOS release 6.9 (Final) | 32C/64G | 4*500G*SSD+21T高效云盘 |
935G /orabackup 切割后做本地备份集存储
935G /oralog 在线及归档日志
467G /oradata/oradata04 数据文件
467G /oradata/oradata03 数据文件
467G /oradata/oradata02 数据文件
467G /oradata/oradata01 数据文件
(四)
备库数据库软件安装
略
(五)
主库DG环境配置
由开发商操作
# 参数修改
alter database force logging;
alter system set log_archive_config = 'dg_config=(ccc,ccc_dg)';
alter system set log_archive_dest_2 = 'SERVICE=ccc_dg COMPRESSION=ENABLE LGWR ASYNC AFFIRM VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=ccc_dg';
alter system set log_archive_dest_state_2 = ENABLE;
# tnsnames.ora 修改
CCC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xxxx)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ccc)
)
)
CCC_DG =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zzzz)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = ccc)
(UR = A)
)
)
# 密码文件同步至备库
(六)
备库DG环境配置
# 参数配置
alter system set log_archive_config = 'dg_config=(ccc,ccc_dg)';
alter system set log_archive_dest_1 = 'location=/oralog/archive';
alter system set db_file_name_convert = 'D:\ORADB\CCC','/oradata/oradata01','F:\ORADB\CCC','/oradata/oradata02','G:\ORADB\CCC','/oradata/oradata02','H:\ORADB\CCC','/oradata/oradata03','I:\ORADB\CCC','/oradata/oradata03','J:\ORADB\CCC','/oradata/oradata04' scope=spfile;
alter system set log_file_name_convert = 'D:\ORADB\CCC','/oralog/log' scope=spfile;
# tnsnames.ora配置
同主库
# 监听配置
略
配置完成之后,尝试使用tnsname连接主备数据库
(七)
开启数据库初始化
nohup sh ccc_dg_par.sh > /dev/null 2>&1 &
ccc_dg_par.sh
#!/bin/bash
set -o pipefail
set -o errexit
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
export ORACLE_SID=ccc
$ORACLE_HOME/bin/rman target sys/xxxxxxx@xxx auxiliary sys/xxxxxxxxx@xxx_dg cmdfile 'ccc_dg.par' log 'ccc_dg.log' <<EOF
exit
EOF
exit
ccc_dg.par
run{
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate auxiliary channel standby1 type disk;
allocate auxiliary channel standby2 type disk;
set newname for datafile 5 to '/oradata/oradata01/BACKUP01.DBF';
set newname for datafile 63 to '/oradata/oradata01/BACKUP07.DBF';
set newname for datafile 11 to '/oradata/oradata01/system01.DBF';
…………
set newname for tempfile 5 to '/oradata/oradata03/TEMP03.DBF';
set newname for tempfile 6 to '/oradata/oradata04/TEMP02.DBF';
duplicate target database
for standby
from active database
nofilenamecheck
dorecover;
release channel prmy1;
release channel prmy2;
}
(八)
开启实时同步
Alter database add standby logfile group 11 '/oralog/log/standby_11.log’ size 1024m;
Alter database add standby logfile group 12 '/oralog/log/standby_12.log’ size 1024m;
Alter database add standby logfile group 13 '/oralog/log/standby_13.log’ size 1024m;
Alter database add standby logfile group 14 '/oralog/log/standby_14.log’ size 1024m;
Alter database add standby logfile group 15 '/oralog/log/standby_15.log’ size 1024m;
Alter database add standby logfile group 16 '/oralog/log/standby_16.log’ size 1024m;
Alter database add standby logfile group 17 '/oralog/log/standby_17.log’ size 1024m;
alter database recover managed standby database disconnect from session;
alter database recover managed standby database cancel;
Alter database open;
alter database recover managed standby database disconnect from session using current logfile;
(九)
验证并接入EasyDB监控平台