记住主备机ip
主机:192.168.29.135
备机:192.168.29.136
监视机:192.168.1.18
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DM01 DMSVR01 5236 45101 主机ip 55101 65101
DM01 DMSVR02 5236 45121 备机ip 55121 65121
基础准备
1主机备机初始化实例,dbca建库
安装路径 /dm8/data
数据库名 DM01(主)/DM01(备)
实例名 DMSVR01(主)/DMSVR02(备)
端口号 5236
页大小 16KB
簇大小 32个页
日志文件大小 500MB
字符串大小写 敏感
SYSDBA/SYSAUDITOR用户密码 DM01SYSDBA
2关闭主备实例
[dmdba@localhost ~]$ cd /dm8/bin
[dmdba@localhost bin]$ ./DmServiceDMSVR01 stop
Stopping DmServiceDMSVR01: [ OK ]
[dmdba@localhost bin]$
[dmdba@localhost ~]$ cd /dm8/bin
[dmdba@localhost bin]$ ./DmServiceDMSVR02 stop
Stopping DmServiceDMSVR02: [ OK ]
[dmdba@localhost bin]$
3备份主机
[dmdba@localhost ~]$ cd /dm8/bin
[dmdba@localhost bin]$ mkdir /dm8/bak
[dmdba@localhost bin]$ ./dmrman
dmrman V8
RMAN> BACKUP DATABASE '/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/bak/BACKUP_FILE_01'
BACKUP DATABASE '/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/bak/BACKUP_FILE_01'
file dm.key not found, use default license!
Database mode = 0, oguid = 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
EP[0]'s cur_lsn[40610], file_lsn[40610]
Processing backupset /dm8/bak/BACKUP_FILE_01
[Percent:100.00%][Speed:0.00M/s][Cost:00:00:02][Remaining:00:00:00]
backup successfully!
time used: 00:00:03.409
RMAN> exit
time used: 0.425(ms)
[dmdba@localhost bin]$
/dm8/bin $ ./dmrman
BACKUP DATABASE '/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/bak/BACKUP_FILE_01'
4修改主机dmdba用户密码为Dameng123
[root@localhost 桌面]# passwd dmdba
更改用户 dmdba 的密码 。
新的 密码:Dameng123
重新输入新的 密码:Dameng123
passwd:所有的身份验证令牌已经成功更新。
[root@localhost 桌面]#
5将主机备份传到备机
备机
[dmdba@localhost dm8]$ mkdir /dm8/bak
[dmdba@localhost dm8]$ ll
主机
[dmdba@localhost bak]$ scp -r /dm8/bak/BACKUP_FILE_01 192.168.29.136:/dm8/bak
Authorized users only. All activities may be monitored and reported.
dmdba@192.168.29.136's password:
BACKUP_FILE_01.bak 100% 13MB 91.6MB/s 00:00
BACKUP_FILE_01.meta 100% 98KB 11.2MB/s 00:00
[dmdba@localhost bak]$
scp /dm8/bak/BACKUP_FILE_01 备机ip:/dm8/bak
6备机恢复备份
/dm8/bin $ ./dmrman
RESTORE DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/bak'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/bak'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' UPDATE DB_MAGIC
RESTORE DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/bak/BACKUP_FILE_01'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/bak/BACKUP_FILE_01'
RECOVER DATABASE '/dm8/data/DM01/dm.ini' UPDATE DB_MAGIC
主库配置文件配置
新建文件,将所有配置文件粘贴进去,然后全文替换,注意文件夹名称DM01
/dm8/data/DM01
[dmdba@localhost DM01]$ vim dm.ini
[dmdba@localhost DM01]$ vim dmmal.ini
[dmdba@localhost DM01]$ vim dmarch.ini
[dmdba@localhost DM01]$ vim dmwatcher.ini
1 dm.ini
INSTANCE_NAME = DMSVR01
PORT_NUM = 5236
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
2 dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 主机ip
MAL_PORT = 55101
MAL_INST_HOST = 主机ip
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 备机ip
MAL_PORT = 55121
MAL_INST_HOST = 备机ip
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
3 dmarch.ini (注:arch_dest备机写主机实例,主机写备机实例)
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
4 dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dm8/data/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
5 启动主库
cd /dm8/bin
./DmServiceDMSVR01 start mount
6 修改主库的模式和设置oguid。
cd /dm8/bin
./disql SYSDBA/DM01SYSDBA@localhost:5236
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database primary;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
备库配置文件配置
/dm8/data/DM01
[dmdba@localhost DM01]$ vim dm.ini
[dmdba@localhost DM01]$ vim dmmal.ini
[dmdba@localhost DM01]$ vim dmarch.ini
[dmdba@localhost DM01]$ vim dmwatcher.ini
1 dm.ini
INSTANCE_NAME = DMSVR02
PORT_NUM = 5236
DW_INACTIVE_INTERVAL = 60
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
RLOG_SEND_APPLY_MON = 64
2 dmmal.ini
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 主机ip
MAL_PORT = 55101
MAL_INST_HOST = 主机ip
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 备机ip
MAL_PORT = 55121
MAL_INST_HOST = 备机ip
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
3 dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSVR01 //备机写主机实例
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
4 dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 453331
INST_INI = /dm8/data/DM01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
5 Mount 方式启动备库
cd /dm8/bin
./DmServiceDMSVR02 start mount
6 设置备库模式和oguid值
cd /dm8/bin
./disql SYSDBA/DM01SYSDBA@localhost:5236
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL>sp_set_oguid(453331);
SQL>alter database standby;
SQL>SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
启主备库的守护进程
[dmdba@/dm8/bin]#./dmwatcher /dm8/data/DM01/dmwatcher.ini
[dmdba@/dm8/bin]#./dmwatcher /dm8/data/DM01/dmwatcher.ini
配置监视机
dmmonitor.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.29.135:65101 //主
MON_DW_IP = 192.168.29.136:65121 //备
启动监视器
cd /dm8/bin
./dmmonitor /dm8/dmmonitor.ini
--注册监视器服务(也可以不注册)
/dm8/script/root/dm_service_installer.sh -t dmmonitor -p ITSM_DB -monitor_ini /dm8/dmmonitor.ini
-- 守护进程服务注册(最好注册)
主库
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DM01/dmwatcher.ini
备库
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DM01/dmwatcher.ini
临时关闭防火墙 # systemctl stop firewalld.service
测试
备库
Select * from t1;
主库
Create table t1(id int);
Insert into t1 values(1);
Commit;
文章
阅读量
获赞