达梦8 数据库安装+体系结构介绍

达梦8 数据库安装+体系结构介绍

 

 

 

 

1. 目录

Table of Contents

1. 目录. 1

2. 达梦数据库安装. 1

2.1 达梦数据库软件安装. 1

2.1.1 达梦8新特性. 1

2.1.2 安装的前置条件. 1

2.2.2 安装达梦8数据库软件. 2

2.2 达梦数据库安装(DBCA) 3

2.2.2 达梦工具介绍. 5

3. 数据库的启停. 5

4. 达梦数据库体系结构. 6

4.1 数据库. 7

4.1.1.数据文件         (用户的真实数据). 7

4.1.2.重做日志文件           (改变的数据信息). 7

4.1.3.控制文件         (数据版本信息,数据库的架构信息,创建时间 等)  7

4.2 实例:. 14

4.2.1 总量:memory_target 14

4.2.2 公共池. 14

4.2.3 数据缓冲区. 14

4.2.4 字典缓冲区. 15

4.2.5 SQL 缓冲区. 15

4.2.6 排序区. 15

4.2.7 HASH 区. 15

4.2.8 重做日志缓冲区. 16

4.3 分析SQL 语句的执行过程:. 16

4.4 查看达梦进程:. 16

 

 

 

2. 达梦数据库安装

 

2.1 达梦数据库软件安装

2.1.1 达梦8新特性

         达梦8 是对7 的迭代,主要改动:  

             1.  兼容(oracle)  

             2.  生态(适配)(CPU  龙芯,飞腾,鲲鹏,申威,海光)  

             3.  分布式(DM8)  

                  a)  计算节点和存储节点分离 (弹性计算)  

                  b)  数据要有副本 (类似HDFS)  

             4.  客户端工具增强(DEM             (web 监控、管理、配置),数据库配置助手)  

             5.  安全增强 (存储加密,强制访问控制等)  

             6.  优化器 (改善CBO)  

             7.  AWR 报告  

2.1.2 安装的前置条件

          内核版本:(2.6 以上内核)  

          [root@localhost ~]# uname -r  

 

       Glibc 版本:  (要求2.0以上)

          [root@localhost ~]# rpm -q glibc  

                   glibc-2.17-292.el7.x86_64

 

              关闭防火墙

          Iptables:防火墙  

          [root@localhost ~]# iptables -L 

          清防火墙:  

          [root@localhost ~]# iptables -F  

          [root@localhost ~]# iptables -X  

 

              关闭selinux

          [root@localhost ~]# getenforce  

     临时设置:[root@localhost ~]# setenforce 0  

     永久设置:[root@localhost ~]# vim /etc/selinux/config  

     SELINUX=disabled  

     重启操作系统。  

 

 

     最大文件打开数:

         [root@localhost /]# vim /etc/security/limits.conf  

     dmdba                      soft        nofile                    4096  

     dmdba                      haer        nofile                    65536  

     默认:[root@localhost pam.d]# ulimit -a  

     临时设置:[root@localhost pam.d]# ulimit -n 65536  

 

2.2.2 安装达梦8数据库软件

创建dmdba用户

groupadd dinstall

useradd dmdba -g dinstall

 

 GUI:图形 

[root@localhost ~]# xhost + 

[root@localhost ~]# su – dmdba 

[dmdba@localhost mnt]$ ./DMInstall.bin

按步骤安装及可。。。

    注意事项:

  1. 字符集推荐选utf-8,因为在跟其它软件做适配时,其它软件基本现在都是使用utf-8.
  2. 安装完成后记录用root用户执行下XX/script/root/root_installer.sh

 

Key 问题: 

有 key 选择 key,没有点下一步(开发版,不能做商用,并发限制,用户数目的限

制,时间期限(1 年)) 

更换Key 文件:把新的key 文件拷贝到安装目录的bin 下,重启数据库实例 

 

 

安装后目录的结构:  

bin      库文件和常用的命令(达梦)  

bin2        UTF8相关  

desktop      桌面  

doc    帮助文档  

