注册
DCP学习分享以及考试心得
专栏/培训园地/ 文章详情 /

DCP学习分享以及考试心得

Tian. 2024/10/31 403 0 0
摘要

DCP认证学习分享:

达梦DCP培训一共四天,主要学习了以下内容:
达梦数据库运维规范,DM8表管理(堆表,分区表,外部表,临时表),DM8序列,同义词,物化视图,索引,数据迁移,达梦DEM管理,安全管理,快速数据加载,性能优化,DBLINK,数据守护等等

下面是我平时练习的一些笔记:
创建表空间DMTS01初始大小为500MB,每次扩展2MB
create tablespace DMTS01 datafile '/dm8/data/DMTS01.DBF' size 500 autoextend on next 2;
检查:select * from DBA_DATA_FILES;

备份还原:对数据库做完全备份,备份存放路径为/dm8/backup,要求可以把数据库还原到任何一个时刻。

开启数据库归档:
mkdir -p /dm8/arch/DMDB
chown dmdba:dinstall /dm8/arch /dm8/arch/DMDB
disql SYSDBA/Dameng123:5236

数据库配置为mount
alter database mount;
检查:select status$ from v$instance;

配置归档路径:
alter database add archivelog 'DEST=/dm8/arch,TYPE=LOCAL,FILE_SIZE=64,SPACE_LIMIT=0';
检查:select * from v$dm_arch_ini;

开启归档
SQL> alter database archivelog;

启动数据库
SQL> alter database open;
SQL> select status$ from v$instance;
SQL> select arch_mode from v$database;

切换归档
SQL> alter system switch logfile;
SQL> select * from SYS.V$ARCH_FILE;

修改默认备份路径
$ mkdir -p /dm8/backup
$ chown dmdba:dinstall /dm8/backup
$ vi /dm8/data/DMDB/dm.ini
BAK_PATH = /dm8/data/DMDB/bak #backup file path
修改为: BAK_PATH = /dm8/backup #backup file path

需要重启后配置生效
检查:select * from SYS."V$PARAMETER" t where t.NAME = 'BAK_PATH';

在线全备数据库
SQL> backup database full to DBDB_Full backupset '/dm8/backup';
检查:
$ find /dm8/backup
dmrman CTLSTMT="check backupset '/dm8/backup';"

恢复数据库:
/dm8/bin/dmrman
RESTORE DATABASE '/dm8/data/DMDB/dm.ini' FROM BACKUPSET '/dm8/backup'
RECOVER DATABASE '/dm8/data/DMDB/dm.ini' FROM BACKUPSET '/dm8/backup'
RECOVER DATABASE '/dm8/data/DMDB/dm.ini' UPDATE DB_MAGIC

性能优化:
调整buffer缓冲区的大小为800MB。字典缓冲区大小为100MB
SQL> select name,value,sys_value,file_value,type from v$parameter t where name = 'BUFFER';
SQL> sp_set_para_value(2, 'BUFFER', 800);

SQL> select name,value,sys_value,file_value,type from v$parameter t where name = 'DICT_BUF_SIZE';
SQL> sp_set_para_value(2, 'DICT_BUF_SIZE', 10);

需要重启后配置生效
检查:
SQL> select name,value,sys_value,file_value,type from v$parameter t where name = 'BUFFER';
SQL> select name,value,sys_value,file_value,type from v$parameter t where name = 'DICT_BUF_SIZE';

创建序列:
SQL> create sequence DMTEST.SEQ1 start with 100 increment by 1 maxvalue 100000 cycle; --循环

审计:
对DMTEST.TEST表的修改进行审计
切换到sysauditor用户
SQL> sp_set_enable_audit(2); -- 0 :关闭审计,1:打开普通审计,2:打开普通审计和实时审计,缺省值为 0.
SQL> sp_audit_object('UPDATE', 'DMTEST', 'DMTEST', 'TEST', 'ALL');

数据守护:
数据守护端口规划:
数据库名 实例名 PORT_NUM MAL_INST_DW_PORT MAL_HOST MAL_PORT MAL_DW_PORT
GRP1_RT_01 GRP1_RT_01 5236 45101 192.168.1.30 55101 65101
GRP1_RT_03 GRP1_RT_03 5236 45121 192.168.1.20 55121 65121
----先初始化主备库实例,dbca建库,注意名称
或者命令行初始化命令如下:
主库(IP: 192.168.1.30 实例名:GRP1_RT_01):
./dminit path=/dm8/data DB_NAME=GRP1_RT_01 INSTANCE_NAME=GRP1_RT_01 PAGE_SIZE=8 EXTENT_SIZE=16 LOG_SIZE=500 CASE_SENSITIVE=Y SYSDBA_PWD=dameng123

备库(IP: 192.168.1.20 实例名:GRP1_RT_03):
./dminit path=/dm8/data DB_NAME=GRP1_RT_03 INSTANCE_NAME=GRP1_RT_03 PAGE_SIZE=8 EXTENT_SIZE=16 LOG_SIZE=500 CASE_SENSITIVE=Y SYSDBA_PWD=dameng123

