A机器 |
B机器 |
|
业务IP |
10.16.216.80(217没有配置暂时使用216网段) |
10.16.216.81 |
心跳IP |
10.16.217.10 |
10.16.217.11 |
实例名 |
NBSJ_01 |
NBSJ_02 |
实例端口 |
5236 |
5236 |
MAL端口 |
61141 |
61142 |
MAL守护进程端口 |
52141 |
52142 |
守护进程端口 |
33141 |
33142 |
OGUID |
453331 |
|
守护组 |
GRP1 |
|
安装目录 |
/dmsoft/dmdbms |
|
实例目录 |
/data/ |
|
归档上限 |
10240 (单位M) |
|
监视器IP |
确认监视器:10.16.216.82 非确认监视器:10.16.216.83 |
心跳网络方面:①集群间的心跳网络要走数据,最好走两个交换机,来实现冗余和负载均衡。②需要把服务器多个心跳网卡绑定为一个逻辑网卡来使用(比如bond方式)。③交换机速度建议至少为千兆。
存储方面:①需要在每台机器上挂在独立存储,其中主机所在机器挂载的存储建议大一些。②需要格式化好,且所有机器挂载路径保持一致。③在空间不够用时,要求支持在挂载目录上直接进行扩充。④文件系统建议使用ext4。
心跳网络方面:①关闭其中一台交换机或者模拟其中一条线路故障,是否能做到网络方面的冗余。②测试心跳网络的稳定性,会不会出现断连或者丢包等情况。
存储方面:反复重启集群机器,检查存储是否会出现只读、脱挂、挂载路径是否会发生改变等情况。
主库数据库参数优化脚本:
/*
**************************************************************************
* *
* Auto parameter adjustment 2.6 *
* [November 16, 2021 ]
* Written by Mr. Huanghaiming *
* Take effect after restart dmserver
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='WORKER_THREADS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TASK_THREADS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='IO_THR_GROUPS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_OS_MEMORY' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_POOL' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_N_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='BUFFER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_BUFFER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='BUFFER_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RECYCLE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RECYCLE_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='FAST_POOL_PAGES' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='FAST_ROLL_PAGES' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_MAGIC_CHECK' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_FREQROOTS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HJ_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HJ_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HAGR_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HAGR_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BLK_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RLOG_POOL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='CACHE_POOL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='DICT_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='VM_POOL_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SESS_POOL_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='USE_PLN_POOL' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_MONITOR' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SVR_LOG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TEMP_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TEMP_SPACE_LIMIT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_SESSIONS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_SESSION_STATEMENT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PK_WITH_CLUSTER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_ENCRYPT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='OLAP_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='VIEW_PULLUP_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='OPTIMIZER_MODE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ADAPTIVE_NPLN_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PARALLEL_PURGE_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PARALLEL_POLICY' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='UNDO_EXTENT_NUM'UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_INJECT_HINT';
* *
**************************************************************************
*/
declare
exec_mode int:= 1; --0表示直接执行脚本修改参数,1表示不直接修改参数,打印设置参数的语句,设置为1后,必须调整v_mem_mb和v_cpus
mem_per int:= 90; --默认所有的内存归达梦数据库使用,如实际不能100%可用,可以调整此参数
v_mem_mb int:= 64000; --根据机器实际内存调整此参数
v_cpus int:= 32; --根据机器实际CPU核数调整此参数
tname varchar(100);
MEMORY_POOL int;
MEMORY_N_POOLS int;
MEMORY_TARGET int;
BUFFER INT;
MAX_BUFFER INT;
RECYCLE int;
CACHE_POOL_SIZE int;
BUFFER_POOLS int;
RECYCLE_POOLS int;
SORT_BUF_SIZE int;
SORT_BUF_GLOBAL_SIZE INT;
DICT_BUF_SIZE INT;
HJ_BUF_SIZE INT;
HAGR_BUF_SIZE INT;
HJ_BUF_GLOBAL_SIZE INT;
HAGR_BUF_GLOBAL_SIZE INT;
SORT_FLAG INT;
SORT_BLK_SIZE INT;
RLOG_POOL_SIZE INT;
TASK_THREADS INT;
IO_THR_GROUPS INT;
FAST_POOL_PAGES INT :=3000;
FAST_ROLL_PAGES INT :=1000;
CNT INT;
begin
CNT :=0;
if exec_mode=0 then
SELECT TOP 1 N_CPU,TOTAL_PHY_SIZE/1024/1024 INTO v_cpus,v_mem_mb FROM V$SYSTEMINFO;
end if;
v_mem_mb := v_mem_mb * (mem_per/100.0);
v_mem_mb=round(v_mem_mb,-3);
IF v_mem_mb <= 2000 THEN
goto return_2000;
END IF;
IF v_mem_mb > 512000 THEN
v_mem_mb :=v_mem_mb*0.8;
END IF;
MEMORY_TARGET=round(cast(v_mem_mb * 0.12 as int),-3);
TASK_THREADS :=4;
IO_THR_GROUPS :=4;
IF v_cpus < 8 THEN
TASK_THREADS :=4;
IO_THR_GROUPS :=2;
END IF;
IF v_cpus >= 64 THEN
v_cpus := 64;
TASK_THREADS :=16;
IO_THR_GROUPS :=8;
END IF;
BUFFER := round(cast(v_mem_mb * 0.4 as int),-3);
MAX_BUFFER := BUFFER;
RECYCLE :=cast(v_mem_mb * 0.04 as int);
IF v_mem_mb < 70000 THEN
with t as
(
select rownum rn from dual connect by level <= 100
) ,
t1 as
(
select * from t where rn > 1 minus
select
ta.rn * tb.rn
from
t ta,
t tb
where
ta.rn <= tb.rn
and ta.rn > 1
and tb.rn > 1
)
select top 1 rn into BUFFER_POOLS from t1 where rn > v_mem_mb/800 order by 1;
--设置根据内存情况RECYCLE_POOLS参数
with t as
(
select rownum rn from dual connect by level <= 100
) ,
t1 as
(
select * from t where rn > 1 minus
select
ta.rn * tb.rn
from
t ta,
t tb
where
ta.rn <= tb.rn
and ta.rn > 1
and tb.rn > 1
)
select top 1 rn into RECYCLE_POOLS from t1 where rn > v_mem_mb/800/3 order by 1;
ELSE
BUFFER_POOLS := 101;
RECYCLE_POOLS := 41;
END IF;
--修改内存池
IF v_mem_mb >= 16000 THEN
IF v_mem_mb= 16000 THEN
MEMORY_POOL := 1500;
SORT_BUF_GLOBAL_SIZE := 1000;
MEMORY_N_POOLS := 3;
CACHE_POOL_SIZE := 512;
ELSE
MEMORY_POOL := 2000;
SORT_BUF_GLOBAL_SIZE := 2000;
MEMORY_N_POOLS := 11;
CACHE_POOL_SIZE := 1024;
END IF;
FAST_POOL_PAGES :=9999;
SORT_FLAG = 0;
SORT_BLK_SIZE=1;
SORT_BUF_SIZE := 10;
RLOG_POOL_SIZE := 1024;
HJ_BUF_GLOBAL_SIZE := LEAST(cast(v_mem_mb * 0.0625 as int),10000);
HAGR_BUF_GLOBAL_SIZE := LEAST(cast(v_mem_mb * 0.0625 as int),10000);
HJ_BUF_SIZE :=250;
HAGR_BUF_SIZE :=250;
RECYCLE :=round(RECYCLE,-3);
IF v_mem_mb >= 64000 THEN
FAST_POOL_PAGES :=99999;
FAST_ROLL_PAGES :=9999;
BUFFER :=BUFFER-3000;
MAX_BUFFER :=BUFFER;
CACHE_POOL_SIZE := 2048;
RLOG_POOL_SIZE := 2048;
SORT_FLAG = 1;
SORT_BLK_SIZE=1;
SORT_BUF_SIZE=50;
SORT_BUF_GLOBAL_SIZE= cast(v_mem_mb * 0.02 as int);
HJ_BUF_GLOBAL_SIZE := cast(v_mem_mb * 0.15625 as int);
HAGR_BUF_GLOBAL_SIZE := cast(v_mem_mb * 0.04 as int);
HJ_BUF_SIZE :=512;
HAGR_BUF_SIZE :=512;
MEMORY_N_POOLS := 59;
END IF;
DICT_BUF_SIZE := 50;
HJ_BUF_GLOBAL_SIZE :=round(HJ_BUF_GLOBAL_SIZE,-3);
HAGR_BUF_GLOBAL_SIZE :=round(HAGR_BUF_GLOBAL_SIZE,-3);
SORT_BUF_GLOBAL_SIZE :=round(SORT_BUF_GLOBAL_SIZE,-3);
RECYCLE :=round(RECYCLE,-3);
ELSE
MEMORY_POOL :=GREAT(cast(v_mem_mb * 0.0625 as int),100);
MEMORY_POOL :=round(MEMORY_POOL,-2);
MEMORY_N_POOLS := 1;
CACHE_POOL_SIZE := 200;
RLOG_POOL_SIZE := 256;
SORT_BUF_SIZE := 10;
SORT_BUF_GLOBAL_SIZE := 500;
DICT_BUF_SIZE := 50;
SORT_FLAG = 0;
SORT_BLK_SIZE=1;
HJ_BUF_GLOBAL_SIZE := GREAT(cast(v_mem_mb * 0.0625 as int),500);
HAGR_BUF_GLOBAL_SIZE := GREAT(cast(v_mem_mb * 0.0625 as int),500);
HJ_BUF_SIZE := GREAT(cast(v_mem_mb * 0.00625 as int),50);
HAGR_BUF_SIZE :=GREAT(cast(v_mem_mb * 0.00625 as int),50);
END IF;
tname :='BAK_DMINI_' || to_char(sysdate,'yymmdd');
execute IMMEDIATE 'select count(*) from USER_ALL_TABLES where table_name= ?' into CNT using tname;
IF CNT=0 THEN
execute IMMEDIATE 'CREATE TABLE BAK_DMINI_' || to_char(sysdate,'yymmdd') || ' as select *,sysdate uptime from v$dm_ini';
ELSE
execute IMMEDIATE 'INSERT INTO BAK_DMINI_' || to_char(sysdate,'yymmdd') || ' select *,sysdate uptime from v$dm_ini';
END IF;
IF exec_mode=0 THEN
--修改cpu相关参数
SP_SET_PARA_VALUE(2,'WORKER_THREADS',v_cpus);
SP_SET_PARA_VALUE(2,'TASK_THREADS',TASK_THREADS);
SP_SET_PARA_VALUE(2,'IO_THR_GROUPS',IO_THR_GROUPS);
--修改内存池相关参数
SP_SET_PARA_VALUE(2,'MAX_OS_MEMORY', mem_per);
SP_SET_PARA_VALUE(2,'MEMORY_POOL', MEMORY_POOL);
SP_SET_PARA_VALUE(2,'MEMORY_N_POOLS', MEMORY_N_POOLS);
SP_SET_PARA_VALUE(2,'MEMORY_TARGET', MEMORY_TARGET);
--修改内存检测参数为1
SP_SET_PARA_VALUE(2,'MEMORY_MAGIC_CHECK', 1);
--非DSC环境将ENABLE_FREQROOTS设置为1,注意DM7 v$instance视图没有dsc_role字段,DM7这部分可以删掉
if exists(select 1 from v$instance where dsc_role = 'NULL') then
SP_SET_PARA_VALUE(2,'ENABLE_FREQROOTS', 1);
end if;
--修改缓冲区相关参数
SP_SET_PARA_VALUE(2,'BUFFER', BUFFER);
SP_SET_PARA_VALUE(2,'MAX_BUFFER', MAX_BUFFER);
SP_SET_PARA_VALUE(2,'BUFFER_POOLS', BUFFER_POOLS);
SP_SET_PARA_VALUE(2,'RECYCLE', RECYCLE);
SP_SET_PARA_VALUE(2,'RECYCLE_POOLS', RECYCLE_POOLS);
--修改fast_pool相关参数
SP_SET_PARA_VALUE(2,'FAST_POOL_PAGES', FAST_POOL_PAGES);
SP_SET_PARA_VALUE(2,'FAST_ROLL_PAGES', FAST_ROLL_PAGES);
--修改HASH相关参数
SP_SET_PARA_VALUE(1,'HJ_BUF_GLOBAL_SIZE', HJ_BUF_GLOBAL_SIZE);
SP_SET_PARA_VALUE(1,'HJ_BUF_SIZE', HJ_BUF_SIZE );
SP_SET_PARA_VALUE(1,'HAGR_BUF_GLOBAL_SIZE',HAGR_BUF_GLOBAL_SIZE);
SP_SET_PARA_VALUE(1,'HAGR_BUF_SIZE', HAGR_BUF_SIZE );
--修改排序相关参数
SP_SET_PARA_VALUE(2,'SORT_FLAG',SORT_FLAG);
SP_SET_PARA_VALUE(2,'SORT_BLK_SIZE',SORT_BLK_SIZE);
SP_SET_PARA_VALUE(2,'SORT_BUF_SIZE', SORT_BUF_SIZE);
SP_SET_PARA_VALUE(2,'SORT_BUF_GLOBAL_SIZE', SORT_BUF_GLOBAL_SIZE);
--修改其他内存参数
SP_SET_PARA_VALUE(2,'RLOG_POOL_SIZE', RLOG_POOL_SIZE);
SP_SET_PARA_VALUE(2,'CACHE_POOL_SIZE', CACHE_POOL_SIZE);
SP_SET_PARA_VALUE(2,'DICT_BUF_SIZE', DICT_BUF_SIZE);
SP_SET_PARA_VALUE(2,'VM_POOL_TARGET', 16384);
SP_SET_PARA_VALUE(2,'SESS_POOL_TARGET', 16384);
--修改实例相关参数
SP_SET_PARA_VALUE(2,'USE_PLN_POOL', 1);
SP_SET_PARA_VALUE(2,'ENABLE_MONITOR', 1);
SP_SET_PARA_VALUE(2,'SVR_LOG', 1);
SP_SET_PARA_VALUE(2,'TEMP_SIZE', 1024);
SP_SET_PARA_VALUE(2,'TEMP_SPACE_LIMIT', 102400);
SP_SET_PARA_VALUE(2,'MAX_SESSIONS', 1500);
SP_SET_PARA_VALUE(2,'MAX_SESSION_STATEMENT', 20000);
SP_SET_PARA_VALUE(2,'PK_WITH_CLUSTER', 0);
SP_SET_PARA_VALUE(2,'ENABLE_ENCRYPT',0);
--修改优化器相关参数
SP_SET_PARA_VALUE(2,'OLAP_FLAG',2);
SP_SET_PARA_VALUE(2,'VIEW_PULLUP_FLAG',1);
SP_SET_PARA_VALUE(2,'OPTIMIZER_MODE',1);
SP_SET_PARA_VALUE(2,'ADAPTIVE_NPLN_FLAG',0);
--开启并行PURGE
SP_SET_PARA_VALUE(2,'PARALLEL_PURGE_FLAG',1);
--开启手动并行
SP_SET_PARA_VALUE(2,'PARALLEL_POLICY',2);
--UNDO_RETENTION如果放大,可以适当调大UNDO_EXTENT_NUM。负载高的时候,减少文件系统的申请/释放操作。
SP_SET_PARA_VALUE(2,'UNDO_EXTENT_NUM',16);
--开启SQL 注入HINT功能
SP_SET_PARA_VALUE(2,'ENABLE_INJECT_HINT',1);
ELSE
--修改cpu相关参数
PRINT 'SP_SET_PARA_VALUE(2,''WORKER_THREADS'','||v_cpus||');';
PRINT 'SP_SET_PARA_VALUE(2,''TASK_THREADS'','||TASK_THREADS||');';
PRINT 'SP_SET_PARA_VALUE(2,''IO_THR_GROUPS'','||IO_THR_GROUPS||');';
--修改内存池相关参数
PRINT 'SP_SET_PARA_VALUE(2,''MAX_OS_MEMORY'', '||mem_per||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_POOL'', '||MEMORY_POOL||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_N_POOLS'', '||MEMORY_N_POOLS||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_TARGET'', '||MEMORY_TARGET||');';
--修改缓冲区相关参数
PRINT 'SP_SET_PARA_VALUE(2,''BUFFER'', '||BUFFER||');';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_BUFFER'', '||MAX_BUFFER||');';
PRINT 'SP_SET_PARA_VALUE(2,''BUFFER_POOLS'', '||BUFFER_POOLS||');';
PRINT 'SP_SET_PARA_VALUE(2,''RECYCLE'', '||RECYCLE||');';
PRINT 'SP_SET_PARA_VALUE(2,''RECYCLE_POOLS'', '||RECYCLE_POOLS||');';
--修改fast_pool相关参数
PRINT 'SP_SET_PARA_VALUE(2,''FAST_POOL_PAGES'', '||FAST_POOL_PAGES||');';
PRINT 'SP_SET_PARA_VALUE(2,''FAST_ROLL_PAGES'', '||FAST_ROLL_PAGES||');';
--修改内存检测参数为1
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_MAGIC_CHECK'', 1);';
--非DSC环境将ENABLE_FREQROOTS设置为1,注意DM7 v$instance视图没有dsc_role字段,DM7这部分可以删掉
if exists(select 1 from v$instance where dsc_role = 'NULL') then
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_FREQROOTS'', 1);';
end if;
--修改HASH相关参数
PRINT 'SP_SET_PARA_VALUE(1,''HJ_BUF_GLOBAL_SIZE'', '||HJ_BUF_GLOBAL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HJ_BUF_SIZE'', '||HJ_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HAGR_BUF_GLOBAL_SIZE'','||HAGR_BUF_GLOBAL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HAGR_BUF_SIZE'', '||HAGR_BUF_SIZE||');';
--修改排序相关参数
PRINT 'SP_SET_PARA_VALUE(2,''SORT_FLAG'','||SORT_FLAG||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BLK_SIZE'','||SORT_BLK_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BUF_SIZE'', '||SORT_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BUF_GLOBAL_SIZE'', '||SORT_BUF_GLOBAL_SIZE||');';
--修改其他内存参数
PRINT 'SP_SET_PARA_VALUE(2,''RLOG_POOL_SIZE'', '||RLOG_POOL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''CACHE_POOL_SIZE'', '||CACHE_POOL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''DICT_BUF_SIZE'', '||DICT_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''VM_POOL_TARGET'', 16384);';
PRINT 'SP_SET_PARA_VALUE(2,''SESS_POOL_TARGET'', 16384);';
--修改实例相关参数
PRINT 'SP_SET_PARA_VALUE(2,''USE_PLN_POOL'', 1);';
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_MONITOR'', 1);';
PRINT 'SP_SET_PARA_VALUE(2,''SVR_LOG'', 0);';
PRINT 'SP_SET_PARA_VALUE(2,''TEMP_SIZE'', 1024);';
PRINT 'SP_SET_PARA_VALUE(2,''TEMP_SPACE_LIMIT'', 102400);';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_SESSIONS'', 1500);';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_SESSION_STATEMENT'', 20000);';
PRINT 'SP_SET_PARA_VALUE(2,''PK_WITH_CLUSTER'', 0);';
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_ENCRYPT'',0);';
--修改优化器相关参数
PRINT 'SP_SET_PARA_VALUE(2,''OLAP_FLAG'',2);';
PRINT 'SP_SET_PARA_VALUE(2,''VIEW_PULLUP_FLAG'',1);';
PRINT 'SP_SET_PARA_VALUE(2,''OPTIMIZER_MODE'',1);';
PRINT 'SP_SET_PARA_VALUE(2,''ADAPTIVE_NPLN_FLAG'',0);';
--开启并行PURGE
PRINT 'SP_SET_PARA_VALUE(2,''PARALLEL_PURGE_FLAG'',1);';
--开启手动并行
PRINT 'SP_SET_PARA_VALUE(2,''PARALLEL_POLICY'',2);';
--UNDO_RETENTION如果放大,可以适当调大UNDO_EXTENT_NUM。负载高的时候,减少文件系统的申请/释放操作。
PRINT 'SP_SET_PARA_VALUE(2,''UNDO_EXTENT_NUM'',16);';
--开启SQL 注入HINT功能
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_INJECT_HINT'',1);';
END IF;
select MEMORY_TARGET+BUFFER+RECYCLE+HJ_BUF_GLOBAL_SIZE+HAGR_BUF_GLOBAL_SIZE+CACHE_POOL_SIZE
+DICT_BUF_SIZE+SORT_BUF_GLOBAL_SIZE+RLOG_POOL_SIZE;
exception
when others then
raise_application_error (-20001,substr( ' 执行失败, '||SQLCODE||' '||SQLERRM||' '||dbms_utility.format_error_backtrace , 1, 400));
<
end;
备库参数优化脚本:
/*
**************************************************************************
* *
* Auto parameter adjustment 2.6 *
* [November 16, 2021 ]
* Written by Mr. Huanghaiming *
* Take effect after restart dmserver
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='WORKER_THREADS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TASK_THREADS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='IO_THR_GROUPS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_OS_MEMORY' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_POOL' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_N_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='BUFFER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_BUFFER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='BUFFER_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RECYCLE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RECYCLE_POOLS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='FAST_POOL_PAGES' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='FAST_ROLL_PAGES' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MEMORY_MAGIC_CHECK' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_FREQROOTS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HJ_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HJ_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HAGR_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='HAGR_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BLK_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SORT_BUF_GLOBAL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='RLOG_POOL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='CACHE_POOL_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='DICT_BUF_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='VM_POOL_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SESS_POOL_TARGET' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='USE_PLN_POOL' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_MONITOR' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='SVR_LOG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TEMP_SIZE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='TEMP_SPACE_LIMIT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_SESSIONS' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='MAX_SESSION_STATEMENT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PK_WITH_CLUSTER' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_ENCRYPT' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='OLAP_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='VIEW_PULLUP_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='OPTIMIZER_MODE' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ADAPTIVE_NPLN_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PARALLEL_PURGE_FLAG' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='PARALLEL_POLICY' UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='UNDO_EXTENT_NUM'UNION ALL
SELECT PARA_NAME,PARA_VALUE FROM V$DM_INI WHERE PARA_NAME='ENABLE_INJECT_HINT';
* *
**************************************************************************
*/
declare
exec_mode int:= 1; --0表示直接执行脚本修改参数,1表示不直接修改参数,打印设置参数的语句,设置为1后,必须调整v_mem_mb和v_cpus
mem_per int:= 90; --默认所有的内存归达梦数据库使用,如实际不能100%可用,可以调整此参数
v_mem_mb int:= 64000; --根据机器实际内存调整此参数
v_cpus int:= 32; --根据机器实际CPU核数调整此参数
tname varchar(100);
MEMORY_POOL int;
MEMORY_N_POOLS int;
MEMORY_TARGET int;
BUFFER INT;
MAX_BUFFER INT;
RECYCLE int;
CACHE_POOL_SIZE int;
BUFFER_POOLS int;
RECYCLE_POOLS int;
SORT_BUF_SIZE int;
SORT_BUF_GLOBAL_SIZE INT;
DICT_BUF_SIZE INT;
HJ_BUF_SIZE INT;
HAGR_BUF_SIZE INT;
HJ_BUF_GLOBAL_SIZE INT;
HAGR_BUF_GLOBAL_SIZE INT;
SORT_FLAG INT;
SORT_BLK_SIZE INT;
RLOG_POOL_SIZE INT;
TASK_THREADS INT;
IO_THR_GROUPS INT;
FAST_POOL_PAGES INT :=3000;
FAST_ROLL_PAGES INT :=1000;
CNT INT;
begin
CNT :=0;
if exec_mode=0 then
SELECT TOP 1 N_CPU,TOTAL_PHY_SIZE/1024/1024 INTO v_cpus,v_mem_mb FROM V$SYSTEMINFO;
end if;
v_mem_mb := v_mem_mb * (mem_per/100.0);
v_mem_mb=round(v_mem_mb,-3);
IF v_mem_mb <= 2000 THEN
goto return_2000;
END IF;
IF v_mem_mb > 512000 THEN
v_mem_mb :=v_mem_mb*0.8;
END IF;
MEMORY_TARGET=round(cast(v_mem_mb * 0.12 as int),-3);
TASK_THREADS :=4;
IO_THR_GROUPS :=4;
IF v_cpus < 8 THEN
TASK_THREADS :=4;
IO_THR_GROUPS :=2;
END IF;
IF v_cpus >= 64 THEN
v_cpus := 64;
TASK_THREADS :=16;
IO_THR_GROUPS :=8;
END IF;
BUFFER := round(cast(v_mem_mb * 0.4 as int),-3);
MAX_BUFFER := BUFFER;
RECYCLE :=cast(v_mem_mb * 0.04 as int);
IF v_mem_mb < 70000 THEN
with t as
(
select rownum rn from dual connect by level <= 100
) ,
t1 as
(
select * from t where rn > 1 minus
select
ta.rn * tb.rn
from
t ta,
t tb
where
ta.rn <= tb.rn
and ta.rn > 1
and tb.rn > 1
)
select top 1 rn into BUFFER_POOLS from t1 where rn > v_mem_mb/800 order by 1;
--设置根据内存情况RECYCLE_POOLS参数
with t as
(
select rownum rn from dual connect by level <= 100
) ,
t1 as
(
select * from t where rn > 1 minus
select
ta.rn * tb.rn
from
t ta,
t tb
where
ta.rn <= tb.rn
and ta.rn > 1
and tb.rn > 1
)
select top 1 rn into RECYCLE_POOLS from t1 where rn > v_mem_mb/800/3 order by 1;
ELSE
BUFFER_POOLS := 101;
RECYCLE_POOLS := 41;
END IF;
--修改内存池
IF v_mem_mb >= 16000 THEN
IF v_mem_mb= 16000 THEN
MEMORY_POOL := 1500;
SORT_BUF_GLOBAL_SIZE := 1000;
MEMORY_N_POOLS := 3;
CACHE_POOL_SIZE := 512;
ELSE
MEMORY_POOL := 2000;
SORT_BUF_GLOBAL_SIZE := 2000;
MEMORY_N_POOLS := 11;
CACHE_POOL_SIZE := 1024;
END IF;
FAST_POOL_PAGES :=9999;
SORT_FLAG = 0;
SORT_BLK_SIZE=1;
SORT_BUF_SIZE := 10;
RLOG_POOL_SIZE := 1024;
HJ_BUF_GLOBAL_SIZE := LEAST(cast(v_mem_mb * 0.0625 as int),10000);
HAGR_BUF_GLOBAL_SIZE := LEAST(cast(v_mem_mb * 0.0625 as int),10000);
HJ_BUF_SIZE :=250;
HAGR_BUF_SIZE :=250;
RECYCLE :=round(RECYCLE,-3);
IF v_mem_mb >= 64000 THEN
FAST_POOL_PAGES :=99999;
FAST_ROLL_PAGES :=9999;
BUFFER :=BUFFER-3000;
MAX_BUFFER :=BUFFER;
CACHE_POOL_SIZE := 2048;
RLOG_POOL_SIZE := 2048;
SORT_FLAG = 1;
SORT_BLK_SIZE=1;
SORT_BUF_SIZE=50;
SORT_BUF_GLOBAL_SIZE= cast(v_mem_mb * 0.02 as int);
HJ_BUF_GLOBAL_SIZE := cast(v_mem_mb * 0.15625 as int);
HAGR_BUF_GLOBAL_SIZE := cast(v_mem_mb * 0.04 as int);
HJ_BUF_SIZE :=512;
HAGR_BUF_SIZE :=512;
MEMORY_N_POOLS := 59;
END IF;
DICT_BUF_SIZE := 50;
HJ_BUF_GLOBAL_SIZE :=round(HJ_BUF_GLOBAL_SIZE,-3);
HAGR_BUF_GLOBAL_SIZE :=round(HAGR_BUF_GLOBAL_SIZE,-3);
SORT_BUF_GLOBAL_SIZE :=round(SORT_BUF_GLOBAL_SIZE,-3);
RECYCLE :=round(RECYCLE,-3);
ELSE
MEMORY_POOL :=GREAT(cast(v_mem_mb * 0.0625 as int),100);
MEMORY_POOL :=round(MEMORY_POOL,-2);
MEMORY_N_POOLS := 1;
CACHE_POOL_SIZE := 200;
RLOG_POOL_SIZE := 256;
SORT_BUF_SIZE := 10;
SORT_BUF_GLOBAL_SIZE := 500;
DICT_BUF_SIZE := 50;
SORT_FLAG = 0;
SORT_BLK_SIZE=1;
HJ_BUF_GLOBAL_SIZE := GREAT(cast(v_mem_mb * 0.0625 as int),500);
HAGR_BUF_GLOBAL_SIZE := GREAT(cast(v_mem_mb * 0.0625 as int),500);
HJ_BUF_SIZE := GREAT(cast(v_mem_mb * 0.00625 as int),50);
HAGR_BUF_SIZE :=GREAT(cast(v_mem_mb * 0.00625 as int),50);
END IF;
tname :='BAK_DMINI_' || to_char(sysdate,'yymmdd');
execute IMMEDIATE 'select count(*) from USER_ALL_TABLES where table_name= ?' into CNT using tname;
IF CNT=0 THEN
execute IMMEDIATE 'CREATE TABLE BAK_DMINI_' || to_char(sysdate,'yymmdd') || ' as select *,sysdate uptime from v$dm_ini';
ELSE
execute IMMEDIATE 'INSERT INTO BAK_DMINI_' || to_char(sysdate,'yymmdd') || ' select *,sysdate uptime from v$dm_ini';
END IF;
IF exec_mode=0 THEN
--修改cpu相关参数
SP_SET_PARA_VALUE(2,'WORKER_THREADS',v_cpus);
SP_SET_PARA_VALUE(2,'TASK_THREADS',TASK_THREADS);
SP_SET_PARA_VALUE(2,'IO_THR_GROUPS',IO_THR_GROUPS);
--修改内存池相关参数
SP_SET_PARA_VALUE(2,'MAX_OS_MEMORY', mem_per);
SP_SET_PARA_VALUE(2,'MEMORY_POOL', MEMORY_POOL);
SP_SET_PARA_VALUE(2,'MEMORY_N_POOLS', MEMORY_N_POOLS);
SP_SET_PARA_VALUE(2,'MEMORY_TARGET', MEMORY_TARGET);
--修改内存检测参数为1
SP_SET_PARA_VALUE(2,'MEMORY_MAGIC_CHECK', 1);
--非DSC环境将ENABLE_FREQROOTS设置为1,注意DM7 v$instance视图没有dsc_role字段,DM7这部分可以删掉
if exists(select 1 from v$instance where dsc_role = 'NULL') then
SP_SET_PARA_VALUE(2,'ENABLE_FREQROOTS', 1);
end if;
--修改缓冲区相关参数
SP_SET_PARA_VALUE(2,'BUFFER', BUFFER);
SP_SET_PARA_VALUE(2,'MAX_BUFFER', MAX_BUFFER);
SP_SET_PARA_VALUE(2,'BUFFER_POOLS', BUFFER_POOLS);
SP_SET_PARA_VALUE(2,'RECYCLE', RECYCLE);
SP_SET_PARA_VALUE(2,'RECYCLE_POOLS', RECYCLE_POOLS);
--修改fast_pool相关参数
SP_SET_PARA_VALUE(2,'FAST_POOL_PAGES', FAST_POOL_PAGES);
SP_SET_PARA_VALUE(2,'FAST_ROLL_PAGES', FAST_ROLL_PAGES);
--修改HASH相关参数
SP_SET_PARA_VALUE(1,'HJ_BUF_GLOBAL_SIZE', HJ_BUF_GLOBAL_SIZE);
SP_SET_PARA_VALUE(1,'HJ_BUF_SIZE', HJ_BUF_SIZE );
SP_SET_PARA_VALUE(1,'HAGR_BUF_GLOBAL_SIZE',HAGR_BUF_GLOBAL_SIZE);
SP_SET_PARA_VALUE(1,'HAGR_BUF_SIZE', HAGR_BUF_SIZE );
--修改排序相关参数
SP_SET_PARA_VALUE(2,'SORT_FLAG',SORT_FLAG);
SP_SET_PARA_VALUE(2,'SORT_BLK_SIZE',SORT_BLK_SIZE);
SP_SET_PARA_VALUE(2,'SORT_BUF_SIZE', SORT_BUF_SIZE);
SP_SET_PARA_VALUE(2,'SORT_BUF_GLOBAL_SIZE', SORT_BUF_GLOBAL_SIZE);
--修改其他内存参数
SP_SET_PARA_VALUE(2,'RLOG_POOL_SIZE', RLOG_POOL_SIZE);
SP_SET_PARA_VALUE(2,'CACHE_POOL_SIZE', CACHE_POOL_SIZE);
SP_SET_PARA_VALUE(2,'DICT_BUF_SIZE', DICT_BUF_SIZE);
SP_SET_PARA_VALUE(2,'VM_POOL_TARGET', 16384);
SP_SET_PARA_VALUE(2,'SESS_POOL_TARGET', 16384);
--修改实例相关参数
SP_SET_PARA_VALUE(2,'USE_PLN_POOL', 1);
SP_SET_PARA_VALUE(2,'ENABLE_MONITOR', 1);
SP_SET_PARA_VALUE(2,'SVR_LOG', 1);
SP_SET_PARA_VALUE(2,'TEMP_SIZE', 1024);
SP_SET_PARA_VALUE(2,'TEMP_SPACE_LIMIT', 102400);
SP_SET_PARA_VALUE(2,'MAX_SESSIONS', 1500);
SP_SET_PARA_VALUE(2,'MAX_SESSION_STATEMENT', 20000);
SP_SET_PARA_VALUE(2,'PK_WITH_CLUSTER', 0);
SP_SET_PARA_VALUE(2,'ENABLE_ENCRYPT',0);
--修改优化器相关参数
SP_SET_PARA_VALUE(2,'OLAP_FLAG',2);
SP_SET_PARA_VALUE(2,'VIEW_PULLUP_FLAG',1);
SP_SET_PARA_VALUE(2,'OPTIMIZER_MODE',1);
SP_SET_PARA_VALUE(2,'ADAPTIVE_NPLN_FLAG',0);
--开启并行PURGE
SP_SET_PARA_VALUE(2,'PARALLEL_PURGE_FLAG',1);
--开启手动并行
SP_SET_PARA_VALUE(2,'PARALLEL_POLICY',2);
--UNDO_RETENTION如果放大,可以适当调大UNDO_EXTENT_NUM。负载高的时候,减少文件系统的申请/释放操作。
SP_SET_PARA_VALUE(2,'UNDO_EXTENT_NUM',16);
--开启SQL 注入HINT功能
SP_SET_PARA_VALUE(2,'ENABLE_INJECT_HINT',1);
ELSE
--修改cpu相关参数
PRINT 'SP_SET_PARA_VALUE(2,''WORKER_THREADS'','||v_cpus||');';
PRINT 'SP_SET_PARA_VALUE(2,''TASK_THREADS'','||TASK_THREADS||');';
PRINT 'SP_SET_PARA_VALUE(2,''IO_THR_GROUPS'','||IO_THR_GROUPS||');';
--修改内存池相关参数
PRINT 'SP_SET_PARA_VALUE(2,''MAX_OS_MEMORY'', '||mem_per||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_POOL'', '||MEMORY_POOL||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_N_POOLS'', '||MEMORY_N_POOLS||');';
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_TARGET'', '||MEMORY_TARGET||');';
--修改缓冲区相关参数
PRINT 'SP_SET_PARA_VALUE(2,''BUFFER'', '||BUFFER||');';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_BUFFER'', '||MAX_BUFFER||');';
PRINT 'SP_SET_PARA_VALUE(2,''BUFFER_POOLS'', '||BUFFER_POOLS||');';
PRINT 'SP_SET_PARA_VALUE(2,''RECYCLE'', '||RECYCLE||');';
PRINT 'SP_SET_PARA_VALUE(2,''RECYCLE_POOLS'', '||RECYCLE_POOLS||');';
--修改fast_pool相关参数
PRINT 'SP_SET_PARA_VALUE(2,''FAST_POOL_PAGES'', '||FAST_POOL_PAGES||');';
PRINT 'SP_SET_PARA_VALUE(2,''FAST_ROLL_PAGES'', '||FAST_ROLL_PAGES||');';
--修改内存检测参数为1
PRINT 'SP_SET_PARA_VALUE(2,''MEMORY_MAGIC_CHECK'', 1);';
--非DSC环境将ENABLE_FREQROOTS设置为1,注意DM7 v$instance视图没有dsc_role字段,DM7这部分可以删掉
if exists(select 1 from v$instance where dsc_role = 'NULL') then
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_FREQROOTS'', 1);';
end if;
--修改HASH相关参数
PRINT 'SP_SET_PARA_VALUE(1,''HJ_BUF_GLOBAL_SIZE'', '||HJ_BUF_GLOBAL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HJ_BUF_SIZE'', '||HJ_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HAGR_BUF_GLOBAL_SIZE'','||HAGR_BUF_GLOBAL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(1,''HAGR_BUF_SIZE'', '||HAGR_BUF_SIZE||');';
--修改排序相关参数
PRINT 'SP_SET_PARA_VALUE(2,''SORT_FLAG'','||SORT_FLAG||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BLK_SIZE'','||SORT_BLK_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BUF_SIZE'', '||SORT_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''SORT_BUF_GLOBAL_SIZE'', '||SORT_BUF_GLOBAL_SIZE||');';
--修改其他内存参数
PRINT 'SP_SET_PARA_VALUE(2,''RLOG_POOL_SIZE'', '||RLOG_POOL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''CACHE_POOL_SIZE'', '||CACHE_POOL_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''DICT_BUF_SIZE'', '||DICT_BUF_SIZE||');';
PRINT 'SP_SET_PARA_VALUE(2,''VM_POOL_TARGET'', 16384);';
PRINT 'SP_SET_PARA_VALUE(2,''SESS_POOL_TARGET'', 16384);';
--修改实例相关参数
PRINT 'SP_SET_PARA_VALUE(2,''USE_PLN_POOL'', 1);';
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_MONITOR'', 1);';
PRINT 'SP_SET_PARA_VALUE(2,''SVR_LOG'', 0);';
PRINT 'SP_SET_PARA_VALUE(2,''TEMP_SIZE'', 1024);';
PRINT 'SP_SET_PARA_VALUE(2,''TEMP_SPACE_LIMIT'', 102400);';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_SESSIONS'', 1500);';
PRINT 'SP_SET_PARA_VALUE(2,''MAX_SESSION_STATEMENT'', 20000);';
PRINT 'SP_SET_PARA_VALUE(2,''PK_WITH_CLUSTER'', 0);';
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_ENCRYPT'',0);';
--修改优化器相关参数
PRINT 'SP_SET_PARA_VALUE(2,''OLAP_FLAG'',2);';
PRINT 'SP_SET_PARA_VALUE(2,''VIEW_PULLUP_FLAG'',1);';
PRINT 'SP_SET_PARA_VALUE(2,''OPTIMIZER_MODE'',1);';
PRINT 'SP_SET_PARA_VALUE(2,''ADAPTIVE_NPLN_FLAG'',0);';
--开启并行PURGE
PRINT 'SP_SET_PARA_VALUE(2,''PARALLEL_PURGE_FLAG'',1);';
--开启手动并行
PRINT 'SP_SET_PARA_VALUE(2,''PARALLEL_POLICY'',2);';
--UNDO_RETENTION如果放大,可以适当调大UNDO_EXTENT_NUM。负载高的时候,减少文件系统的申请/释放操作。
PRINT 'SP_SET_PARA_VALUE(2,''UNDO_EXTENT_NUM'',16);';
--开启SQL 注入HINT功能
PRINT 'SP_SET_PARA_VALUE(2,''ENABLE_INJECT_HINT'',1);';
END IF;
select MEMORY_TARGET+BUFFER+RECYCLE+HJ_BUF_GLOBAL_SIZE+HAGR_BUF_GLOBAL_SIZE+CACHE_POOL_SIZE
+DICT_BUF_SIZE+SORT_BUF_GLOBAL_SIZE+RLOG_POOL_SIZE;
exception
when others then
raise_application_error (-20001,substr( ' 执行失败, '||SQLCODE||' '||SQLERRM||' '||dbms_utility.format_error_backtrace , 1, 400));
<
end;
集群部署完成后可以用参数优化脚本对数据库配置文件dm.ini中参数进行优化。
优化过程:打开优化脚本后复制内容到管理工具中执行,将输出结果在数据库管理工具中执行后重启数据库集群,使配置的参数生效。
使用root用户登录数据库服务器,在/etc/security/limits.conf 配置文件中设置他们的文件描述符极限,
在该文件的最后,添加如下四行:
[root@~]# cd /etc/security
[root@~]#cp limits.conf limits.conf_20161225_bak
[root@~]#vim /etc/security/limits.conf
dmdba soft nofile 65536
dmdba hard nofile 65536
dmdba soft nproc 10240
dmdba hard nproc 10240
修改完毕之后,source /etc/security/limits.conf;
等服务器起来之后,使用dmdba用户进行登录,通过ulimit -a查看上述两个参数是否已经生效。
所有需要安装数据库软件的服务器都需要创建用户
创建安装用户组(root用户操作)
[root@~]#groupadd dinstall
创建安装用户(root用户操作)
[root@~]# useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
初始化用户密码(root用户操作)
[root@~]#passwd dmdba
密码:Dameng@123
变更/data目录所属的用户和组(root用户操作)
[root@~]#chown -R dmdba:dinstall /data
[root@~]#chown -R dmdba:dinstall /dmsoft
使用dmdba用户给/data目录授权(dmdba用户操作)
[root@~]#chmod -R 755 /data
[root@~]#chmod -R 755 /dmsoft
挂载iso安装文件后,进入挂载目录,执行安装命令
[dmdba@~]#./DMInstall.bin -i
请选择安装语言(C/c:中文 E/e:英文) [C/c]:
解压安装程序...
欢迎使用达梦数据库安装程序
是否输入Key文件路径? (Y/y:是 N/n:否) [Y/y]:N
是否设置时区? (Y/y:是 N/n:否) [Y/y]:
设置时区:
[ 1]: GTM-12=日界线西
[ 2]: GTM-11=萨摩亚群岛
[ 3]: GTM-10=夏威夷
[ 4]: GTM-09=阿拉斯加
[ 5]: GTM-08=太平洋时间(美国和加拿大)
[ 6]: GTM-07=亚利桑那
[ 7]: GTM-06=中部时间(美国和加拿大)
[ 8]: GTM-05=东部部时间(美国和加拿大)
[ 9]: GTM-04=大西洋时间(美国和加拿大)
[10]: GTM-03=巴西利亚
[11]: GTM-02=中大西洋
[12]: GTM-01=亚速尔群岛
[13]: GTM=格林威治标准时间
[14]: GTM+01=萨拉热窝
[15]: GTM+02=开罗
[16]: GTM+03=莫斯科
[17]: GTM+04=阿布扎比
[18]: GTM+05=伊斯兰堡
[19]: GTM+06=达卡
[20]: GTM+07=曼谷,河内
[21]: GTM+08=中国标准时间
[22]: GTM+09=汉城
[23]: GTM+10=关岛
[24]: GTM+11=所罗门群岛
[25]: GTM+12=斐济
[26]: GTM+13=努库阿勒法
[27]: GTM+14=基里巴斯
请选择设置时区 [21]:
安装类型:
1 典型安装
2 服务器
3 客户端
4 自定义
请选择安装类型的数字序号 [1 典型安装]:
所需空间: 733M
请选择安装目录 [/home/dmdba/dmdbms]:/dmsoft/dmdbms/
可用空间: 473109M
是否确认安装路径? (Y/y:是 N/n:否) [Y/y]:
安装前小结
安装位置: /dmsoft/dmdbms
所需空间: 733M
可用空间: 473109M
版本信息: 企业版
有效日期: 2018-02-13
安装类型: 典型安装
是否确认安装 (Y/y,N/n) [Y/y]:
2017-07-31 10:06:35
[INFO] 安装达梦数据库...
2017-07-31 10:06:35
[INFO] 安装 default 模块...
2017-07-31 10:06:37
[INFO] 安装 server 模块...
2017-07-31 10:06:37
[INFO] 安装 client 模块...
2017-07-31 10:06:38
[INFO] 安装 drivers 模块...
2017-07-31 10:06:38
[INFO] 安装 manual 模块...
2017-07-31 10:06:38
[INFO] 安装 service 模块...
2017-07-31 10:06:41
[INFO] 移动ant日志文件。
2017-07-31 10:06:41
[INFO] 安装达梦数据库完成。
按照提示执行脚本:
--初始化实例
cd /dmsoft/dmdbms/bin
[dmdba@~]# ./dminit path=/data/ page_size=32 EXTENT_SIZE=32 log_size=2048 case_sensitive=n charset=1
--前台启动服务
[dmdba@~]# ./dmserver /data/DAMENG/dm.ini
--关闭前台数据库服务:exit
--修改/data/DAMENG/dm.ini配置文件
[dmdba@~]# vim /data/DAMENG/dm.ini
修改内容:
INSTANCE_NAME = NBSJ_01 #修改实例名
DW_INACTIVE_INTERVAL = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI = 1 #打开归档配置
SVR_LOG = 1 #开启sql日志记录
[dmdba@~]# vi /data/DAMENG/dmarch.ini
[ARCHIVE_LOCAL]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST = /data/DAMENG/arch/ #本地归档存放路径
ARCH_FILE_SIZE = 1024 #单个归档大小,单位MB
ARCH_SPACE_LIMIT = 10240 #归档上限,单位MB 根据系统修改
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME #实时归档类型
ARCH_DEST = NBSJ_02 #实时归档目标实例名 写备的实例名
[dmdba@~]# vi /data/DAMENG/dmmal.ini
MAL_CHECK_INTERVAL = 5 #MAL 链路检测时间间隔
MAL_CONN_FAIL_INTERVAL = 5 #判定 MAL 链路断开的时间
[MAL_INST1]
MAL_INST_NAME = NBSJ_01 #实例名,和 dm.ini 中的 INSTANCE_NAME 一致
MAL_HOST = 10.16.217.10 #MAL系统监听 TCP 连接的 IP 地址 心跳的
MAL_PORT = 61141 #MAL 系统监听 TCP 连接的端口
MAL_INST_HOST = 10.16.216.80 #实例的对外服务 IP 地址
MAL_INST_PORT = 5236 #实例的对外服务端口,和 dm.ini 中的 PORT_NUM 一致
MAL_DW_PORT = 52141 #实例本地的守护进程监听 TCP 连接的端口
MAL_INST_DW_PORT = 33141 #实例监听守护进程 TCP连接的端口
[MAL_INST2]
MAL_INST_NAME = NBSJ_02
MAL_HOST = 10.16.217.11
MAL_PORT = 61142
MAL_INST_HOST = 10.16.216.81
MAL_INST_PORT = 5236
MAL_DW_PORT = 52142
MAL_INST_DW_PORT = 33142
[dmdba@~]# vi /data/DAMENG/dmwatcher.ini
[GRP1]
DW_TYPE = GLOBAL #全局守护类型
DW_MODE = AUTO #自动切换模式
DW_ERROR_TIME = 10 #远程守护进程故障认定时间
INST_RECOVER_TIME = 60 #主库守护进程启动恢复的间隔时间
INST_ERROR_TIME = 10 #本地实例故障认定时间
INST_OGUID = 453331 #守护系统唯一 OGUID 值
INST_INI = /data/DAMENG/dm.ini #dm.ini 配置文件路径
INST_AUTO_RESTART = 1 #打开实例的自动启动功能
INST_STARTUP_CMD = /dmsoft/dmdbms/bin/dmserver #命令行方式启动
RLOG_SEND_THRESHOLD = 0 #指定主库发送日志到备库的时间阀值,默认关闭
RLOG_APPLY_THRESHOLD = 0 #指定备库重演日志的时间阀值,默认关闭
[dmdba@~]# vim /data/DAMENG/sqllog.ini
BUF_TOTAL_SIZE = 10240 #SQLs Log Buffer Total Size(K)(1024~1024000)
BUF_SIZE = 1024 #SQLs Log Buffer Size(K)(50~409600)
BUF_KEEP_CNT = 6 #SQLs Log buffer keeped count(1~100)
[SLOG_ALL]
FILE_PATH = ../log/logcommit
PART_STOR = 0
SWITCH_MODE = 2
SWITCH_LIMIT = 1024
ASYNC_FLUSH = 1
FILE_NUM = 10
ITEMS = 0
SQL_TRACE_MASK = 1
MIN_EXEC_TIME = 0
USER_MODE = 0
USERS =
--创建日志目录
[dmdba@~]# mkdir /dmsoft/dmdbms/log/logcommit
[dmdba@~]# cd /dmsoft/dmdbms/bin
[dmdba@~]# ./dmrman CTLSTMT="BACKUP DATABASE '/data/DAMENG/dm.ini' FULL TO BACKUP_FILE1 BACKUPSET '/data/DAMENG/bak/BACKUP_FILE_0120'"
[dmdba@~]# scp -r /data/DAMENG/bak/BACKUP_FILE_0117 [email protected]:/data/DAMENG/bak
用root用户注册数据库服务
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmserver -p _LTCIS01 -dm_ini /data/DAMENG/dm.ini -m mount
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -p _LTCIS01 -watcher_ini /data/DAMENG/dmwatcher.ini
先按照章节1步骤修改参数、创建用户、安装达梦软件等
--初始化实例
cd /dmsoft/dmdbms/bin
[dmdba@~]# ./dminit path=/data/ page_size=32 EXTENT_SIZE=32 log_size=2048 case_sensitive=n charset=1
--前台启动服务
[dmdba@~]# ./dmserver /data/DAMENG/dm.ini
--关闭前台数据库服务:exit
--修改/data/DAMENG/dm.ini配置文件
[dmdba@~]# vi /data/DAMENG/dm.ini
INSTANCE_NAME = NBSJ_02
DW_INACTIVE_INTERVAL = 60 #接收守护进程消息超时时间
ALTER_MODE_STATUS = 0 #不允许手工方式修改实例模式/状态/OGUID
ENABLE_OFFLINE_TS = 2 #不允许备库 OFFLINE 表空间
MAL_INI = 1 #打开 MAL 系统
ARCH_INI = 1 #打开归档配置
SVR_LOG = 1 #开启sql日志记录
[dmdba@~]# vi /data/DAMENG/dmarch.ini
[ARCHIVE_LOCAL]
ARCH_TYPE = LOCAL #本地归档类型
ARCH_DEST = /data/DAMENG/arch/ #本地归档存放路径
ARCH_FILE_SIZE = 1024 #单个归档大小,单位MB
ARCH_SPACE_LIMIT = 10240 #归档上限,单位MB
[ARCHIVE_REALTIME]
ARCH_TYPE = REALTIME #实时归档类型
ARCH_DEST = NBSJ_01 #实时归档目标实例名,写主的实例名
与A机器DW1_01的dmmal.ini、dmwatcher.ini相同
用root用户注册数据库服务
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmserver -p _LTCIS02 -dm_ini /data/DAMENG/dm.ini -m mount
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmwatcher -p _LTCIS02 -watcher_ini /data/DAMENG/dmwatcher.ini
cd /dmsoft/dmdbms/bin
[dmdba@~]# ./dmrman CTLSTMT="RESTORE DATABASE '/data/DAMENG/dm.ini' FROM BACKUPSET '/data/DAMENG/bak/BACKUP_FILE_0120'"
[dmdba@~]# ./dmrman CTLSTMT="RECOVER DATABASE '/data/DAMENG/dm.ini' FROM BACKUPSET '/data/DAMENG/bak/BACKUP_FILE_0120'"
[dmdba@~]# ./dmrman CTLSTMT="RECOVER DATABASE '/data/DAMENG/dm.ini' UPDATE DB_MAGIC"
首先需要在监视器服务器需要按照章节1进行安装达梦软件等步骤
1、在节点10.16.216.82/dmsoft/dmmonitor中存放确认监视器配置文件。
2、在节点10.16.216.83/dmsoft/dmmonitor中存放非确认监视器配置文件。
[dmdba@~]# vi /dmsoft/dmmonitor/dmmonitor.ini
MON_DW_CONFIRM = 1 #0为非确认,1为确认
MON_LOG_PATH = /dmsoft/dmmonitor/log #监视器日志文件存放路径
MON_LOG_INTERVAL = 60 #每隔 60s 定时记录系统信息到日志文件
MON_LOG_FILE_SIZE = 32 #单个日志大小,单位MB
MON_LOG_SPACE_LIMIT = 1024 #日志上限,单位MB
[GRP1]
MON_INST_OGUID = 453331 #组GDW1的唯一OGUID 值
MON_DW_IP = 10.16.216.80:52141 #IP对应MAL_HOST,PORT对应MAL_DW_PORT
MON_DW_IP = 10.16.216.81:52142
使用root用户注册数据库监视器服务
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmmonitor -p _LTCIS01 -monitor_ini /dmsoft/dmonitor/dmmonitor.ini
[dmdba@~]# vi /dmsoft/dmmonitor/dmmonitor.ini
MON_DW_CONFIRM = 0 #0为非确认,1为确认
MON_LOG_PATH = /dmsoft/dmmonitor/ log #监视器日志文件存放路径
MON_LOG_INTERVAL = 60 #每隔 60s 定时记录系统信息到日志文件
MON_LOG_FILE_SIZE = 32 #单个日志大小,单位MB
MON_LOG_SPACE_LIMIT = 1024 #日志上限,单位MB
[GRP1]
MON_INST_OGUID = 453331 #组GDW1的唯一OGUID 值
MON_DW_IP = 10.16.216.80:52141 #IP对应MAL_HOST,PORT对应MAL_DW_PORT
MON_DW_IP = 10.16.216.81:52142
使用root用户注册数据库监视器服务
[root@~]# /dmsoft/dmdbms/script/root/dm_service_installer.sh -t dmmonitor -p _LTCIS02 -monitor_ini /dmsoft/dmonitor/dmmonitor.ini
.前台启动监视器进程,确认数据库集群状态是否正常
[dmdba@cmdsdbdmjk01 ~]$ dmmonitor /dmsoft/dmmonitor/dmmonitor.ini
命令 |
含义 |
list |
查看守护进程的配置信息 |
show global info |
查看所有实例组的信息 |
tip |
查看系统当前运行状态 |
login |
登录监视器 |
logout |
退出登录 |
choose switchover GDW1 |
主机正常:查看可切换为主机的实例列表 |
switchover GDW1.实例名 |
主机正常:使用指定组的指定实例,切换为主机 |
choose takeover GDW1 |
主机故障:查看可切换为主机的实例列表 |
takeover GDW1.实例名 |
主机故障:使用指定组的指定实例,切换为主机 |
choose takeover force GDW1 |
强制切换:查看可切换为主机的实例列表 |
takeover force GDW1.实例名 |
强制切换:使用指定组的指定实例,切换为主机 |
主机故障后,在备机执行SELECT SF_DW_CHECK_TAKEOVER();【1:可接管 0:不可接管】 |
例子:
login
用户名:SYSDBA
密码:
[monitor] 2021-07-26 21:49:29: 登录监视器成功!
show
2021-07-26 21:49:39
exit 退出
[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ01 start
[dmdba@~]# /dmsoft/dmdbms/bin/disql SYSDBA/SYSDBA
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);
[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ02 start
[dmdba@~]# /dmsoft/dmdbms/bin/disql SYSDBA/SYSDBA
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);
A机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_NBSJ01 start
B机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_NBSJ02 start
确认监视器[dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ1 start
非确认监视器[dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ2 start
#前台启动:[dmdba@~]# /dmsoft/dmdbms/bin/dmmonitor /dmsoft/dmmonitor/dmmonitor.ini
启动:
--数据库服务进程
A机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ01 start
B机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ02 start
--守护进程
A机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_NBSJ01 start
B机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_ NBSJ02 start
--监视器
确认监视器:[dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ1 start
非确认监视器: [dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ0 start
停止:监视器→B机器守护进程→A机器守护进程→A机器主库→B机器备库
--监视器
确认监视器:[dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ1 stop
非确认监视器: [dmdba@~]# /dmsoft/dmdbms/bin/DmMonitorService_NBSJ0 stop
--守护进程
B机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_NBSJ02 stop
A机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmWatcherService_NBSJ01 stop
--数据库服务
A机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ01 stop
B机器:[dmdba@~]# /dmsoft/dmdbms/bin/DmService_NBSJ02 stop
Linux环境:dm_svc.conf放在应用服务器/etc目录下。
Windows32环境:dm_svc.conf放在应用服务器System32目录下。
Windows64环境:dm_svc.conf放在应用服务器System32和SysWOW64目录下。
在应用服务器上配置dm_svc.conf文件
[root@~]# vi /etc/dm_svc.conf
TIME_ZONE=(+8:00)
LANGUAGE=(cn)
NBSJ=(10.16.216.80:5236,10.16.216.81:5236)
[NBSJ]
LOGIN_MODE=(1)
SWITCH_TIME=(300)
SWITCH_INTERVAL=(200)
(1) 创建表空间
CREATE TABLESPACE LTCIS DATAFILE '/data/LTCIS/LTCIS01.DBF' SIZE 307200 AUTOEXTEND OFF; #300G给数据
CREATE TABLESPACE LTCIS_INDEX DATAFILE '/data/LTCIS/LTCISIDX01.DBF' SIZE 102400 AUTOEXTEND OFF; #100G给索引
(2) 创建用户并关联对应表空间
CREATE USER LTCIS IDENTIFIED BY "******" DEFAULT TABLESPACE "LTCIS" DEFAULT INDEX TABLESPACE "LTCIS_INDEX";
(3) 对相应用户授予权限
grant "RESOURCE","PUBLIC" to "LTCIS";
grant select any table to LTCIS ;
grant select any view to LTCIS;
#dba密码 密码要记住,忘记找不回
ALTER USER SYSDBA IDENTIFIED BY "XXXXX";
数蛙账号
CREATE USER "DBSNMP" IDENTIFIED BY "XXXXXXX" DEFAULT TABLESPACE "MAIN";
grant public,resource to DBSNMP;
grant "VTI" TO "DBSNMP";
需要准备DEM的后台dm8数据库
MEMORY_POOL = 200 BUFFER = 1000 KEEP = 64 SORT_BUF_SIZE = 50 |
启动数据库
cd /dmsoft/DAMENG/
./DmService_DEM start
以上安装目录和初始化目录根据自己需求调整即可
DEM通过web服务访问需要准备tomcat安装包,安装包可见提供的目录下的apache-tomcat-8.5.69.tar.gz,里面应用已经部署好。
vim apache-tomcat-8.5.69/webapps/ROOT/WEB-INF/db.xml
初始化脚本为DEM的基础数据脚本,可见提供目录下的文件dem_init.sql。
登陆数据库执行脚本:
SQL>SET CHAR_CODE UTF8
SQL>start /home/dmdba/dem_init.sql
cd ./apache-tomcat-8.5.69/bin
./startup.sh
登陆验证
假设部署DEM的机器IP为192.168.0.104,则DEM地址:http://192.168.0.104:18080/
默认用户名和密码:admin/888888。 登陆后可以修改,牢记
启动dmagent服务
注意:在要进行监控和管理的机器或数据库所在机器上部署dmagent。
dmagent的运行需要依赖JAVA环境,因此部署dmagent前需要配置JAVA环境,JAVA版本必须为JAVA 1.8。
修改dmagent配置文件
达梦数据库安装目录的tool下存有dmagent
配置dmagent目录下的agent.ini
center.url=http://192.168.0.104:18080 #DEM访问地址 gather_enable=true #开启收集监控数据功能,默认打开 service_enable=true #开启远程调用功能,部署时需要打开, |
核对dmagent和DEM所运行机器时间
一般要求dmagent和DEM所运行机器时间一致,最多不要相差5分钟。因为5分钟为dmagent消息的有效时间.
启动dmagent 在达梦数据库服务器上面(主备)
service.sh start/restart #服务方式运行
访问DEM
http://192.168.0.104:18080/