drivers      驱动(JDBC 等)  

include    头文件(.h)  

jar    jar 包(逻辑备份,日志挖掘,数据快速加载)  

jdk      JAVA1.6  

license_en.txt    license_zh.txt      许可信息  

log      日志  

release_en.txt    release_zh.txt      版本信息  

samples    示例  

script      脚本  

tool      客户端工具  

uninstall    uninstall.sh      卸载    

web    DEM(达梦企业管理工具web)  

 

 

2.2 达梦数据库安装(DBCA)

                采用dminit工具建库(同oracle的dbca) 

           获取帮助:[dmdba@localhost ~]$ dminit    help  

           [dmdba@localhost~]$ dminit path=/dm8/data/db_name=DM instance_name=TEST port_num=5236

                            #指定库文件目录、实例名、端口号  

 

           注册服务:(采用root用户)  

                                                                 cd /script/root

           获取注册脚本帮助:[root@localhost root]# ./dm_service_installer.sh -h                    

Usage: dm_service_installer.sh -t service_type [-p service_name_postfix] [-dm_ini dm_ini_file]

        [-watch_ini watch_ini_file ] [-wmon_ini wmon_ini_file] [-rww_ini rww_ini_file]

        [-watcher_ini watcher_ini_file ] [-monitor_ini monitor_ini_file] [-cssm_ini cssm_ini_file]

        [-dfs_ini dfs_ini_file] [-dcr_ini dcr_ini_file]

        [-dss_ini dss_ini_file] [-drs_ini drs_ini_file] [-dras_ini dras_ini_file] [-dcs_ini dcs_ini_file] [-server server_info]

        [-m open|mount] [-y dependent_service] [-auto true|false]

  or dm_service_installer.sh [-s service_file_path]

  or dm_service_installer.sh -h

 

   -t               服务类型,包括dmimon,dmap,dmserver,dmwatcher,dmmonitor,dmcss,dmcssm,dmasmsvr,dmdcs,dmdrs,dmdras,dmdss

   -p               服务名后缀,对于dmimon,dmap服务类型无效

   -dm_ini          dm.ini文件路径

   -watch_ini       dmwatch.ini文件路径.

   -wmon_ini        dmwmon.ini文件路径.

   -rww_ini         dmrww.ini文件路径.

   -watcher_ini     dmwatcher.ini文件路径.

   -monitor_ini     dmmonitor.ini文件路径.

   -dcr_ini         dmdcr.ini文件路径.

   -cssm_ini        dmcssm.ini文件路径.

   -dss_ini         dss.ini文件路径.

   -drs_ini         drs.ini文件路径.

   -dras_ini        dras.ini文件路径.

   -dcs_ini         dcs.ini文件路径.

   -dfs_ini         dfs.ini文件路径.

   -server          服务器信息(IP:PORT)

   -auto            设置服务是否自动启动,值为true或false,默认true.

   -m               设置服务器启动模式open或mount,只针对dmserver服务类型生效,可选

   -y               设置依赖服务,此选项只针对systemd服务环境下的dmserver和dmasmsvr服务生效

   -s               服务脚本路径,设置则忽略除-y外的其他参数选项

   -h               帮助

 

           查看已注册服务:[root@localhost root]# systemctl list-unit-files |grep D  

 

           注册服务:[root@localhost root]# cd /dm8/script/root  

           [root@localhost  root]#  ./dm_service_installer.sh  -t  dmserver   -p  TEST   -dm_ini /dm8/data/DM/dm.ini  

                            #具体参数含义可参考dm_service_installer.sh -h

                            #-dm_ini这个参数在dm7-i

 

           启用服务:[root@localhost root]# systemctl    enable DmServiceTEST.service  

           查看服务状态:[root@localhost root]# systemctl    start DmServiceTEST.service  

 

2.2.2 达梦工具介绍

                   DM 管理工具(一个图形界面的客户端)

           [dmdba@localhost ~]$ cd /dm8/tool  

           [dmdba@localhost tool]$ ./manager  

 

                   disql 命令行客户端工具

                /dm8/bin:  

                [dmdba@localhost bin]$ ./disql    

 

                达梦服务查看器

 

