达梦数据库
# 一、数据库安装
# 前期准备
- 创建dmdba用户,dinstall组
[root@localhost oracle]# groupadd dinstall && useradd -g dinstall dmdba && echo root|passwd --stdin dmdba Changing password for user dmdba. passwd: all authentication tokens updated successfully.
- 关闭防火墙和selinux
- 创建软件安装目录
/opt/dmdbms && chown dmdba:dinstall /opt/dmdbms
- 创建数据目录
/opt/dmdata && chown dmdba:dinstall /opt/dmdata
- 修改用户资源限制
vi /etc/security/limits.conf 增加相应配置dmdba hard nofile 131072 dmdba soft nofile 131072 dmdba soft nice 0 dmdba hard nice 0 dmdba soft as unlimited dmdba hard as unlimited dmdba soft fsize unlimited dmdba hard fsize unlimited dmdba soft nproc 131072 dmdba hard nproc 131072 dmdba soft data unlimited dmdba hard data unlimited dmdba soft core unlimited dmdba hard core unlimited dmdba soft memlock unlimited dmdba hard memlock unlimited
- 上传安装包,解压
unzip dm8_20220525_x86_rh6_64.zip
- iso挂载到/mnt
mount -o loop dm8_20220525_x86_rh6_64.iso /mnt/
- 取消挂载
umount /mnt/
(全部安装完成后执行)
# 安装
切换用户 dmdba 进行安装
执行安装脚本
/mnt/DMInstall.bin -i
[dmdba@localhost ~]$ /mnt/DMInstall.bin -i Please select the installer's language (E/e:English C/c:Chinese) [E/e]:c 解压安装程序......... 欢迎使用达梦数据库安装程序 是否输入Key文件路径? (Y/y:是 N/n:否) [Y/y]:n 是否设置时区? (Y/y:是 N/n:否) [Y/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=基里巴斯 请选择设置时区 [6]:21 安装类型: 1 典型安装 2 服务器 3 客户端 4 自定义 请选择安装类型的数字序号 [1 典型安装]:1 所需空间: 1585M 请选择安装目录 [/home/dmdba/dmdbms]:/opt/dmdbms 目录(/opt/dmdbms)下不为空,请选择其他目录。 请选择安装目录 [/home/dmdba/dmdbms]:/opt/dmdbms 可用空间: 13G 是否确认安装路径(/opt/dmdbms)? (Y/y:是 N/n:否) [Y/y]:y 安装前小结 安装位置: /opt/dmdbms 所需空间: 1585M 可用空间: 13G 版本信息: 有效日期: 安装类型: 典型安装 是否确认安装? (Y/y:是 N/n:否):y 2022-07-18 19:00:36 [INFO] 安装达梦数据库... 2022-07-18 19:00:37 [INFO] 安装 基础 模块... 2022-07-18 19:00:40 [INFO] 安装 服务器 模块... 2022-07-18 19:00:40 [INFO] 安装 客户端 模块... 2022-07-18 19:00:42 [INFO] 安装 驱动 模块... 2022-07-18 19:00:43 [INFO] 安装 手册 模块... 2022-07-18 19:00:43 [INFO] 安装 服务 模块... 2022-07-18 19:00:44 [INFO] 移动日志文件。 2022-07-18 19:00:44 [INFO] 安装达梦数据库完成。 请以root系统用户执行命令: /opt/dmdbms/script/root/root_installer.sh 安装结束
root执行脚本
/opt/dmdbms/script/root/root_installer.sh
[root@localhost opt]# /opt/dmdbms/script/root/root_installer.sh 移动 /opt/dmdbms/bin/dm_svc.conf 到/etc目录 修改服务器权限 创建DmAPService服务 Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service. 创建服务(DmAPService)完成 启动DmAPService服务 [root@localhost opt]#
# 初始化
- 执行初始化脚本
./dminit path=/opt/dmdata db_name=aihb instance_name=aihb
[dmdba@localhost bin]$ pwd /opt/dmdbms/bin [dmdba@localhost bin]$ ./dminit path=/opt/dmdata db_name=aihb instance_name=aihb initdb V8 db version: 0x7000c file dm.key not found, use default license! License will expire on 2023-05-25 Normal of FAST Normal of DEFAULT Normal of RECYCLE Normal of KEEP Normal of ROLL log file path: /opt/dmdata/aihb/aihb01.log log file path: /opt/dmdata/aihb/aihb02.log write to dir [/opt/dmdata/aihb]. create dm database success. 2022-07-19 10:05:20 [dmdba@localhost bin]$
# 注册数据库服务,启动数据库
调用达梦提供的脚本生成数据库服务,自动启动数据库,脚本在安装目录的/script/root子目录下,调用注册脚本需使用root用户
./dm_service_installer.sh -t dmserver -dm_ini /opt/dmdata/aihb/dm.ini -p aihb
- 调用dm_service_installer.sh脚本来生成服务
- -t 指定需要创建的服务类型,这里是数据库服务所以是dmserver
- -dm_ini 指定在上一步初始化后生成的dm.ini文件
- -p 为生成服务的后缀名,可自定义,这里给的czw,所以创建的服务名为DmServiceczw
[root@localhost root]# pwd /opt/dmdbms/script/root [root@localhost root]# ll total 48 -rwxr-xr-x. 1 dmdba dinstall 29111 Jul 19 10:00 dm_service_installer.sh -rwxr-xr-x. 1 dmdba dinstall 9618 Jul 19 10:00 dm_service_uninstaller.sh -rwxr-xr-x. 1 dmdba dinstall 635 Jul 19 10:00 root_installer.sh [root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /opt/dmdata/aihb/dm.ini 请设置参数-p [root@localhost root]# ./dm_service_installer.sh -t dmserver -dm_ini /opt/dmdata/aihb/dm.ini -p aihb Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceaihb.service to /usr/lib/systemd/system/DmServiceaihb.service. 创建服务(DmServiceaihb)完成 [root@localhost root]#
启动数据库
systemctl start DmServiceaihb
# 二、创建Oracle To 达梦的DBlink(OCI方式)
# 环境准备
键 | 值 |
---|---|
操作系统 | Centos 7 |
Oracle数据库 | 11.2.0.4.0 |
达梦数据库 | Centos 7 x86版本 |
达梦安装目录 | /opt/dmdbms |
Oracle OCI位置 | /opt/oracle |
# 工具准备
Oracle OCI: instantclient-basic-linux.x64-11.2.0.4.0.zip(与系统和Oracle版本对应) 下载地址 (opens new window)
# Oracle OCI安装配置(达梦数据库所在服务器)
进入包所在的路径并解压:
cd /opt/oracle/ && unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
(18.3 之前的版本需要这一步)进入解压后目录创建软连接:
cd instantclient_11_2 && ln -sfv libclntsh.so.11.1 libclntsh.so
配置环境变量
- 将OCI添加到/etc/ld.so.conf.d目录下(系统用户)
echo /opt/oracle/instantclient_11_2 > /etc/ld.so.conf.d/oracle-instantclient.conf
- 加载动态链接库(使上一步生效):
ldconfig
- 配置LD_LIBRARY_PATH环境变量(dmdba用户)
修改dmdba用户下的.bash_profile文件(vim ~/.bash_profile
),添加以下内容export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/opt/oracle/instantclient_11_2"
- 加载环境变量(使上一步生效):
source ~/.bash_profile
- 将OCI添加到/etc/ld.so.conf.d目录下(系统用户)
启动(重启达梦数据库 系统用户)
systemctl restart DmServiceXXX #(**实际服务名**)
- 创建DBLink(注:用户名不要加引号)
create link LINKORA connect 'ORACLE' with username identified by "password" using 'x.x.x.x:1521/orcl';
# 常用SQL
# 博客
编辑 (opens new window)
上次更新: 2024/08/29, 21:10:49