避坑指南,防火墙关闭或者开放对应端口
1.建主库实例
2.建备库实例
3.stop 主库实例、备库实例
4.备份主库
5.还原备份到备库
6.修改主库配置 ini文件
7.mount启动主库,修改oguid、primary
8.复制修改备课配置 ini文件
9.mount启动备课,修改oguid、standby
10.启动主库守护进程
11.启动备库守护进程
12.启动监视进程,switchover主备,执行脚本
13.关闭监视进程
14.关闭备库守护进程
15.关闭主库守护进程
16.关闭主库实例
17.关闭备课实例
18.注册服务,监视进程、主备守护进程
1.做好数据库节点规划。
1.1.生产环境配置:1台主机,1台备机,1台监视器。
1.2.本次实操为练习,准备了两台机器,主机1台,备机和监视器共用1台。
1.3.ip规划如下:
dwp 172.16.16.131 ---主机
dws 172.16.16.132 ---备机
dwm 172.16.16.132 ---监视器
2.数据守护端口规划如下:
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DAMENG01 DAMENG01 5246 40001 172.16.16.131 50001 60001
DAMENG02 DAMENG02 5246 40001 172.16.16.132 50001 60001
3.初始化数据库实例(目录/dm8,用户dmdba):
3.1.本次初始化主备库实例,dbca建库、建实、例注册服务,注意名称见第2步。本人实操通过dbca.sh建库、建实例、注册服务,所以不需要步骤3.2、3.3。
3.2.或者用命令行初始化实例命令如下(本次不用),执行命令目录/dm8/bin:
3.2.1.主库(IP: 172.16.16.131 实例名: DAMENG01):
./dminit path=/dm8/data DB_NAME=DAMENG01 INSTANCE_NAME=DAMENG01 PAGE_SIZE=8 EXTENT_SIZE=16 LOG_SIZE=500 CASE_SENSITIVE=Y SYSDBA_PWD=123456789
3.2.2.备库(IP: 172.16.16.132 实例名: DAMENG02):
./dminit path=/dm8/data DB_NAME=DAMENG02 INSTANCE_NAME=DAMENG02 PAGE_SIZE=8 EXTENT_SIZE=16 LOG_SIZE=500 CASE_SENSITIVE=Y SYSDBA_PWD=123456789
3.3.用命令初始化需要自己手动注册服务,命令如下:
主库:
/dm8/script/root/dm_service_installer.sh -t dmserver -p DAMENG01 -dm_ini /dm8/data/DAMENG01/dm.ini
备库:
/dm8/script/root/dm_service_installer.sh -t dmserver -p DAMENG02 -dm_ini /dm8/data/DAMENG02/dm/.ini
4.主备两台实例关掉,在/dm8/bin目录下执行如下:
./DmServiceDMSERVER01 stop
./DmServiceDMSERVER02 stop
5.对主机进行备份,在/dm8/bin目录下执行如下:
./dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/DAMENG01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'"
6.将备份文件从主机传到备机,命令如下
scp -r /dm8/backup/BACKUP_FILE_01 dmdba@172.16.16.132:/dm8/backup
7.在备上进行恢复,共需dmrman执行3个命令:如下
./dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/DAMENG02/dm.ini' FROM BACKUPSET '/dm8/backup/BACKUP_FILE_01'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DAMENG02/dm.ini' FROM BACKUPSET '/dm8/backup/BACKUP_FILE_01'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DAMENG02/dm.ini' UPDATE DB_MAGIC"
INSTANCE_NAME = DMSERVER01
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
RLOG_SEND_APPLY_MON = 64
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSERVER01
MAL_HOST = 172.16.16.131
MAL_PORT = 50001
MAL_INST_HOST = 172.16.16.131
MAL_INST_PORT = 5246
MAL_DW_PORT = 60001
MAL_INST_DW_PORT = 40001
[MAL_INST2]
MAL_INST_NAME = DMSERVER02
MAL_HOST = 172.16.16.132
MAL_PORT = 50002
MAL_INST_HOST = 172.16.16.132
MAL_INST_PORT = 5246
MAL_DW_PORT = 60002
MAL_INST_DW_PORT = 40002
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
[DMSERVER]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 1537321
INST_INI = /dm8/data/DAMENG01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
8.2.mount模式启动主库:
cd /dm8/bin
./DmServiceDMSERVER01 start mount
8.3.修改主库的模式和设置oguid,通过命令./disql登录:
./disql sysdba/123456789@localhost:5246
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL> sp_set_oguid(1537321);
SQL> alter database primary;
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
查看数据库魔数
SQL> select db_magic;
769157258
INSTANCE_NAME = DMSERVER02
PORT_NUM = 5246
DW_INACTIVE_INTERVAL = 60
RLOG_SEND_APPLY_MON = 64
ALTER_MODE_STATUS = 0
ENABLE_OFFLINE_TS = 2
MAL_INI = 1
ARCH_INI = 1
MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = DMSERVER01
MAL_HOST = 172.16.16.131
MAL_PORT = 50001
MAL_INST_HOST = 172.16.16.131
MAL_INST_PORT = 5246
MAL_DW_PORT = 60001
MAL_INST_DW_PORT = 40001
[MAL_INST2]
MAL_INST_NAME = DMSERVER02
MAL_HOST = 172.16.16.132
MAL_PORT = 50002
MAL_INST_HOST = 172.16.16.132
MAL_INST_PORT = 5246
MAL_DW_PORT = 60002
MAL_INST_DW_PORT = 40002
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DMSERVER01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0
[DMSERVER]
DW_TYPE = GLOBAL
DW_MODE = AUTO
DW_ERROR_TIME = 10
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 10
INST_OGUID = 1537321
INST_INI = /dm8/data/DAMENG02/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0
9.2.以 Mount 方式启动备库:
cd /dm8/bin
./DmServiceDMSERVER02 start mount
9.3.设置备库模式和oguid值,通过命令./disql登录:
./disql sysdba/123456789@localhost:5246
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
SQL> sp_set_oguid(1537321);
SQL> alter database standby;
SQL> SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
10.启动守护进程
--启主备库的守护进程
启主库守护进程
[dmdba@/dm8/bin]# ./dmwatcher /dm8/data/DAMENG01/dmwatcher.ini
启备库守护进程
[dmdba@/dm8/bin]# ./dmwatcher /dm8/data/DAMENG02/dmwatcher.ini
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dm8/data/log
MON_LOG_INTERVAL = 60
MON_LOG_FILE_SIZE = 32
MON_LOG_SPACE_LIMIT = 0
[DMSERVER]
MON_INST_OGUID = 1537321
MON_DW_IP = 172.16.16.131:60001
MON_DW_IP = 172.16.16.132:60002
启动监视器
[dmdba@bogon bin]$ ./dmmonitor /dm8/dmmonitor.ini
12.注册监视器服务,注册主备机守护进程服务:
12.1.注册监视器服务(也可以不注册)
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmmonitor -p ITSM_DB -monitor_ini /dm8/dmmonitor.ini
12.2.注册主库的守护进程
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DAMENG01/dmwatcher.ini
12.3.注册备库的守护进程
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DAMENG02/dmwatcher.ini
关闭顺序:
1.监视器进程
2.备库守护进程
3.主库守护进程
4.主库实例
5.备课实例
文章
阅读量
获赞