3. 数据库的启停

首先启动dm server

systemctl start DmServiceTest

 

disql查看状态

SQL> select INSTANCE_NAME,STATUS$ from v$instance;  

 

行号     INSTANCE_NAME STATUS$  

 

----------  -------------  -------  

 

1      TEST           OPEN  

 

将数据库切换到mount状态下,mount状态是维护状态,可以做一些维护之类的工作

SQL>  alter  database  mount; 

 

打开数据库

SQL> alter database open; 

 

挂起状态,不允向数据库写入数据了 

SQL> alter database suspend;  

 

关闭:  

shutdown abort ;(相当于直接拔电源)    

shutdown normal;  

shutdown immediate;  

 

4. 达梦数据库体系结构

   DM server  =  客户端    +      服务器      是一个C/S架构的模式  

 

       服务器  =    数据库  +  实例  

 

           数据库=存放到磁盘上的文件。  

 

           实例=共享内存+后台进程或者线程  

 

   注意:(客户端不能直接访问数据库,借助实例。非DSC 环境    一个数据库只能被一个实例打开。DSC  一个数据库可以被多    个实例打开)  

 

4.1 数据库

4.1.1.数据文件         (用户的真实数据) 

 

数据文件是交替使用的,这点注意

系统表空间不可操作,这个你可以做下实验。

oracle 是根据块大小来限制数据文件大小的 8k是32g 16k就是64g了

达梦没有bifile;

表的话默认是索引组织表

 

4.1.2.重做日志文件           (改变的数据信息) 

      SQL> select * from v$rlogfile;  

 

      特点:循环写,重复写,达梦不支持手动切换日志  

 

 

       日志大小:日志小对业务系统,频繁切换影响性能  

 

调整重做日志的大小:SQL>  alter  database  resize  logfile '/dm8/data/DAMENG/DAMENG01.log' to 500;

增加一个重做日志文件:     SQL>alter         database            add          logfile  '/dm8/data/DAMENG/DAMENG03.log' size 500;  

 

alter system switch logfile; --归档,此命令不是切日志,dm没有切日志的命令

没有日志组日志成员的概念。

 

4.1.3.控制文件         (数据版本信息,数据库的架构信息,创建时间 等)  

 

SQL>   select   *   from   v$dm_ini  where  para_name='CTL_PATH';  

 

    CTL_BAK_PATH    参数是设置控制文件的备份路径  

 

    CTL_BAK_NUM    备份个数  

 

 

    把控制文件转成文本  

[dmdba@localhost ctl_bak]$ dmctlcvt help  

 

[dmdba@mha-slave data]$ dmctlcvt type=1  src=/data/dmdbms/data/DAMENG/dm.ctl dest=/tmp/dm.txt

DMCTLCVT V8

convert ctl to txt success!

[dmdba@mha-slave data]$ cat /tmp/dm.txt

##############################################################################

## please do not adjust parameter order, ensure the ctl have no difference ###

##########################################################################

 

 

# database name

dbname=DAMENG

# server mode

svr_mode=0

#OGUID

oguid=0

# db server version

version=117507918

# database version

db_version=458762

# pseg version

pseg_version=458762

#SGUID

sguid=1399416188

#NEXT_TS_ID

next_ts_id=5

#RAC_NODES

rac_nodes=1

#NEXT_HTS_ID

next_htsid=129

#TIME_FLAG

time_flag=170

#MDIR_FLAG

mdir_flag=31

#STARTUP_CNT

startup_cnt=3

#LAST_STARTUP_TIME

last_startup_time=DATETIME '2020-7-7 10:18:27'

#DM7_DCT_VERSION

dm7_dct_version=7

#DM8_DCT_VERSION

dm8_dct_version=18

 

#===============================================

#===============================================

 

# table space name

ts_name=SYSTEM

 # table space ID

ts_id=0

# table space status

ts_state=0

# table space cache

ts_cache=

# DSC node number

ts_nth=0

