先检查操作系统的防火墙策略端口是否开放。
1、systemctl start firewalld
2、systemctl stop firewalld
3、systemctl status firewalld
4、systemctl disable firewalld
第一步:数据准备
第一:主库准备--停机备份
./dmrman
BACKUP DATABASE '/dm/data/DAMENG/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dmbackup/BACKUP_FILE_01'
Dmrman 工具现需要开启dmap服务 ps -ef|grep dmap 启动dmap命令./DmAPService start
第二:备库准备
备库初始化实例-注意实例名称
./dminit PATH=/dmdata LOG_PATH=/dmdmdbms/DM01.log LOG_PATH=/dmdmdbms/DM02.log LOG_PATH=/dmdmdbms/DM03.log db_name=DAMENG instance_name=DM02 SYSDBA_PWD="DAMENGSYSDBA" SYSAUDITOR_PWD="DAMENGSYSDBA" PORT_NUM=5236 EXTENT_SIZE=32 PAGE_SIZE=16 charset=1 log_size=500
备库建一个目录
mkdir /dmbackup
主库复制备份包到备库
scp -r BACKUP_FILE_01 dmdba@192.168.147.164:/dmbackup
备库进行数据恢复
./dmrman
第一条restore
RESTORE DATABASE '/dmdata/DAMENG/dm.ini' FROM BACKUPSET '/dmbackup/BACKUP_FILE_01/'
第二条RECOVER
RECOVER DATABASE '/dmdata/DAMENG/dm.ini' FROM BACKUPSET '/dmbackup/BACKUP_FILE_01/'
第三条更新DB_MAGIC
RECOVER DATABASE '/dmdata/DAMENG/dm.ini' UPDATE DB_MAGIC
第二步:主库配置
INSTANCE_NAME = DM01
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
MAL_CHECK_INTERVAL = 60
MAL_CONN_FAIL_INTERVAL = 60
[MAL_INST1]
MAL_INST_NAME = DM01
MAL_HOST = 192.168.147.165
MAL_PORT = 55101
MAL_INST_HOST = 192.168.147.165
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DM02
MAL_HOST = 192.168.147.164
MAL_PORT = 55121
MAL_INST_HOST = 192.168.147.164
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
Vi dmarch.ini 主库前面开了归档这个文件有了就添加下面内容
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM02
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmarch
ARCH_FILE_SIZE = 2048
ARCH_SPACE_LIMIT = 20480
ARCH_FLUSH_BUF_SIZE = 0
ARCH_HANG_FLAG = 1
Vi dmwatcher.ini 没有则新建
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 60
INST_OGUID = 453331
INST_INI = /dmdata/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dmdmdbms/bin/DAMENG
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
另外开一个窗口 --启动主库
./DAMENG /dmdata/DAMENG/dm.ini mount
./disql SYSDBA/DAMENGSYSDBA 普通状态
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);
第三步:备库配置
关闭防火墙
systemctl stop firewalld
systemctl disable firewalld
INSTANCE_NAME = DM02
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
MAL_CHECK_INTERVAL = 60
MAL_CONN_FAIL_INTERVAL = 60
[MAL_INST1]
MAL_INST_NAME = DM01
MAL_HOST = 192.168.147.165
MAL_PORT = 55101
MAL_INST_HOST = 192.168.147.165
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DM02
MAL_HOST = 192.168.147.164
MAL_PORT = 55121
MAL_INST_HOST = 192.168.147.164
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
Vi dmarch.ini ARCH_DEST 部分不一样 其他都一样
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = DM01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dmarch
ARCH_FILE_SIZE = 2048
ARCH_SPACE_LIMIT = 20480
ARCH_FLUSH_BUF_SIZE = 0
ARCH_HANG_FLAG = 1
Vi dmwatcher.ini 和主库一模一样
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
DW_ERROR_TIME = 60
INST_RECOVER_TIME = 60
INST_ERROR_TIME = 60
INST_OGUID = 453331
INST_INI = /dmdata/DAMENG/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dmdmdbms/bin/DAMENG
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0
启动备库
./DAMENG /dmdata/DAMENG/dm.ini mount
./disql SYSDBA/DAMENGSYSDBA 普通状态
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);
第四步:主库、备库启动数据守护
./dmwatcher /dmdata/DAMENG/dmwatcher.ini
第五步:监视器配置
Vi dmmonitor.ini 配置监视器
MON_DW_CONFIRM = 1
MON_LOG_PATH = /dmdata/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.147.165:65101
MON_DW_IP = 192.168.147.164:65121
启动监视器
cd /dm/bin
./dmmonitor /dmdmmonitor.ini
show
login
sysdba
sysdba
switchover
第六步:注册服务
主库注册服务
./dm_service_installer.sh -t DAMENG -dm_ini /dmdata/DAMENG/dm.ini -p DM01 -m mount
./dm_service_installer.sh -t dmwatcher -watcher_ini /dmdata/DAMENG/dmwatcher.ini -p DM01
查是否开机自启动
systemctl list-unit-files
否则执行下
systemctl enable DmServiceDM01
systemctl enable DmWatcherServiceDM01
备库注册服务
./dm_service_installer.sh -t DAMENG -dm_ini /dmdata/DAMENG/dm.ini -p DM02 -m mount
./dm_service_installer.sh -t dmwatcher -watcher_ini /dmdata/DAMENG/dmwatcher.ini -p DM02
查是否开机自启动
systemctl list-unit-files
否则执行
systemctl enable DmServiceDM02
systemctl enable DmWatcherServiceDM02
监视器注册服务
./dm_service_installer.sh -t dmmonitor -monitor_ini /dmdata/DAMENG/dmmonitor.ini -p GRP1
查是否开机自启动
systemctl list-unit-files
否则执行
systemctl enable DmMonitorServiceGRP1
启动关闭集群的顺序 启动 主库服务->备库服务->主库守护->备库守护->监视器 关闭 监视器->备库守护->主库守护->主库服务->备库服务
文章
阅读量
获赞