达梦数据库安装及卸载
因工作需要,安装过达梦数据库多次,本次写个文档,供参考。
1. 创建安装用户
#创建安装用户组 dinstall
groupadd -g 12349 dinstall #创建安装用户 dmdba
useradd -u 12345 -g dinstall -m -d /home/dmdba -s /bin/bash dmdba #初始化用户密码
passwd dmdba
2. 设置Linux系统用户可以打开的最大的文件数
建议用户设置为 65536 以上或 unlimited(无限制)
[root@localhost ~]# vi /etc/security/limits.conf dmdba soft nofile 65536 dmdba hard nofile 65536
3. 达梦数据库安装
3.1 上传安装文件
将安装文件DMInstall.bin(安装镜像解压后的文件)上传至服务器。
文件可下载链接: https://pan.baidu.com/s/1t25yMKoOQ7KuhXacK70ZRw 提取码: 9wam
3.2 切换用户
su - dmdba
3.3 命令行安装
本文作为演示,安装路径选择默认路径/home/dmdba/dmdbms。实际应用数据库安装路径,建议选择挂载盘或者大容量路径作为安装路径。
[dmdba@ZWZF-CWY-LZY-12 upload]$ sh DMInstall.bin -i
Please select the installer's language (E/e:English C/c:Chinese) [E/e]:e
Extract install files.........
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 127946
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 4096
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
The max number of open files is too little, suggest to set 65536 or more to number of open files.
Welcome to DM DBMS Installer
Whether to input the path of Key File? (Y/y:Yes N/n:No) [Y/y]:n
Whether to Set The TimeZone? (Y/y:Yes N/n:No) [Y/y]:y
TimeZone:
[ 1]: GTM-12=West Date Line
[ 2]: GTM-11=Samoa
[ 3]: GTM-10=Hawaii
[ 4]: GTM-09=Alaska
[ 5]: GTM-08=Pacific(America and Canada)
[ 6]: GTM-07=Arizona
[ 7]: GTM-06=Central(America and Canada)
[ 8]: GTM-05=East(America and Canada)
[ 9]: GTM-04=Atlantic(America and Canada)
[10]: GTM-03=Brasilia
[11]: GTM-02=Middle Atlantic
[12]: GTM-01=Azores
[13]: GTM=Greenwich Mean Time
[14]: GTM+01=Sarajevo
[15]: GTM+02=Cairo
[16]: GTM+03=Moscow
[17]: GTM+04=AbuDhabi
[18]: GTM+05=Islamabad
[19]: GTM+06=Dakar
[20]: GTM+07=BangKok,Hanoi
[21]: GTM+08=China
[22]: GTM+09=Seoul
[23]: GTM+10=Guam
[24]: GTM+11=Solomon
[25]: GTM+12=Fiji
[26]: GTM+13=Nukualofa
[27]: GTM+14=Kiribati
Please Select the TimeZone [21]:21
Installation Type:
1 Typical
2 Server
3 Client
4 Custom
Please Input the number of the Installation Type [1 Typical]:1
Require Space: 1602M
Please Input the install path [/home/dmdba/dmdbms]:
Available Space:30G
Please Confirm the install path(/home/dmdba/dmdbms)? (Y/y:Yes N/n:No) [Y/y]:y
Pre-Installation Summary
Installation Location: /home/dmdba/dmdbms
Require Space: 1602M
Available Space: 30G
Version Information:
Expire Date:
Installation Type: Typical
Confirm to Install? (Y/y:Yes N/n:No):y
2022-09-08 16:44:30
[INFO] Installing DM DBMS...
2022-09-08 16:44:31
[INFO] Installing BASE Module...
2022-09-08 16:44:33
[INFO] Installing SERVER Module...
2022-09-08 16:44:33
[INFO] Installing CLIENT Module...
2022-09-08 16:44:35
[INFO] Installing DRIVERS Module...
2022-09-08 16:44:35
[INFO] Installing MANUAL Module...
2022-09-08 16:44:35
[INFO] Installing SERVICE Module...
2022-09-08 16:44:36
[INFO] Move log file to log directory.
2022-09-08 16:44:37
[INFO] Installed DM DBMS completely.
Please execute the commands by root:
/home/dmdba/dmdbms/script/root/root_installer.sh
End
注意: 安装完成后,终端提示“请以 root 系统用户执行命令”。由于使用非 root系统用户进行安装,所以部分安装步骤没有相应的系统权限,需要用户手动执行相关命令。用户可根据提示完成相关操作
[root@ZWZF-CWY-LZY-12 tmp]# /home/dmdba/dmdbms/script/root/root_installer.sh Move /home/dmdba/dmdbms/bin/dm_svc.conf to /etc Modify the files' mode of DM Server Create the DmAPService service Created symlink from /etc/systemd/system/multi-user.target.wants/DmAPService.service to /usr/lib/systemd/system/DmAPService.service. Finished to create the service (DmAPService) Start the DmAPService service
3.4 数据库初始化
执行dminit命令,进行数据库初始化。
[dmdba@ZWZF-CWY-LZY-12 upload]$ cd /home/dmdba/dmdbms/bin
[dmdba@ZWZF-CWY-LZY-12 bin]$ ./dminit
initdb V8
db version: 0x7000c
file dm.key not found, use default license!
License will expire on 2023-06-30
input system dir: /home/dmdba/dmdbms/data
input db name: DAMENG
input port num: 5236
input page size(4, 8, 16, 32): 32
input extent size(16, 32, 64): 32
input sec priv mode(0, 1, 2, 3): 0
input time zone(-12:59,+14:00): +8:00
string case sensitive? ([Y]es, [N]o): N
which charset to use? (0[GB18030], 1[UTF-8], 2[EUC-KR]): 1
length in char? ([Y]es, [N]o): Y
enable database encrypt? ([Y]es, [N]o): N
input slice size(0, 512, 4096): 4096
page check mode? (0/1/2): 0
input elog path: /home/dmdba/dmdbms/data
only create huge table with delta? (0/1): 0
rlog generate for huge? (0/1): 0
pseg_mgr_flag (0/1): 0
auto_overwrite mode? (0/1/2): 0
CHARACTER type fixed storage ? ([Y]es/1, [N]o/0): 0
SQL log forbid ? ([Y]es/1, [N]o/0): 0
Normal of FAST
Normal of DEFAULT
Normal of RECYCLE
Normal of KEEP
Normal of ROLL
log file path: /home/dmdba/dmdbms/data/DAMENG/DAMENG01.log
log file path: /home/dmdba/dmdbms/data/DAMENG/DAMENG02.log
write to dir [/home/dmdba/dmdbms/data/DAMENG].
create dm database success. 2022-09-08 17:11:42
4. 为数据库实例注册服务
切换root用户,前往 /home/dmdba/dmdbms/script/root下,找到dm_service_installer.sh脚本,该脚本是用于安装实例服务的 【注意:要切换root用户,该脚本只有root用户能执行】
该命令有几个重要的配置项
-t 服务类型,包括dmimon,dmap,dmserver,dmwatcher,dmmonitor,dmcss,dmcssm,dmasmsvr,dmdcs,dmdrs,dmdras,dmdss
-p 服务名后缀,对于dmimon,dmap服务类型无效
-dm_ini dm.ini文件路径 【这个文件就是上面安装完数据库实例后,在指定的path下面生成dm.ini文件】
执行以下命令注册服务
./dm_service_installer.sh -t dmserver -p DMSERVER -dm_ini /home/dmdba/dmdbms/data/DAMENG/dm.ini
[root@ZWZF-CWY-LZY-12 root]# ./dm_service_installer.sh -t dmserver -p DMSERVER -dm_ini /home/dmdba/dmdbms/data/DAMENG/dm.ini Created symlink from /etc/systemd/system/multi-user.target.wants/DmServiceDMSERVER.service to /usr/lib/systemd/system/DmServiceDMSERVER.service. Finished to create the service (DmServiceDMSERVER)
服务注册完成,会在/home/dmdba/dmdbms/bin目录下创建 DmService + 服务名后缀的脚本,由于上面我注册服务使用的后缀名是 DMSERVER ,所以这个脚本名就是 DmServiceDMSERVER
5. 启动数据库
通过注册服务生成的脚本启动达梦数据库服务
[dmdba@ZWZF-CWY-LZY-12 bin]# ./DmServiceDMSERVER start Starting DmServiceDMSERVER: Last login: Thu Sep 8 16:40:33 CST 2022 on pts/1 [ OK ]
至此,达梦数据库实例服务启动完成。
初始化过程中设置服务端口为5236,故通过 lsof -i:5236 ,查看该端口是否已经启动监听
[dmdba@ZWZF-CWY-LZY-12 bin]$ lsof -i:5236 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME dmserver 17977 dmdba 4u IPv6 377780630 0t0 TCP *:padl2sim (LISTEN)
6. 登录数据库
进入/home/dmdba/dmdbms/bin目录下,通过disql命令来访问数据库
[dmdba@ZWZF-CWY-LZY-12 bin]$ pwd /home/dmdba/dmdbms/bin [dmdba@ZWZF-CWY-LZY-12 bin]$ ./disql disql V8 username:SYSDBA password: Server[LOCALHOST:5236]:mode is normal, state is open login used time : 4.513(ms) SQL>
7. 许可证(License)替换
达梦许可证过期后,继续使用达梦服务,需要替换dm.key。操作如下:
① 将达梦数据库服务关闭
② 进入达梦安装目录的bin目录下(如:/home/dmdba/dmdbms/bin),将原有dm.key备份,将新的dm.key复制到bin目录。
③ 重启达梦数据库
8. 卸载达梦数据库
用户在 DM 安装目录下,找到卸载程序 uninstall.sh 来执行卸载。 用户执行命令“ ./uninstall.sh -i ”来卸载程序
[dmdba@ZWZF-CWY-LZY-12 dmdbms]$ ./uninstall.sh -i Check the DMDBMS installed by root, if uninstall by that is not root, maybe has some files to remain. if the DMDBMS is installed by that is not root, please continue to run the uninstall program. Whether continue to run the uninstall program? (y/Y:Yes n/N:No):y Whether to uninstall DM database(/home/dmdba/dmdbms/)? (y/Y:Yes n/N:No):y Whether to deletet the dm_svc.conf file? (y/Y:Yes n/N:No):y Uninstalling all database services Uninstalling DmJobMonitorService database services Uninstalling DmInstanceMonitorService database services Uninstalling DmAuditMonitorService database services Uninstalling DmAPService database services Uninstalling DmServiceDMSERVER database services Uninstall all database services completed Uninstalling database directorys Uninstalling bin directory Uninstall bin directory completed Uninstalling bin2 directory Uninstall bin2 directory completed Uninstalling include directory Uninstall include directory completed Uninstalling desktop directory Uninstall desktop directory completed Uninstalling doc directory Uninstall doc directory completed Uninstalling drivers directory Uninstall drivers directory completed Uninstalling jdk directory Uninstall jdk directory completed Uninstalling jar directory Uninstall jar directory completed Uninstalling samples directory Uninstall samples directory completed Uninstalling script directory Uninstall script directory completed Uninstalling tool directory Uninstall tool directory completed Uninstalling web directory Uninstall web directory completed Uninstalling uninstall directory Uninstall uninstall directory completed Uninstalling license_en.txt file Uninstall license_en.txt file completed Uninstalling license_zh.txt file Uninstall license_zh.txt file completed Uninstalling uninstall.sh file Uninstall uninstall.sh file completed Uninstall database directorys completed Execute the command by "root": /home/dmdba/dmdbms/root_uninstaller.sh
在 Linux(Unix)系统下,使用非 root 用户卸载完成时, 终端提示“Execute the command by "root": /home/dmdba/dmdbms/root_uninstaller.sh”。用户需要手动执行相关命令。如下图所示:
[root@ZWZF-CWY-LZY-12 ~]# /home/dmdba/dmdbms/root_uninstaller.sh Delete DmAPService service Removed symlink /etc/systemd/system/multi-user.target.wants/DmAPService.service. Delete DmServiceDMSERVER service Removed symlink /etc/systemd/system/multi-user.target.wants/DmServiceDMSERVER.service. Delete /etc/dm_svc.conf [root@ZWZF-CWY-LZY-12 ~]#
至此,达梦服务卸载完成!
拓展
通过help可以打印dminit帮助信息
[dmdba@ZWZF-CWY-LZY-12 bin]$ ./dminit help initdb V8 db version: 0x7000c file dm.key not found, use default license! License will expire on 2023-06-30 version: 03134283904-20220630-163817-20005 Format: ./dminit KEYWORD=value Example: ./dminit PATH=/public/dmdb/dmData PAGE_SIZE=16 Keyword Explanation(default value) -------------------------------------------------------------------------------- INI_FILE dm.ini path PATH database path CTL_PATH control file path LOG_PATH log file path EXTENT_SIZE extent size of data file(16), optional value: 16, 32, 64, unit: PAGE PAGE_SIZE page size(8), optional value: 4, 8, 16, 32, unit: K LOG_SIZE log file size(256), unit: M, range: 256M ~ 2G CASE_SENSITIVE whether case is sensitive(Y), optional value: Y/N or 1/0 CHARSET/UNICODE_FLAG CHARSET(0), optional value:0[GB18030],1[UTF-8],2[EUC-KR] SEC_PRIV_MODE security privilege mode(0), optional value▒▒0[TRADITION], 1[BMJ], 2[EVAL], 3[ZB] LENGTH_IN_CHAR whether LENGTH for VARCHAR is in characters(N), optional value: Y/N, 1/0 SYSDBA_PWD set SYSDBA password(SYSDBA) SYSAUDITOR_PWD set SYSAUDITOR password(SYSAUDITOR) DB_NAME database name(DAMENG) INSTANCE_NAME instance name(DMSERVER) PORT_NUM listener port(5236) BUFFER System buffer size(100), unit: M TIME_ZONE set time zone(+08:00) PAGE_CHECK page check mode(0), optional value: 0/1/2 PAGE_HASH_NAME set page check hash algorithm EXTERNAL_CIPHER_NAME set default encrypt/decrypt algorithm EXTERNAL_HASH_NAME set default hash algorithm EXTERNAL_CRYPTO_NAME set crypto name to encrypt svr key RLOG_ENCRYPT_NAME encrypt cipher name of redo log USBKEY_PIN set usbkey pin PAGE_ENC_SLICE_SIZE slice size for page encryption, optional value: 0, 512, 4096, unit: Byte ENCRYPT_NAME set algorithm for encrypt the whole database BLANK_PAD_MODE set blank padding mode(0), optional value:0/1 SYSTEM_MIRROR_PATH mirror path of system data file MAIN_MIRROR_PATH mirror path of main file ROLL_MIRROR_PATH mirror path of roll file MAL_FLAG MAL_INI flag(0) in dm.ini ARCH_FLAG ARCH_INI(0) flag in dm.ini MPP_FLAG MPP_INI(0) flag in dm.ini CONTROL control file path! AUTO_OVERWRITE whether overwrite all files with the same name(0) 0: no 1: part 2: all USE_NEW_HASH whether use new hash algorithm for string. (default 1) DCP_MODE whether is DM CLUSTER PROXY mode(default 0) DCP_PORT_NUM in DCP mode, set dcp_port_num ELOG_PATH set the path of log file recording the contents during initialization AP_PORT_NUM listener port for cooperative worker in distribution environment DFS_FLAG DFS_INI flag(0) in dm.ini DFS_PATH default path of db file when dfs_flag is true DFS_HOST ip of ddfs(localhost) DFS_PORT port number of ddfs(3332) DFS_COPY_NUM copy num of dfs file(3) DFS_DB_NAME database name in ddfs(default same as DB_NAME) SHARE_FLAG database share flag in ddfs(default 0) REGION_MODE system tablespace datafile region policy in ddfs(default 0) 0: MICRO 1: GREAT HUGE_WITH_DELTA Only support to create with delta huge table(default 1) 1: YES 0: NO RLOG_GEN_FOR_HUGE whether to generate redo log for with delta huge table(default 0) 1: YES 0: NO PSEG_MGR_FLAG Only use manager segment to record trx info(default 0) 1: YES 0: NO CHAR_FIX_STORAGE whether CHARACTER type stored by fixed length(N), optional value: Y/N, 1/0 SQL_LOG_FORBID whether forbid SQL log(N), optional value: Y/N, 1/0 DPC_MODE specify instance role in DPC cluster(default 0) 0: None 1: MP 2: BP 3: SP, value MP/BP/SP also works HELP print help information
本文来自博客园,作者:查拉图斯特拉面条,转载请注明原文链接:https://www.cnblogs.com/n00dle/p/16670161.html