# table space create time

ts_create_time=DATETIME '2020-7-6 16:28:52'

# table space modify time

ts_modify_time=DATETIME '2020-7-6 16:28:52'

# table space encrypt flag

ts_encrypt_flag=0

# table space copy num

ts_copy_num=0

# table space region size flag

ts_size_flag=0

 

#-----------------------------------------------

 

# file path

fil_path=/data/dmdbms/data/DAMENG/SYSTEM.DBF

# mirror path

mirror_path=

# file id

fil_id=0

# whether the file is auto extend

autoextend=1

# file create time

fil_create_time=DATETIME '2020-7-6 16:28:52'

# file modify time

fil_modify_time=DATETIME '2020-7-6 16:28:52'

# the max size of file

fil_max_size=0

# next size of file

fil_next_size=0

 

 

#===============================================

 

# table space name

ts_name=ROLL

 # table space ID

ts_id=1

# table space status

ts_state=0

# table space cache

ts_cache=

# DSC node number

ts_nth=0

# table space create time

ts_create_time=DATETIME '2020-7-6 16:28:52'

# table space modify time

ts_modify_time=DATETIME '2020-7-6 16:28:52'

# table space encrypt flag

ts_encrypt_flag=0

# table space copy num

ts_copy_num=0

# table space region size flag

ts_size_flag=0

 

#-----------------------------------------------

 

# file path

fil_path=/data/dmdbms/data/DAMENG/ROLL.DBF

# mirror path

mirror_path=

# file id

fil_id=0

# whether the file is auto extend

autoextend=1

# file create time

fil_create_time=DATETIME '2020-7-6 16:28:52'

# file modify time

fil_modify_time=DATETIME '2020-7-6 16:28:52'

# the max size of file

fil_max_size=0

# next size of file

fil_next_size=0

 

 

#===============================================

 

# table space name

ts_name=RLOG

 # table space ID

ts_id=2

# table space status

ts_state=0

# table space cache

ts_cache=

# DSC node number

ts_nth=0

# table space create time

ts_create_time=DATETIME '2020-7-6 16:28:52'

# table space modify time

ts_modify_time=DATETIME '2020-7-6 16:28:52'

# table space encrypt flag

ts_encrypt_flag=0

# table space copy num

ts_copy_num=0

# table space region size flag

ts_size_flag=0

 

#-----------------------------------------------

 

# file path

fil_path=/data/dmdbms/data/DAMENG/DAMENG01.log

# mirror path

mirror_path=

# file id

fil_id=0

# whether the file is auto extend

autoextend=1

# file create time

fil_create_time=DATETIME '2020-7-6 16:28:52'

# file modify time

fil_modify_time=DATETIME '2020-7-6 16:28:52'

# the max size of file

fil_max_size=0

# next size of file

fil_next_size=0

 

# file path

fil_path=/data/dmdbms/data/DAMENG/DAMENG02.log

# mirror path

mirror_path=

# file id

fil_id=1

# whether the file is auto extend

autoextend=1

# file create time

fil_create_time=DATETIME '2020-7-6 16:28:52'

# file modify time

fil_modify_time=DATETIME '2020-7-6 16:28:52'

# the max size of file

fil_max_size=0

# next size of file

fil_next_size=0

 

 

#===============================================

 

# table space name

ts_name=MAIN

 # table space ID

ts_id=4

# table space status

ts_state=0

# table space cache

ts_cache=

# DSC node number

ts_nth=0

# table space create time

ts_create_time=DATETIME '2020-7-6 16:28:52'

# table space modify time

ts_modify_time=DATETIME '2020-7-6 16:28:52'

# table space encrypt flag

ts_encrypt_flag=0

# table space copy num

ts_copy_num=0

# table space region size flag

ts_size_flag=0

 

#-----------------------------------------------

 

# file path

fil_path=/data/dmdbms/data/DAMENG/MAIN.DBF

# mirror path

mirror_path=

# file id

fil_id=0

# whether the file is auto extend

autoextend=1

# file create time

