软件包:
NeoKylin Linux A 6.0 x86_64bit(中标麒麟)
dm7_setup_rh6_64_ent_7.6.0.197_20190917
unixODBC-2.3.0.tar.gz
1.安装
1.1.安装环境检查
[root@localhost ~]# lsb_release -a //查看操作系统
[root@localhost ~]# rpm -aq|grep glibc //查看包
[root@localhost ~]# cat /proc/cpuinfo //查看cpu
[root@localhost ~]# fdisk -l //查看磁盘信息
[root@localhost ~]# df -h //查看空间大小
1.2.创建用户和安装目录
[root@localhost ~]# mkdir /dm7 //创建安装目录
[root@localhost ~]# id dmdba //规划用户dmdba,不建议使用root
id: dmdba:无此用户
[root@localhost ~]# groupadd dinstall
[root@localhost ~]# useradd -g dinstall dmdba
[root@localhost ~]# id dmdba
uid=500(dmdba) gid=503(dinstall) 组=503(dinstall)
[root@localhost ~]# passwd dmdba
更改用户 dmdba 的密码。
Enter new password:
Re-type new password:
passwd: 所有的身份验证令牌已经成功更新。
[root@localhost ~]# chown -R dmdba:dinstall /dm7
1.3.环境变量配置
[dmdba@localhost ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export DM_HOME=/dm7
export PATH=$DM_HOME/bin:$DM_HOME/tool:$PATH:$HOME/bin
[dmdba@localhost ~]$ source .bash_profile
1.4.设置文件最大打开数目
[root@localhost ~]# ulimit -n 65536
[root@localhost ~]# vi /etc/security/limits.conf
dmdba soft nofile 4096
dmdba hard nofile 65536
[root@localhost /]# su dmdba
[dmdba@localhost /]$ ulimit -a
1.5.安装数据库软件
[root@localhost /]# ls -l /dev|grep cdrom //光盘驱动器
lrwxrwxrwx 1 root root 3 4月 16 15:21 cdrom -> sr
crw-irw---- 1 root cdrom 21, 1 4月 16 15:15 sg1
brw-rw----+ 1 root cdrom 11, 0 4月 16 15:21 sr0
[root@localhost /]# mount -o loop /dev/cdrom /mnt/ //挂载安装盘
[root@localhost /]# cd mnt/
[root@localhost mnt]# ll
总用量 575058
-r-xr-xr-x 1 root root 584382798 9月 16 2019 DMInstall.bin
-r-xr-xr-x 1 root root 2266249 9月 12 2019 DM_Install_en.pdf
-r-xr-xr-x 1 root root 2207674 9月 12 2019 DM_Install_zh.pdf
-r-xr-xr-x 1 root root 868 9月 12 2019 release_en.txt
-r-xr-xr-x 1 root root 973 9月 12 2019 release_zh.txt
[dmdba@localhost root]$ cd /mnt
[dmdba@localhost mnt]$ export DISPLAY=192.168.116.1:0.0 //配置远程图形化显示
[dmdba@localhost mnt]$ xhost +
access control disabled, clients can connect from any host
xhost: must be on local machine to enable or disable access control.
[dmdba@localhost mnt]$ ./DMInstall.bin
1.6.卸载软件
已经存数据库,停止数据库,执行uninstall.sh
只安装了软件,可以直接执行uninstall.sh
脚本uninstall.sh在安装目录下
1.7.初始化数据库
[dmdba@localhost bin]$ ./dminit path=/dm7/data DB_NAME=DM02 instance_name=DM02 PORT_NUM=5239
[root@localhost /]# cd /dm7/script/root/
[root@localhost root]# ./dm_service_installer.sh -t dmserver -i /dm7/data/DM02/dm.ini -p DM02
移动服务脚本文件(/dm7/bin/DmServiceDM02 到 /etc/rc.d/init.d/DmServiceDM02)
创建服务(DmServiceDM02)完成
[root@localhost root]# service DmServiceDM02 start
1.8.图形界面工具介绍
[root@localhost tool]# ./console //DM控制台工具
[root@localhost tool]# ./dbca.sh //数据库配置助手
[root@localhost tool]# ./dmservice.sh //服务查看器
[root@localhost tool]# ./dts //DM数据迁移工具
[root@localhost tool]# ./manager //DM管理工具
[root@localhost tool]# ./monitor //DM性能监视工具
2.DM7日常操作
2.1.数据库实例登录
[dmdba@localhost ~]$ source .bash_profile //环境变量生效
[dmdba@localhost ~]$ disql sysdba/dameng123@localhost:5236 //目录在/dm7/bin/disql
服务器[localhost:5236]:处于普通打开状态
登录使用时间: 17.723(毫秒)
disql V7.6.0.197-Build(2019.09.12-112648)ENT
SQL>
2.2.数据库实例状态切换
SQL> select status$ from v$instance;
行号 STATUS$
---------- -------
1 OPEN
已用时间: 11.844(毫秒). 执行号:3.
SQL> alter database mount;
操作已执行
已用时间: 00:00:01.859. 执行号:0.
SQL> select status$ from v$instance;
行号 STATUS$
---------- -------
1 MOUNT
已用时间: 0.526(毫秒). 执行号:4.
2.3.启动数据库实例
[dmdba@localhost bin]$ ./dminit path=/dm7/data DB_NAME=DM03 instance_name=DM03 PORT_NUM=5237
[root@localhost /]# cd /dm7/script/root/
[root@localhost root]# ./dm_service_installer.sh -t dmserver -i /dm7/data/DM03/dm.ini -p DM03
移动服务脚本文件(/dm7/bin/DmServiceDM03 到 /etc/rc.d/init.d/DmServiceDM03)
创建服务(DmServiceDM03)完成
[root@localhost root]#
[root@localhost root]# service DmServiceDM03 start
Starting DmServiceDM03: [ OK ]
[root@localhost root]#
[root@localhost root]# netstat -ntl|grep 523* //判断数据库是否启动
tcp 0 0 :::5236 :::* LISTEN
tcp 0 0 :::5237 :::* LISTEN
tcp 0 0 :::5239 :::* LISTEN
tcp 0 0 :::5240 :::* LISTEN
[root@localhost root]# ps -ef|grep dmserver //判断数据库是否启动
dmdba 2176 1 0 21:40 ? 00:00:02 /dm7/bin/dmserver /dm7/data/DM02/dm.ini -noconsole
dmdba 2294 1 0 21:40 ? 00:00:02 /dm7/bin/dmserver /dm7/data/DAMENG/dm.ini -noconsole
dmdba 12042 1 1 22:25 pts/2 00:00:05 /dm7/bin/dmserver /dm7/data/DM04/dm.ini -noconsole
dmdba 13140 1 2 22:29 pts/0 00:00:03 /dm7/bin/dmserver /dm7/data/DM03/dm.ini -noconsole
root 13720 4293 0 22:32 pts/0 00:00:00 grep dmserver
2.4.重做日志文件
SQL> select path from v$rlogfile;
行号 PATH
---------- -----------------------------
1 /dm7/data/DAMENG/DAMENG01.log
2 /dm7/data/DAMENG/DAMENG02.log
已用时间: 11.391(毫秒). 执行号:365.
SQL> alter database add logfile '/dm7/data/DAMENG/DAMENG04.log' size 128;
操作已执行
已用时间: 569.746(毫秒). 执行号:367.
SQL> select path,rlog_size/1024/1024 from v$rlogfile;
行号 PATH RLOG_SIZE/1024/1024
---------- ----------------------------- --------------------
1 /dm7/data/DAMENG/DAMENG01.log 256
2 /dm7/data/DAMENG/DAMENG02.log 256
3 /dm7/data/DAMENG/DAMENG04.log 128
已用时间: 0.360(毫秒). 执行号:368.
SQL>
SQL> alter database resize logfile '/dm7/data/DAMENG/DAMENG04.log' to 256;
操作已执行
已用时间: 640.713(毫秒). 执行号:369.
SQL> select path,rlog_size/1024/1024 from v$rlogfile;
行号 PATH RLOG_SIZE/1024/1024
---------- ----------------------------- --------------------
1 /dm7/data/DAMENG/DAMENG01.log 256
2 /dm7/data/DAMENG/DAMENG02.log 256
3 /dm7/data/DAMENG/DAMENG04.log 256
已用时间: 0.369(毫秒). 执行号:370.
SQL>
注意:重做日志不能删除,所有日志文件大小要求一致。
3.DM7的体系结构
3.1.DM逻辑存储结构
3.2.DM物理存储结构
[dmdba@localhost ~]$ cd /dm7/data/DAMENG/
[dmdba@localhost DAMENG]$ ll *.ini //配置文件,以ini结尾
-rw-r--r-- 1 dmdba dinstall 907 4月 16 15:52 dmarch_example.ini
-rw-r--r-- 1 dmdba dinstall 2147 4月 16 15:52 dmdcr_cfg_example.ini
-rw-r--r-- 1 dmdba dinstall 631 4月 16 15:52 dmdcr_example.ini
-rw-r--r-- 1 dmdba dinstall 45283 4月 16 15:52 dm.ini
-rw-r--r-- 1 dmdba dinstall 1537 4月 16 15:52 dminit_example.ini
-rw-r--r-- 1 dmdba dinstall 2070 4月 16 15:52 dmmal_example.ini
-rw-r--r-- 1 dmdba dinstall 1277 4月 16 15:52 dmmonitor_example.ini
-rw-r--r-- 1 dmdba dinstall 288 4月 16 15:52 dmmpp_example.ini
-rw-r--r-- 1 dmdba dinstall 1679 4月 16 15:52 dmtimer_example.ini
-rw-r--r-- 1 dmdba dinstall 2146 4月 16 15:52 dmwatcher_example.ini
-rw-r--r-- 1 dmdba dinstall 635 4月 16 15:52 sqllog_example.ini
-rw-r--r-- 1 dmdba dinstall 479 4月 16 15:52 sqllog.ini
[dmdba@localhost DAMENG]$ ll *.ctl //控制文件是一个二进制文件,以ctl结尾
-rw-r--r-- 1 dmdba dinstall 9728 4月 20 21:44 dm.ctl
查看控制文件内容:
[dmdba@dca01 DAMENG]$ dmctlcvt help
[dmdba@dca01 DAMENG]$ dmctlcvt type=1
src=/dm7/data/DAMENG/dm.ctl dest=/tmp/dmctl.txt
[dmdba@dca01 tmp]$ cat dmctl.txt
--------------------------------------------------------------------------
[dmdba@localhost DAMENG]$ ll *.DBF
//数据文件,数据文件的大小范围:4096*页大小------2147483647*页大小
表空间中数据文件的总数不超过256个
-rw-r--r-- 1 dmdba dinstall 134217728 4月 16 19:30 DMHR.DBF
-rw-r--r-- 1 dmdba dinstall 134217728 4月 20 11:41 MAIN.DBF
-rw-r--r-- 1 dmdba dinstall 134217728 4月 20 21:49 ROLL.DBF
-rw-r--r-- 1 dmdba dinstall 22020096 4月 20 22:14 SYSTEM.DBF
-rw-r--r-- 1 dmdba dinstall 10485760 4月 20 21:44 TEMP.DBF
[dmdba@localhost DAMENG]$ ll DAMENG*.log //重做日志文件,以实例名*.log结尾的文件
-rw-r--r-- 1 dmdba dinstall 268435456 4月 20 22:10 DAMENG01.log
-rw-r--r-- 1 dmdba dinstall 268435456 4月 20 21:44 DAMENG02.log
-rw-r--r-- 1 dmdba dinstall 268435456 4月 20 21:44 DAMENG03.log
4.表空间管理
表空间是由一个或多个数据文件构成的,表空间是数据库的一个容器,存放数据库中的数据对象(表,索引等)
达梦数据库默认的表空间
[dmdba@localhost ~]$ disql SYSDBA/dameng123@localhost:5236
服务器[localhost:5236]:处于普通打开状态
登录使用时间: 4.439(毫秒)
disql V7.6.0.197-Build(2019.09.12-112648)ENT
SQL> select tablespace_name,status from dba_tablespaces;
行号 TABLESPACE_NAME STATUS
---------- --------------- -----------
1 SYSTEM 0
2 ROLL 0
3 TEMP 0
4 MAIN 0
5 DMHR 0
6 HMAIN NULL
6 rows got
已用时间: 10.549(毫秒). 执行号:1833.
SQL>
SYSTEM:数据字典和全局的系统数据。
ROLL:存放了数据库运行过程中产生的回滚记录
Temp:临时表空间
Main:数据库默认表空间,创建数据对象的时候,如果不指定存放的位置,默认存放在该表空间。
HMAIN:HUGE表空间
相关参数:
UNDO_RETENTION 单位:秒
SQL> select para_name,para_value from v$dm_ini where para_name='UNDO_RETENTION';
行