• 达梦8.0主备安装


    主库IP: 192.168.44.102 dmprimary
    备库IP: 192.168.44.101 dmstandby

    1.安装软件:

    mount -o loop /root/dm8_20220901_x86_rh6_64_ent_8.6.1.120.iso /dmdb

    1.1.创建用户、组

    groupadd -g 12349 dinstall
    useradd -u 12345 -g dinstall -m -d /home/dmdba -s /bin/bash dmdba

    3.初始化用户密码。

    passwd dmdba

    su - dmdba
    mkdir -p /opt/dmdbms/data/DAMENG5237/backup /opt/dmdbms/data /opt/dmdbms/data/DAMENG5237/arch /opt/dmdbms/data/DAMENG5237/log /opt/dmdbms/product
    mkdir -p /opt/dmdbms/tmp
    chown -R dmdba:dinstall /opt/dmdbms/tmp
    chmod -R 777 /opt/dmdbms/tmp
    chown -R dmdba:dinstall /opt/dmdbms

    vi /etc/profile
    DM_INSTALL_TMPDIR=/opt/dmdbms/tmp
    export DM_INSTALL_TMPDIR

    1.2.软件安装

    [root@dmstandby dmdb]# ./DMInstall.bin -i
    Please select the installer’s language (E/e:English C/c:Chinese) [E/e]:E
    Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n
    Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
    TimeZone:
    Please Select the TimeZone [21]:21
    Installation Type:
    1 Typical
    2 Server
    3 Client
    4 Custom
    Please Input the number of the Installation Type [1 Typical]:4

    Please Input the number of the Installation Type [1 2 3 4 5]:
    Require Space: 1573M
    Please Input the install path [/opt/dmdbms/product]:
    Available Space:31G
    Please Confirm the install path(/opt/dmdbms/product)? (Y/y:Yes N/n:No) [Y/y]:y
    Pre-Installation Summary
    Installation Location: /opt/dmdbms/product
    Require Space: 1573M
    Available Space: 31G
    Version Information:
    Expire Date:
    Installation Type: Custom
    Confirm to Install? (Y/y:Yes N/n:No):y
    2022-09-26 19:10:33
    [INFO] Installing DM DBMS…
    。。
    [INFO] Installed DM DBMS completely.
    End

    2.主库设置
    2.1.创建主库

    su - dmdba
    [dmdba@dmstandby ~]$ cd /opt/dmdbms/product/bin
    [dmdba@dmstandby bin]$ /opt/dmdbms/product/bin/dminit path=/opt/dmdbms/data PAGE_SIZE=32 EXTENT_SIZE=32 CASE_SENSITIVE=y CHARSET=1 DB_NAME=DAMENG5237 INSTANCE_NAME=DBSERVER5237 PORT_NUM=5237 SYSDBA_PWD=DAMENG.5237

    2.2.注册服务

    [root@dmprimary root]# /opt/dmdbms/product/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dmdbms/data/DAMENG5237/dm.ini -p DMSERVER5237
    Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceDMSERVER5237.service to /usr/lib/systemd/system/DmServiceDMSERVER5237.service.
    Finished to create the service (DmServiceDMSERVER5237)

    2.3.配置主库归档模式

    su - root
    systemctl start DmServiceDMSERVER5237.service

    su - dmdba
    /opt/dmdbms/product/bin/disql sysdba/DAMENG.5237@127.0.0.1:5237

    su - dmdba
    disql sysdba/DAMENG5237123
    alter database mount;
    alter database add archivelog ‘dest=/opt/dmdbms/data/DAMENG5237/arch,TYPE=local,FILE_SIZE=2048’;
    alter database archivelog;
    alter database open;

    select name,arch_mode from v$database;

    3.从库设置
    3.1.创建从库

    su - dmdba
    [dmdba@dmstandby ~]$ cd /opt/dmdbms/product/bin
    [dmdba@dmstandby bin]$ /opt/dmdbms/product/bin/dminit path=/opt/dmdbms/data PAGE_SIZE=32 EXTENT_SIZE=32 CASE_SENSITIVE=y CHARSET=1 DB_NAME=DAMENG5237 INSTANCE_NAME=DBSERVER5237R PORT_NUM=5237 SYSDBA_PWD=DAMENG.5237

    3.2.注册服务

    su - root
    [root@dmprimary root]# /opt/dmdbms/script/root/dm_service_installer.sh -t dmserver -dm_ini /opt/dmdbms/data/DAMENG5237/dm.ini -p DmServiceDMSERVER5237
    systemctl start DmServiceDMSERVER5237
    systemctl stop DmServiceDMSERVER5237

    4.主库备份数据
    1、关闭主库,以 dmrman 备份数据库

    su - root
    [root@dmprimary arch]# systemctl stop DmServiceDMSERVER5237

    su - dmdba
    [dmdba@dmprimary service_template]$ /opt/dmdbms/product/bin/service_template/DmAPService start
    [dmdba@dmprimary bin]$ /opt/dmdbms/product/bin/dmrman
    dmrman V8

    RMAN> backup database ‘/opt/dmdbms/data/DAMENG5237/dm.ini’ backupset ‘/opt/dmdbms/data/DAMENG5237/backup’;
    backup database ‘/opt/dmdbms/data/DAMENG5237/dm.ini’ backupset ‘/opt/dmdbms/data/DAMENG5237/backup’;
    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[48149], file_lsn[48149]
    Processing backupset /opt/dmdbms/data/DAMENG5237/backup
    [Percent:30.77%][Speed:63.87M/s][Cost:00:00:04][Remaining:00:00:02]
    [Percent:100.00%][Speed:0.00M/s][Cost:00:00:06][Remaining:00:00:00]
    backup successfully!
    time used: 00:00:07.991

    拷贝:

    [dmdba@dmprimary backup]$ scp /opt/dmdbms/data/DAMENG5237/backup/ 192.168.44.101:/opt/dmdbms/data/DAMENG5237/backup/

    5.在备库恢复数据

    [root@dmstandby root]# su - dmdba
    mkdir -p /opt/dmdbms/data/DAMENG5237/backup

    还原:

    [dmdba@dmstandby service_template]$ /opt/dmdbms/product/bin/service_template/DmAPService start
    Starting DmAPService: [ OK ]

    [dmdba@dmstandby bin]$ /opt/dmdbms/product/bin/dmrman

    CHECK BACKUPSET ‘/opt/dmdbms/data/DAMENG5237/backup’ ;
    RESTORE DATABASE ‘/opt/dmdbms/data/DAMENG5237/dm.ini’ FROM BACKUPSET ‘/opt/dmdbms/data/DAMENG5237/backup’;
    recover database ‘/opt/dmdbms/data/DAMENG5237/dm.ini’ from backupset ‘/opt/dmdbms/data/DAMENG5237/backup/’;
    recover database ‘/opt/dmdbms/data/DAMENG5237/dm.ini’ update db_magic;

    6.配置文件设置
    6.1.修改主库dm.ini文件

    ALTER_MODE_STATUS = 0 ##不允许手工方式修改实例模式/状态/OGUID
    ENABLE_OFFLINE_TS = 2 ##不允许备库 OFFLINE 表空间
    MAL_INI = 1 ##打开 MAL 系统
    ARCH_INI = 1 ##打开归档配置
    ALTER_TABLE_OPT=3 ##加快带默认值的字段添加(看情况需要)

    6.2.生成主库dmmal.ini文件

    [dmdba@dmprimary DAMENG5237]$ cat dmmal.ini
    MAL_CHECK_INTERVAL = 5 #MAL 链路检测时间间隔
    MAL_CONN_FAIL_INTERVAL = 5 #判定 MAL 链路断开的时间
    [MAL_INST1]
    MAL_INST_NAME = DBSERVER5237 #实例名,和 dm.ini 中的 INSTANCE_NAME 一致
    MAL_HOST = 192.168.44.102 #MAL 系统监听 TCP 连接的 IP 地址
    MAL_PORT = 65237 #MAL 系统监听 TCP 连接的端口
    MAL_INST_HOST = 192.168.44.102 #实例的对外服务 IP 地址
    MAL_INST_PORT = 5237 #实例的对外服务端口,dm.ini 中的 PORT_NUM 一致
    MAL_DW_PORT = 55237 #实例对应的守护进程监听 TCP 连接的端口
    MAL_INST_DW_PORT = 35237 #实例监听守护进程 TCP 连接的端口

    [MAL_INST2]
    MAL_INST_NAME = DBSERVER5237R
    MAL_HOST = 192.168.44.101
    MAL_PORT = 65237
    MAL_INST_HOST = 192.168.44.101
    MAL_INST_PORT = 5237
    MAL_DW_PORT = 55237
    MAL_INST_DW_PORT = 35237

    6.3.生成主库dmarch.ini文件

    [ARCHIVE_REALTIME1]
    ARCH_TYPE = REALTIME #实时归档类型
    ARCH_DEST = DBSERVER5237R #实时归档目标实例名,这里是备库的实例名
    [ARCHIVE_LOCAL1]
    ARCH_TYPE = LOCAL #本地归档类型
    ARCH_DEST = /opt/dmdbms/data/DAMENG5237/arch #本地归档文件存放路径
    ARCH_FILE_SIZE = 2024 #单位Mb,本地单个归档文件最大值
    ARCH_SPACE_LIMIT = 0 #单位Mb,0 表示无限制,范围 1024~4294967294M
    ARCH_FLUSH_BUF_SIZE = 0
    ARCH_HANG_FLAG = 1

    6.4.生成主库dmwatcher.ini文件

    [dmdba@dmprimary DAMENG5237]$ cat dmwatcher.ini
    [GRP1]
    DW_TYPE = GLOBAL ##全局守护类型
    DW_MODE = AUTO ##手工切换 AUTO自动切换模式必须部署一个确认监视器,在集群中每个节点必须配置一致,不能一个是自动,一个是手动
    DW_ERROR_TIME = 10 ##远程守护进程故障认定时间
    INST_RECOVER_TIME = 60 ##主库守护进程启动恢复的间隔时间
    INST_ERROR_TIME = 10 ##本地实例故障认定时间
    INST_OGUID = 455237 ##守护系统唯一 OGUID 值
    INST_INI = /opt/dmdbms/data/DAMENG5237/dm.ini #dm.ini配置文件路径
    INST_AUTO_RESTART = 1 ##打开实例的自动启动功能,若配置为0的话,数据库shutdown后,dmwatch守护进程不会把数据库拉起来
    INST_STARTUP_CMD = /opt/dmdbms/product/bin/dmserver #命令行方式启动
    RLOG_SEND_THRESHOLD = 0 ##指定主库发送日志到备库的时间阀值,默认关闭
    RLOG_APPLY_THRESHOLD = 0 ##指定备库重演日志的时间阀值,默认关闭

    6.5.监视器配置文件dmmonitor.ini

    MON_DW_Confirm = 1 ## 0表示普通监视器 ,最多配置8个,1 确认监视器模式
    MON_LOG_PATH = /opt/dmdbms/data/DAMENG5237/log ##监视器日志文件存放路径
    MON_LOG_INTERVAL = 60 ##每隔 60s 定时记录系统信息到日志文件
    MON_LOG_FILE_SIZE = 256 ##每个日志文件最大 256M
    MON_LOG_SPACE_LIMIT = 0 ##不限定日志文件总占用空间
    [GRP1]
    MON_INST_OGUID = 455237 #组 GRP1 的唯一OGUID 值
    ##配置为监视器到组GRP1的守护进程的连接信息以―IP:PORT‖的形式配置
    ##IP对应dmmal.ini中的 MAL_HOST,PORT 对应 dmmal.ini 中的 MAL_DW_PORT
    MON_DW_IP = 192.168.44.102:55237
    MON_DW_IP = 192.168.44.101:55237

    6.6.拷贝ini文档到备库

    拷贝dm.ini、dmwatcher.ini、dmmonitor.ini、dmarch.ini、dmmal.ini到备库
    [dmdba@dmprimary backup]$ scp /opt/dmdbms/data/DAMENG5237/*.ini 192.168.44.101:/opt/dmdbms/data/DAMENG5237/

    注意从库中dm.ini、dmarch.ini 需要修改对应的
    dm.ini 中的 INST_NAME = DBSERVER5237R
    dmarch.ini 中的 ARCH_DEST = DBSERVER5237

    修改 /opt/dmdbms/product/bin/DmServiceDMSERVER5237 将启动模式由open改为mount

    7.主备同步设置
    7.1.注册DmWatcherService服务

    su - root
    [root@dmprimary root]# /opt/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -p GRP5237 -watcher_ini /opt/dmdbms/data/DAMENG5237/dmwatcher.ini
    Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServiceGRP5237.service to /usr/lib/systemd/system/DmWatcherServiceGRP5237.service.
    Finished to create the service (DmWatcherServiceGRP5237)

    su - root
    [root@dmstandby root]# /opt/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -p GRP5237 -watcher_ini /opt/dmdbms/data/DAMENG5237/dmwatcher.ini
    Created symlink from /etc/systemd/system/multi-user.target.wants/DmWatcherServiceGRP5237.service to /usr/lib/systemd/system/DmWatcherServiceGRP5237.service.
    Finished to create the service (DmWatcherServiceGRP5237)

    [root@host134 system]# ls -al /usr/lib/systemd/system/Dm*

    7.2.注册dmmonitor服务
    主备注册监听器服务,但一般只在备库上开启服务

    su - root
    [root@dmstandby root]# cd /opt/dmdbms/script/root
    [root@dmstandby root]#/opt/dmdbms/script/root/dm_service_installer.sh -t dmmonitor -p Monitor5237 -monitor_ini /opt/dmdbms/data/DAMENG5237/dmmonitor.ini
    Created symlink from /etc/systemd/system/multi-user.target.wants/DmMonitorServiceMonitor52375237.service to /usr/lib/systemd/system/DmMonitorServiceMonitor52375237.service.
    Finished to create the service (DmMonitorServiceMonitor52375237)

    8.启动主备库

    主备库都启动,启动的状态是open模式,会破坏主从关系,使用后台命令的方式启动mount 或者 修改 /opt/dmdbms/product/bin/DmServiceDMSERVER5237 将启动模式由open改为mount。
    这里采取修改修改 /opt/dmdbms/product/bin/DmServiceDMSERVER5237 将启动模式由open改为mount

    su - dmdba
    [root@dmprimary root]# su - dmdba

    [dmdba@dmprimary ~]$ nohup /opt/dmdbms/product/bin/dmserver /opt/dmdbms/data/DAMENG5237/dm.ini mount>dmserver.log &

    systemctl start DmServiceDMSERVER5237

    root@dmstandby root]# su - dmdba

    [dmdba@dmstandby ~]$ nohup /opt/dmdbms/product/bin/dmserver /opt/dmdbms/data/DAMENG5237/dm.ini mount>dmserver.log &

    systemctl start DmServiceDMSERVER5237

    [root@dmprimary dmdba]# /opt/dmdbms/product/bin/disql sysdba/DAMENG.5237@127.0.0.1:5237
    SQL> select status , m o d e ,mode ,mode from v i n s t a n c e ; L I N E I D S T A T U S instance; LINEID STATUS instance;LINEIDSTATUS MODE$


    1 MOUNT NORMAL

    [root@dmstandby dmdba]# /opt/dmdbms/product/bin/disql sysdba/DAMENG.5237@127.0.0.1:5237
    SQL> select status , m o d e ,mode ,mode from v i n s t a n c e ; L I N E I D S T A T U S instance; LINEID STATUS instance;LINEIDSTATUS MODE$


    1 MOUNT NORMAL

    8.1.主备库的oguid/role配置
    8.1.1.A.主库dmprimary

    /opt/dmdbms/product/bin/disql sysdba/DAMENG.5237@127.0.0.1:5237
    SQL>sp_set_oguid(455237);
    SQL>alter database primary;

    8.1.2.B.备库dmstandby

    /opt/dmdbms/product/bin/disql sysdba/DAMENG.5237@127.0.0.1:5237
    SQL>sp_set_oguid(455237);
    SQL>alter database standby;

    这个时候主备库三个实例额度状态都是mount状态的,下面需要启动dmwatcher,把实例状态拉起来

    select status$ from v i n s t a n c e ; L I N E I D S T A T U S instance; LINEID STATUS instance;LINEIDSTATUS


    1 MOUNT

    8.2.启动dmwatcher
    每个实例都启动(root账号)

    [root@dmprimary root]# systemctl start DmWatcherServiceGRP5237
    SQL> select status , m o d e ,mode ,mode from v$instance;

    LINEID STATUS$ MODE$


    1 OPEN PRIMARY
    [root@dmstandby root]# systemctl start DmWatcherServiceGRP5237
    SQL> select status , m o d e ,mode ,mode from v$instance;

    LINEID STATUS$ MODE$


    1 OPEN STANDBY

    我们的监视器是配置在备库上面的:
    启动监视器进程

    [root@mstandby root]# systemctl start DmMonitorServiceMonitor5237

    8.3.测试
    主库上创建表空间和用户

    create tablespace tps_hxl datafile ‘/opt/dmdbms/data/DAMENG5237/tps_hxl01.DBF’ size 1024 autoextend on maxsize 32768;
    create user hxl identified by DAMENG5237123 default tablespace tps_hxl default index tablespace tps_hxl;
    grant dba to hxl;

    从库查看表空间和用户

    select tablespace_name from SYS.DBA_TABLESPACES;
    select username from SYS.DBA_USERS;

    9.监视器监控相关:

    cp /opt/dmdbms/data/DAMENG5237/dmmonitor.ini /opt/dmdbms/data/DAMENG5237/dmmonitor0.ini
    修改监视器配置文件dmmonitor.ini
    MON_DW_Confirm = 0 ## 0表示普通监视器 ,最多配置8个,1 确认监视器模式

    [dmdba@dmstandby ~]$ /opt/dmdbms/product/bin/dmmonitor /opt/dmdbms/data/DAMENG5237/dmmonitor0.ini

    10.删除实例
    1、删除服务

    su - root
    [root@dmstandby root]# pwd
    /opt/dmdbms/script/root
    ./dm_service_uninstaller.sh -n DmServiceDMSERVER5237

    2、删除数据库目录

    [root@host134 root]# su - dmdba
    [dmdba@host134 data]$ cd /opt/dmdbms/data
    [dmdba@host134 data]$ rm -rf DAMENG5237

  • 相关阅读:
    智能自动化输送分拣集成设备|快递自动分拣设备厂家告诉您如何提高10倍分拣效率
    鸿蒙系统优缺点,能否作为开发者选择
    prometheus+springboot监控项目状态
    Elastic Stack容器化部署拓展(Https、AD域集成)并收集Cisco设备的日志信息
    裁员浪潮,回顾一下自己去年的毕业吧(二)
    6-Mysql子查询,多表连接(内连接,外连接,交叉连接)
    k8s Limits 限制内存
    mysql主从复制
    java计算机毕业设计学生健康信息管理源码+系统+mysql数据库+lw文档
    晕,考试的几何画板迭代问题
  • 原文地址:https://blog.csdn.net/u010719917/article/details/127449678