fil_create_time=DATETIME '2020-7-6 16:28:52'

# file modify time

fil_modify_time=DATETIME '2020-7-6 16:28:52'

# the max size of file

fil_max_size=0

# next size of file

fil_next_size=0

 

 

#===============================================

 

# HUGE table space name

htsname=HMAIN

# HUGE table space id

htsid=128

#HUGE table space share flag

htsflag=0

# HUGE table space copy num

hts_copy_num=0

# HUGE table space region size flag

hts_size_flag=0

# HUGE table space create time

hts_create_time=DATETIME '2020-7-6 16:28:52'

# HUGE table space modify time

hts_modify_time=DATETIME '2020-7-6 16:28:52'

# HUGE table space path

htspath=/data/dmdbms/data/DAMENG/HMAIN

 

#===============================================

 

[dmdba@mha-slave data]$

 

 

4.2 实例:

实例:    共享内存    +    后台进程或者线程  

 

4.2.1 总量:memory_target  

SQL> select   *           from    v$dm_ini      where  para_name='MEMORY_TARGET'; 

 

行号     PARA_NAME     PARA_VALUE MIN_VALUE MAX_VALUE MPP_CHK SESS_VALUE FILE_VALUE DESCRIPTION                               PARA_TYPE

---------- ------------- ---------- --------- --------- ------- ---------- ---------- ----------------------------------------- ---------

1          MEMORY_TARGET 0          0         67108864  N       0          0          Memory Share Pool Target Size In Megabyte SYS

 

方式1,修改参数

  SQL> sp_set_para_value(1,'MEMORY_TARGET',1024);  

         1  代表  both      2  配置文件  

 

方式2,修改参数

SQL> alter system set 'MEMORY_TARGET'=1000;  

 

4.2.2 公共池

②公共池:减少系统调用 (预先分配的内存,供各个缓冲区用)  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini  where para_name='MEMORY_POOL';  

 

4.2.3 数据缓冲区

③数据缓冲区    存放数据块,(空闲,干净,脏块,正在使用的)  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini where para_name='BUFFER';  

 

OLTP:物理内存的40-60%  

 

OLAP:物理内存的60-80%  

 

4.2.4 字典缓冲区

④字典缓冲区    缓存最近使用的数据字典和数据定义 (system表空间)  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini where para_name='DICT_BUF_SIZE';  

 

4.2.5 SQL 缓冲区

⑤SQL 缓冲区    缓存最近使用的SQL 代码 (sqlid 或者 hash), 

 

执行计划,结果集  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini  

 

where para_name='CACHE_POOL_SIZE';  

 

4.2.6 排序区

⑥排序区    数据排序  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini  

 

where para_name='SORT_BUF_SIZE';  

 

如果内存排不下,会把部分排序转到磁盘的临时表空间。  

 

4.2.7 HASH 

⑦HASH 区    表连接hash join 使用  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini  

 

 

 

where para_name='HJ_BUF_SIZE';  

 

4.2.8 重做日志缓冲区

⑧重做日志缓冲区  把改变的数据写到重做日志文件中  

 

SQL>   select   para_name,para_value,para_type   from   v$dm_ini  

 

where para_name='RLOG_BUF_SIZE';        (单位是页,建议设置成2 

 

的幂)        (3 秒,事务提交)  

 

 

4.3 分析SQL 语句的执行过程:  

 

    1.  语法分析      

 

    2.  语义分析        (字典缓冲区)  

 

   3.  权限判断         (字典缓冲器)  

 

   4.  数据读取  

 

       a)  在内存      (数据缓冲区)  

 

       b)  不在内存        (数据缓冲区)  

 

   5.执行SQL       (SQL 缓冲区,排序区,HASH 区)  

 

 

4.4 查看达梦进程:

   操作系统查看  

 

    [dmdba@localhost ctl_bak]$ ps -ef|grep dmserver  

 

    [dmdba@localhost ctl_bak]$ top -p 65162 -H    

 

  

 

    数据库查看  

 

   SQL> select name,thread_desc from v$threads;  

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值