前言
近期,参加达梦公司组织的DCA认证培训,在中标麒麟下安装DM8数据库,以下是安装笔记。
一、安装DM数据库
1.服务器信息查看
[root@localhost ~]# uname -r3.10.0-957.el7.x86_64[root@localhost ~]# cat /etc/issue\SKernel \r on an \m[root@localhost ~]# uname -mx86_64
2.硬盘使用情况
[root@localhost ~]# fdisk -l磁盘 /dev/sda:26.8 GB, 26843545600 字节,52428800 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘标签类型:dos磁盘标识符:0x000a616c设备 BootStart EndBlocks Id System/dev/sda1 * 204820991991048576 83 Linux/dev/sda2 2099200 52428799 25164800 8e Linux LVM磁盘 /dev/mapper/nlas-root:23.3 GB, 23345496064 字节,45596672 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节磁盘 /dev/mapper/nlas-swap:2415 MB, 2415919104 字节,4718592 个扇区Units = 扇区 of 1 * 512 = 512 bytes扇区大小(逻辑/物理):512 字节 / 512 字节I/O 大小(最小/最佳):512 字节 / 512 字节[root@localhost ~]# df -h文件系统容量 已用 可用 已用% 挂载点/dev/mapper/nlas-root 22G 4.8G 17G 22% /devtmpfs1.1G0 1.1G 0% /devtmpfs 1.1G0 1.1G 0% /dev/shmtmpfs 1.1G 11M 1.1G 1% /runtmpfs 1.1G0 1.1G 0% /sys/fs/cgroup/dev/sda1 1014M 158M 857M 16% /boottmpfs 212M 4.0K 212M 1% /run/user/42tmpfs 212M 68K 212M 1% /run/user/0/dev/sr04.0G 4.0G0 100% /run/media/root/nsV7Update6-x86_64
3.检查glibc包
[root@localhost ~]# rpm -aq| grep glibccompat-glibc-2.12-4.el7.x86_64glibc-headers-2.17-260.el7.ns7.01.x86_64glibc-2.17-260.el7.ns7.01.x86_64compat-glibc-headers-2.12-4.el7.x86_64glibc-devel-2.17-260.el7.ns7.01.x86_64glibc-common-2.17-260.el7.ns7.01.x86_64
4.创建安装目录(数据库安装目录、数据库文件目录):
[root@localhost ~]# mkdir /dm8[root@localhost ~]# groupadd dinstall[root@localhost ~]# useradd -g dinstall dmdba[root@localhost ~]# passwd dmdba更改用户 dmdba 的密码 。新的 密码:无效的密码: 密码少于 8 个字符重新输入新的 密码:passwd:所有的身份验证令牌已经成功更新。[root@localhost ~]# chown -R dmdba:dinstall /dm8
5.配置环境变量,修改文件最大打开数
[root@localhost ~]# vi .bash_profile[root@localhost ~]# echo $DM_HOME[root@localhost ~]# source .bash_profile[root@localhost ~]#[root@localhost ~]# cat /etc/passwd | grep dmdbadmdba:x:1001:1002::/home/dmdba:/bin/bash[dmdba@localhost ~]$ vi /etc/security/limits.conf增加dmdba soft nofile65536dmdba hard nofile65536[root@localhost ~]# sysctl -p[root@localhost ~]# source /etc/profile
6.创建安装目录(数据库安装目录、数据库文件目录):
[root@localhost ~]# mount -o loop /run/media/root/nsV7Update6-x86_64/ /mntmount: /run/media/root/nsV7Update6-x86_64:设置回环设备失败: 是一个目录[root@localhost ~]# mount -o loop /dev/sr0 /mnt[root@localhost ~]# pwd/root[root@localhost ~]# cd /mnt[root@localhost mnt]# lsDM8 Install.pdf DMInstall.bin注意注销root用户,切换到dmdba用户启动界面,要不图形可能启动不起来,安装步骤比较简单不做过多记录。安装完成后配置环境变量,要不执行命令比较费劲。
7.以DMDBA用户登录
[root@localhost ~]# su - dmdba\u4e0a\u4e00\u6b21\u767b\u5f55\uff1a\u4e00 11\u6708 30 15:37:56 CST pts/1 \u4e0a[dmdba@localhost ~]$ export DISPLAY=localhost:1[dmdba@localhost ~]$ xhost +access control disabled, clients can connect from any host[dmdba@localhost ~]$
8.以文本方式安装
[dmdba@localhost ~]$cd /mnt[dmdba@localhost ~] ./DMInstall.bin -i建库[dmdba@localhost ~]/dm7/bin/dminit./dminit path=/dm7/data db_name=DM02 instance_name=DM02 port_num=5237
ODBC安装
1.解压ODBC安装包
[root@localhost 下载]# tar -xvf unixODBC-2.3.0.tar.gz [root@localhost 下载]# lsunixODBC-2.3.0 unixODBC-2.3.0.tar.gz[root@localhost 下载]# cd unixODBC-2.3.0/
2.安装ODBC
[root@localhost unixODBC-2.3.0]# lsacinclude.m4 cur INSTALLmissing README.SOLARISaclocal.m4 depcomp install-sh mkinstalldirs README.VMSAUTHORS doc InterixNEWS samplesChangeLogDriverManager libltdlodbcinst vmsconfig.guess Drivers logREADMEconfig.h.in DRVConfiglstREADME.AIXylwrapconfig.sub exe ltmain.sh README.CYGWINconfigureextras m4 README.INTERIXconfigure.in include Makefile.am README.OSXCOPYING ini Makefile.in README.QNX[root@localhost unixODBC-2.3.0]# ./configure --enable-gui=no[root@localhost unixODBC-2.3.0]# pwd/root/下载/unixODBC-2.3.0[root@localhost unixODBC-2.3.0]# lsacinclude.m4 configure.in ini Makefile.amREADME.QNXaclocal.m4COPYING INSTALLMakefile.inREADME.SOLARISAUTHORS cur install-sh missing README.VMSChangeLogdepcomp Interixmkinstalldirs samplesconfig.guess doc libltdlNEWS stamp-h1config.h DriverManager libtoolodbcinst vmsconfig.h.in Drivers log READMEconfig.logDRVConfiglst README.AIXylwrapconfig.status exe ltmain.sh README.CYGWINconfig.subextras m4README.INTERIXconfigureinclude Makefile README.OSX[root@localhost unixODBC-2.3.0]# make
3.配置ODBC
[root@localhost unixODBC-2.3.0]# odbc_config --version2.3.0[root@localhost unixODBC-2.3.0]# odbcinst -junixODBC 2.3.0DRIVERS............: /usr/local/etc/odbcinst.iniSYSTEM DATA SOURCES: /usr/local/etc/odbc.iniFILE DATA SOURCES..: /usr/local/etc/ODBCDataSourcesUSER DATA SOURCES..: /root/.odbc.iniSQLULEN Size.......: 8SQLLEN Size........: 8SQLSETPOSIROW Size.: 8[root@localhost unixODBC-2.3.0]# cd /usr/local/etc/[root@localhost etc]# pwd/usr/local/etc[root@localhost etc]# vi odbc.ini [root@localhost etc]# vi odbcinst.ini [root@localhost etc]# vi odbc.ini [root@localhost etc]# chmod 775 odbc.ini [root@localhost etc]# chmod 775 odbcinst.ini [root@localhost etc]# ls[dmdba@localhost ~]$ cd /usr/local/etc/[dmdba@localhost etc]$ cat odbcinst.ini [DM8 ODBC DRIVER]Description = ODBC DRIVER FOR DM8Driver = /dm8/dmdbms/bin/libdodbc.so[dmdba@localhost etc]$ cat odbc.ini [dm8]Description = DM ODBC DSNDDriver = DM8 ODBC DRIVERSERVER = localhostUID = SYSDBAPWD = master159357 TCP_PORT = 5236
4.disql查询
1.查表空间
SQL> desc v$tablespace;行号NAMETYPE$ NULLABLE---------- ------------- ------------ --------1ID INTEGERY2NAMEVARCHAR(128) Y3CACHE VARCHAR(20) Y4TYPE$ TINYINTY5STATUS$ TINYINTY6MAX_SIZEBIGINT Y7TOTAL_SIZE BIGINT Y8FILE_NUMINTEGERY9ENCRYPT_NAME VARCHAR(128) Y10 ENCRYPTED_KEY VARCHAR(500) Y11 COPY_NUMINTEGERY行号NAMETYPE$ NULLABLE---------- --------- ------------ --------12 SIZE_MODE VARCHAR(128) Y12 rows gotSQL> select name,status$ from v$tablespace;行号NAME STATUS$---------- ------ -----------1SYSTEM 02ROLL 03TEMP 04MAIN 0已用时间: 22.982(毫秒). 执行号:508.SQL> select tablespace_name from dba_tablespaces;行号TABLESPACE_NAME---------- ---------------1SYSTEM2ROLL3TEMP4MAIN5PERSON6HMAIN6 rows got
2.查数据文件
SQL> desc v$datafile;行号NAME TYPE$ NULLABLE---------- -------------- ------------ --------1GROUP_ID INTEGERY2ID INTEGERY3PATH VARCHAR(256) Y4CLIENT_PATH VARCHAR(256) Y5CREATE_TIME DATETIME(0) Y6STATUS$ TINYINTY7RW_STATUSTINYINTY8LAST_CKPT_TIME DATETIME(0) Y9MODIFY_TIME DATETIME(0) Y10 MODIFY_TRXBIGINT Y11 TOTAL_SIZEBIGINT Y行号NAMETYPE$ NULLABLE---------- ------------- ------------ --------12 FREE_SIZEBIGINT Y13 FREE_PAGE_NO BIGINT Y14 PAGES_READ BIGINT Y15 PAGES_WRITE BIGINT Y16 PAGE_SIZEINTEGERY17 READ_REQUEST INTEGERY18 WRITE_REQUEST INTEGERY19 AUTO_EXTEND INTEGERY20 MAX_SIZEINTEGERY21 NEXT_SIZEINTEGERY22 MIRROR_PATH VARCHAR(256) Y22 rows got已用时间: 26.439(毫秒). 执行号:509.SQL> select path,status$ from v$datafile;行号PATH STATUS$---------- ----------------------------------- -----------1/dm8/dmdbms/data/DM02/DM/SYSTEM.DBF 12/dm8/dmdbms/data/DM02/DM/ROLL.DBF 13/dm8/dmdbms/data/DM02/DM/TEMP.DBF 14/dm8/dmdbms/data/DM02/DM/MAIN.DBF 1已用时间: 17.592(毫秒). 执行号:510.
3.表空间数据文件路径修改
SQL> alter tablespace person offline;操作已执行已用时间: 87.146(毫秒). 执行号:514.SQL> alter tablespace person rename datafile '/dm8/dmdbms/data/DM02/DM/person02.dbf' to '/dm8/dmdbms/data/DM02/DM/person03.dbf';操作已执行已用时间: 59.666(毫秒). 执行号:515.SQL> alter tablespace person online;操作已执行已用时间: 2.877(毫秒). 执行号:516.SQL>
4.修改数据库归档模式
SQL> alter database mount;操作已执行已用时间: 00:00:01.761. 执行号:0.SQL> alter database add archivelog 'type=local,dest=/dm8/dmdbms/data/DMO2/DM/arch ,file_size=64,space_limit=0';操作已执行已用时间: 4.093(毫秒). 执行号:0.SQL> alter database archivelog;操作已执行已用时间: 2.755(毫秒). 执行号:0.SQL> alter database open;操作已执行已用时间: 00:00:01.729. 执行号:0.SQL>DM7数据库支持用户表空间的备份还原操作。表空间备份需要在联机状态下执行,并且需要开启数据库归档模式。
5.备份数据库
SQL> alter database open;操作已执行已用时间: 00:00:01.726. 执行号:0.全备:SQL> backup database full backupset ‘/dm8/backup’;SQL> backup database full backupset '/dm8/dmdbms/data/DM/hostbak';操作已执行已用时间: 955.549(毫秒). 执行号:7.增量备份:SQL> backup database increment backupset ‘/dm8/backup/incrbak’;SQL> backup database increment backupset '/dm8/dmdbms/data/DM/hostincre';操作已执行已用时间: 00:00:02.656. 执行号:8.表空间备份: backup tablespace “DMHR” full to “TS_DMHR_FULL__08_05_14_59_54” backupset ‘TS_DMHR_FULL__08_05_14_59_54’;表备份: backup table “TEST”.“TEST11” to “TAB_TEST_TEST11__08_05_15_01_16” backupset ‘TAB_TEST_TEST11__08_05_15_01_16’;归档备份: backup archivelog all to “ARCH__08_05_15_05_27” backupset‘ARCH__08_05_15_05_27’;SQL> backup tablespace person full to person_bak bakfile '/dm8/dmdbms/data/DM02/DM/person_bak.bak';操作已执行已用时间: 856.539(毫秒). 执行号:523.查看数据库归档状态SQL> select name,status$,arch_mode from v$database;行号NAME STATUS$ARCH_MODE---------- ---- ----------- ---------1DM 4 Y
6.dmrman备份数据库
解决: 冷备需要先停止数据库。停止数据库后,即可备份成功。[dmdba@localhost bin]$ systemctl stop DmServiceDM02.service 先将DM02服务停止,然后在DM 控制台工具进行备份还原操作。否则将报错误信息[dmdba@localhost bin]$ systemctl start DmServiceDM02.service [dmdba@localhost bin]$ systemctl status DmServiceDM02.service cd /dm8/bin[dmdba@localhost bin]$ ./dmrmanRMAN> backup database ‘/dm8/data/DAMENG/dm.ini’;
7.dmrman恢复数据库
RMAN> check backupset '/dm8/dmdbms/data/DM/bak/';check backupset '/dm8/dmdbms/data/DM/bak/';CMD END.CODE:[0]check backupset successfully.time used: 27.945(ms)RMAN> restore database '/dm8/dmdbms/data/DM/dm.ini' from backupset '/dm8/dmdbms/data/DM/bak/';restore database '/dm8/dmdbms/data/DM/dm.ini' from backupset '/dm8/dmdbms/data/DM/bak/';file dm.key not found, use default license!RESTORE DATABASE CHECK......RESTORE DATABASE,data collect......RESTORE DATABASE,database refresh ......RESTORE BACKUPSET [/dm8/dmdbms/data/DM/bak] START......total 0 packages processed...RESTORE DATABASE,UPDATE ctl file......RESTORE DATABASE,REBUILD key file......RESTORE DATABASE,CHECK db info......RESTORE DATABASE,UPDATE db info......CMD END.CODE:[0]restore successfully.time used: 277.898(ms)RMAN> recover database '/dm8/dmdbms/data/DM/dm.ini' from backupset '/dm8/dmdbms/data/DM/bak/';recover database '/dm8/dmdbms/data/DM/dm.ini' from backupset '/dm8/dmdbms/data/DM/bak/';Database mode = 0, oguid = 0EP[0]'s cur_lsn[34895]RESTORE RLOG CHECK......CMD END.CODE:[603],DESC:[备份集[/dm8/dmdbms/data/DM/bak]备份过程中未产生日志]备份集[/dm8/dmdbms/data/DM/bak]备份过程中未产生日志recover successfully!time used: 241.601(ms)RMAN> recover database '/dm8/dmdbms/data/DM/dm.ini' update db_magic;recover database '/dm8/dmdbms/data/DM/dm.ini' update db_magic;Database mode = 0, oguid = 0EP[0]'s cur_lsn[34895]EP[0]'s apply_lsn[34895] >= end_lsn[34895]recover successfully!time used: 973.951(ms)RMAN>
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。
如果觉得《中标麒麟系统安装达梦数据库》对你有帮助,请点赞、收藏,并留下你的观点哦!