环境信息
dwp 192.168.40.11
dws 192.168.40.12
dwm 192.168.40.13
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
DM01 DMSVR01 5236 45101 192.168.40.11 55101 65101
DM01 DMSVR01 5236 45121 192.168.40.12 55121 65121
-------------------------环境初始化-------------------------
---图形化界面安装
(1)第一次启动虚拟机,执行下 xhost +
xhost +
access control disabled, clients can connect from any host
(2)查看 root 用户的 DISPLAY 变量值
echo $DISPLAY
:0.0
(3)切换 dmdba 用户
su - dmdba
export DISPLAY=:0.0
--创建数据库实例
运行 dbca.sh 创建数据库
cd /dm8/tool
./dbca.sh
--查看防火墙状态
systemctl status firewalld.service
--关防火墙
systemctl stop firewalld.service
--注册实例服务(图形化安装不用注册)
[root@~]# /data/dmdbms/script/root/dm_service_installer.sh -t dmserver -p DMSVR01 -dm_ini /data/dmdbms/data/JJDB/dm.ini -m mount
[root@~]# /data/dmdbms/script/root/dm_service_installer.sh -t dmserver -p DMSVR02 -dm_ini /data/dmdbms/data/JJDB/dm.ini -m mount
-----------------------主库--primary---------------
--主库开启本地归档:
ALTER DATABASE MOUNT;
ALTER DATABASE ADD ARCHIVELOG 'TYPE=LOCAL,DEST=/dm8/arch,FILE_SIZE=128,SPACE_LIMIT=0';
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
--停数据库服务
cd /dm8/bin
./DmServiceDMSVR01 stop
-----------------------备库--standby---------------
--停数据库服务
cd /dm8/bin
./DmServiceDMSVR02 stop
-----------------------主库--primary---&备库------------
--创建备份目录
mkdir /dm8/backup
-----------------------主库--primary---------------
--备份主库
./dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/DM01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'"
--传输备份文件
cd /dm8/backup/BACKUP_FILE_01
scp . 192.168.40.12:/dm8/backup
-----------------------备库--standby---------------
--恢复数据三部曲
./dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DM01/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/DM01/dm.ini' UPDATE DB_MAGIC"
-----------------------主库--primary---------------
--检查dm.ini配置文件
cd /dm8/data/DM01
vi 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
--新建dmmal.ini
vi dmmal.ini
MAL_CHECK_INTERVAL = 60 #MAL 链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 60 #判定 MAL 链路断开的时间
[MAL_INST1]
MAL_INST_NAME = DMSVR01 #实例名, 和 dm.ini 的 INSTANCE_NAME 一致
MAL_HOST = 192.168.40.11 #MAL 系统监听 TCP 连接的 IP 地址
MAL_PORT = 55101 #MAL 系统监听 TCP 连接的端口
MAL_INST_HOST = 192.168.40.11 #实例的对外服务 IP 地址
MAL_INST_PORT = 5236 #实例对外服务端口, 和 dm.ini 的 PORT_NUM 一致
MAL_DW_PORT = 65101 #实例对应的守护进程监听 TCP 连接的端口
MAL_INST_DW_PORT = 45101 #实例监听守护进程 TCP 连接的端口
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.40.12
MAL_PORT = 55121
MAL_INST_HOST = 192.168.40.12
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
--更新dmarch.ini
vi dmarch.ini
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME #实时归档类型
ARCH_DEST = DMSVR02 #实时归档目标实例名
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST = /dm8/arch #本地归档存放路径
ARCH_FILE_SIZE = 128 #单个归档大小, 单位 MB
ARCH_SPACE_LIMIT = 0 #归档上限, 单位 MB
--创建dmwatcher.ini
vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = MANUAL #故障手动切换模式
DW_ERROR_TIME = 10 #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #本地实例故障认定时间
INST_ERROR_TIME = 10 #主库守护进程启动恢复的间隔时间
INST_OGUID = 453331 #守护系统唯一 OGUID 值
INST_INI = /dm8/data/DM01/dm.ini #dm.ini 文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dm8/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阈值, 默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阈值, 默认关闭
--注册守护进程
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DM01/dmwatcher.ini
--以Mount方式启动主库
cd /dm8/bin
./dmserver /dm8/data/DM01/dm.ini mount
或者
cd /dm8/bin
./DmServiceDMSVR02 mount
--进入命令行
./disql sysdba/DM01SYSDBA@localhost:5236
--修改参数
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
sp_set_oguid(453331);
alter database primary;
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
-----------------------备库--standby---------------
--检查dm.ini配置文件
cd /dm8/data/DM01
vi 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
--新建dmmal.ini
vi dmmal.ini
MAL_CHECK_INTERVAL = 60
MAL_CONN_FAIL_INTERVAL = 60
[MAL_INST1]
MAL_INST_NAME = DMSVR01
MAL_HOST = 192.168.40.11
MAL_PORT = 55101
MAL_INST_HOST = 192.168.40.11
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = DMSVR02
MAL_HOST = 192.168.40.12
MAL_PORT = 55121
MAL_INST_HOST = 192.168.40.12
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121
--更新dmarch.ini
vi 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
--创建dmwatcher.ini
vi dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL
DW_MODE = MANUAL
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
--以Mount方式启动备库
cd /dm8/bin
./dmserver /dm8/data/DM01/dm.ini mount
--进入命令行
./disql sysdba/DM01SYSDBA@localhost:5236
--修改参数
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 1);
sp_set_oguid(453331);
alter database standby;
SP_SET_PARA_VALUE(1, 'ALTER_MODE_STATUS', 0);
--注册守护进程
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/DM01/dmwatcher.ini
--启动守护进程
--主库&备库
./dmwatcher /dm8/data/DM01/dmwatcher.ini
./dmwatcher /dm8/data/DM01/dmwatcher.ini
----------------监视器----------------
cd /dm8/bin
--创建dmmonitor.ini
vi dmmonitor.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
[GRP1]
MON_INST_OGUID = 453331
MON_DW_IP = 192.168.40.11:65101
MON_DW_IP = 192.168.40.12:65121
--启动监视器
在bin目录下
./dmmonitor /dm8/bin/dmmonitor.ini
show验证一下
--输入
login
--查看是否可以切换
choose switchover GRP1
手动主备切换
switchover
文章
阅读量
获赞