--注意 dbca初始化数据库,在初始化过程中会注册数据库服务。如果用命令初始化需要自己手动注册服务,命令如下:
主库:
/dm8/script/root/dm_service_installer.sh -t dmserver -p GRP1_RT_01 -dm_ini /dm8/data/GRP1_RT_01/dm.ini
备库:
/dm8/script/root/dm_service_installer.sh -t dmserver -p GRP1_RT_03 -dm_ini /dm8/data/GRP1_RT_03/dm/.ini

opt/template
--主备两台实例关掉
./DmServiceGRP1_RT_01 stop
./DmServiceGRP1_RT_02 stop

--对主机进行备份:
./dmrman CTLSTMT="BACKUP DATABASE '/dm8/data/GRP1_RT_01/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/dm8/backup/BACKUP_FILE_01'"

--从主传到备
scp -r /dm8/backup/BACKUP_FILE_01 192.168.1.20:/dm8/backup

--在备上进行恢复
./dmrman CTLSTMT="RESTORE DATABASE '/dm8/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/GRP1_RT_03/dm.ini' FROM BACKUPSET '/dm8/backup'"
./dmrman CTLSTMT="RECOVER DATABASE '/dm8/data/GRP1_RT_03/dm.ini' UPDATE DB_MAGIC"

--------主库primary配置------------
dm.ini

INSTANCE_NAME = GRP1_RT_01 --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

MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.1.30 --主机
MAL_PORT = 55101 --
MAL_INST_HOST = 192.168.1.30
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 192.168.1.20
MAL_PORT = 55121
MAL_INST_HOST = 192.168.1.20
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121


dmarch.ini (注:arch_dest备机写主机实例,主机写备机实例)

[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_03
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0


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/GRP1_RT_01/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_SEND_THRESHOLD = 0
RLOG_APPLY_THRESHOLD = 0

启动主库
./dmserver /dm8/data/GRP1_RT_01/dm.ini mount
或者
cd /dm8/bin
./DmServiceGRP1_RT_01 start mount

修改主库的模式和设置oguid。
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);

-------------------------备库standby配置----------------------
standby

dm.ini

INSTANCE_NAME = GRP1_RT_03
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

MAL_CHECK_INTERVAL = 5
MAL_CONN_FAIL_INTERVAL = 5
[MAL_INST1]
MAL_INST_NAME = GRP1_RT_01
MAL_HOST = 192.168.1.30
MAL_PORT = 55101
MAL_INST_HOST = 192.168.1.30
MAL_INST_PORT = 5236
MAL_DW_PORT = 65101
MAL_INST_DW_PORT = 45101
[MAL_INST2]
MAL_INST_NAME = GRP1_RT_03
MAL_HOST = 192.168.1.20
MAL_PORT = 55121
MAL_INST_HOST = 192.168.1.20
MAL_INST_PORT = 5236
MAL_DW_PORT = 65121
MAL_INST_DW_PORT = 45121


dmarch.ini (注:arch_dest备机写主机实例,主机写备机实例)

[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME
ARCH_DEST = GRP1_RT_01
[ARCHIVE_LOCAL1]
ARCH_TYPE = LOCAL
ARCH_DEST = /dm8/arch
ARCH_FILE_SIZE = 128
ARCH_SPACE_LIMIT = 0


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/GRP1_RT_03/dm.ini
INST_AUTO_RESTART = 1
INST_STARTUP_CMD = /dm8/bin/dmserver
RLOG_APPLY_THRESHOLD = 0

以 Mount 方式启动备库
./dmserver /dm8/data/GRP1_RT_03/dm.ini mount
或者
cd /dm8/bin
./DmServiceGRP1_RT_03 start mount

设置备库模式和oguid值
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/GRP1_RT_01/dmwatcher.ini

启备库守护进程
[dmdba@/dm8/bin]#./dmwatcher /dm8/data/GRP1_RT_03/dmwatcher.ini

--配置
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.1.30:65101 --主库 MAL_DW_PORT
MON_DW_IP = 192.168.1.20:65121 --备库 MAL_DW_PORT

8个监视器

--注册监视器服务(也可以不注册)
/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/GRP1_RT_01/dmwatcher.ini
注册备库的守护进程
[root@~]# /dm8/script/root/dm_service_installer.sh -t dmwatcher -p Watcher -watcher_ini /dm8/data/GRP1_RT_03/dmwatcher.ini

关闭确认监视器:./DmMonitorServiceDMMONITOR stop
关闭备库守护进程:./DmWatcherServiceDM2 stop
关闭主库守护进程:./DmWatcherServiceDM1 stop
关闭备库数据库服务:./DmServiceDM2 stop
关闭主库数据库服务:./DmServiceDM1 stop

考试心得:

考试分为理论和实操两部分:
理论考试只要多刷题就能过,考试题百分之九十以上都在模拟题中见过。
实操考试时间4个小时还是有点紧的,平时一定要多加练习,提高效率。
实操考试要点:
初始化实例----建表空间---建用户--角色---权限---分区表----外部表---序列--同义词-- 物化视图----审计(注意验证)--快速装载数据---索引(普通索引,分区索引-全文索引)---优化----会修改参数---备份还原---作业----集群搭建配置

评论
后发表回复

作者

文章

阅读量

获赞

扫一扫
联系客服