初学达梦数据库

        近期公司引入了国产数据库达梦数据库,作为一名DBA,对国产数据库还不是很了解,但数据库的国产化势在必行,因此开始了达梦数据库的学习。

        首先从最基础的数据库安装开始吧。

一、达梦数据库软件安装与卸载

1、新增dmdba用户及属组

 groupadd dinstall

 useradd -g dinstall -s /bin/bash dmdba

 passwd dmdba

2、规划安装目录,注意权限更改

mkdir /dm8

Chown dmdba:dinstall /dm8

3、mount iso文件

mkdir /mnt/dm

mount /opt/dm8_20220304_x86_rh6_64.iso /mnt/dm

su – dmdba

cd /mnt/dm

[dmdba@KylinDCA04 dm]$ ll

-r-xr-xr-x 1 root root 2802237 34 13:39 ‘DM8 Install.pdf’

-r-xr-xr-x 1 root root 946534466 34 13:44 DMInstall.bin

4、安装软件

有两种安装方式,图像化界面和命令行方式。

命令行方式安装软件:

cd /mnt/dm

./DMInstall.bin –i

》图形化界面安装软件:

[root@clnxdm8 etc]# xhost +

access control disabled, clients can connect from any host

[root@clnxdm8 etc]# echo $DISPLAY

:2.0

su – dmdba

echo $DISPLAY

export DISPLAY=:2.0

cd /mnt/dm

./DMInstall.bin

提示:如果 错tmp不足,可以设置DM_INSTALL_TMPDIR变量,指定到别的路径下。

如果可打开文件数不够,可以按以下步骤修改:

vim /etc/security/limits.conf

dmdba soft nofile 102400

dmdba hard nofile 204800

root soft nofile 102400

root hard nofile 204800

安装完成后记得执行root脚本/dm8/script/root/root_installer.sh

5、卸载达梦数据库软件,有两种方法:

》图形化方式卸载DM数据库软件:

[root@KylinDCA04 dm8]# ./uninstall.sh

》命令行方式卸载:

[root@KylinDCA04 dm8]# ./uninstall.sh -i

二、达梦数据库安装与卸载

达梦数据库的簇大小,页大小,字符集,大小写敏感、varchar类型以字符为单位等,数据库一旦创建完成将无法更改。所以要提前跟应用系统需求方确认好这些参数。

1、图形化界面安装

su – dmdba

echo $DISPLAY

export DISPLAY=:2.0

cd /dm8/tool/

./dbca –调出图形化界面,一步一步往下做即可。完成后记得执行root脚本。

2、使用命令行方式创建数据库:

[dmdba@KylinDCA04 bin]$    cd /dm8/bin

[dmdba@KylinDCA04bin]$./dminit path=/dm8/data db_name=DMTEST instance_name=DMTEST port_num=5238 page_size=16 SYSDBA_PWD=Dameng123    

上一条命令执行完成后,dminit创建的数据库默认没有注册数据库服务,需要手工注册数据服务。

[root@ommoapp02 root]# ./dm_service_installer.sh -t dmserver -p dmtest -dm_ini /dm8/data/dmtest/dm.ini

Created symlink from /etc/systemd/system/multi-user.target.wants/DmServicedmtest.service to /usr/lib/systemd/system/DmServicedmtest.service.

创建服务(DmServicedmtest)完成

上一步命令执行完成后,手工启动dmtest服务。

 [root@ommoapp02 root]# ls -l /usr/lib/systemd/system/DmServicedmtest1.service

-rw-r—– 1 root root 397 Apr 13 19:53 /usr/lib/systemd/system/DmServicedmtest1.service

[root@ommoapp02 root]# systemctl enable DmServicedmtest1.service

[root@ommoapp02 root]# systemctl start DmServicedmtest1.service

 [root@ommoapp02 root]# ps -ef|grep dmser    –此时可以看到dmserver进程已经启动了

root     26564  2100  0 22:09 pts/1    00:00:00 grep –color=auto dmser

dmdba    29562     1  2 22:07        00:00:04 /dm8/app/bin/dmserver path=/dm8/data/dmtest/dm.ini -noconsole

 [root@ommoapp02 bin]# ./DmServicedmtest1 status

DmServicedmtest1 (pid 18886) is running.      –可看到达梦数据库服务正常运行

3、卸载达梦数据库

首先要关闭服务

[root@clnxdm8 root]# systemctl status DmServiceDMINS  

[root@clnxdm8 root]# systemctl stop DmServiceDMINS

再调用图形化界面进行卸载

/dmtest/app/tool/

./dbca    –图形化界面中有卸载数据库的选项,一步一步往下操作即可。

最后需要手工停止操作系统上的注册的服务:

[root@clnxdm8 root]# systemctl disable DmServiceDMINS.service

Removed /etc/systemd/system/multi-user.target.wants/DmServiceDMINS.service.

[root@clnxdm8 root]# rm -f /usr/lib/systemd/system/DmServiceDMINS.service

至此完成卸载数据库。

三、达梦数据库的启停

1、root用户以服务命令行方式启动数据库:

[root@clnxdm8 system]# pwd

/usr/lib/systemd/system

[root@clnxdm8 system]# ls Dm*

DmAPService.service  DmServicedmins.service 

[root@ommoapp02 root]# systemctl start DmServicedmtest1.service   –启动数据库实例

[root@ommoapp02 root]# systemctl stop DmServicedmtest1.service   –停数据库实例

2、dmdba用户启动数据库的方法:

2.1、[dmdba@clnxdm8 bin]$ ./DmServicedmins start       –启数据库实例

Starting DmServicedmins:                                   [ OK ]

[dmdba@clnxdm8 bin]$ ./DmServicedmins status

DmServicedmins (pid 165049) is running.

2.2、[dmdba@clnxdm8 bin]$ ./dmserver path=/dmtest/data/dmdb/dm.ini    —没有注册服务的时候,用这种方式启动数据库

file dm.key not found, use default license!

version info: develop

instance DMINS is running.

2.3、[dmdba@clnxdm8 bin]$ ./DmServicedmins stop    –停数据库实例

Stopping DmServicedmins:                                   [ OK ]

        达梦数据库的安装和启停学习完了,后续还会继续学习达梦数据库的体系结构、表空间管理、用户权限管理、模式对象管理、归档管理、备份恢复等内容。道阻且长,且行且学习。

文章知识点与官方知识档案匹配,可进一步学习相关知识MySQL入门技能树数据库组成32096 人正在系统学习中

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年3月19日
下一篇 2022年3月19日

相关推荐