前言
近期,参加达梦公司组织的DCA认证培训,在中标麒麟下安装DM8数据库,以下是安装笔记。
一、安装DM数据库
1.服务器信息查看
[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64
[root@localhost ~]# cat /etc/issue
\S
Kernel \r on an \m
[root@localhost ~]# uname -m
x86_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
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 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% /
devtmpfs 1.1G 0 1.1G 0% /dev
tmpfs 1.1G 0 1.1G 0% /dev/shm
tmpfs 1.1G 11M 1.1G 1% /run
tmpfs 1.1G 0 1.1G 0% /sys/fs/cgroup
/dev/sda1 1014M 158M 857M 16% /boot
tmpfs 212M 4.0K 212M 1% /run/user/42
tmpfs 212M 68K 212M 1% /run/user/0
/dev/sr0 4.0G 4.0G 0 100% /run/media/root/nsV7Update6-x86_64
3.检查glibc包
[root@localhost ~]# rpm -aq| grep glibc
compat-glibc-2.12-4.el7.x86_64
glibc-headers-2.17-260.el7.ns7.01.x86_64
glibc-2.17-260.el7.ns7.01.x86_64
compat-glibc-headers-2.12-4.el7.x86_64
glibc-devel-2.17-260.el7.ns7.01.x86_64
glibc-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 dmdba
dmdba:x:1001:1002::/home/dmdba:/bin/bash
[dmdba@localhost ~]$ vi /etc/security/limits.conf
增加
dmdba soft nofile 65536
dmdba hard nofile 65536
[root@localhost ~]# sysctl -p
[root@localhost ~]# source /etc/profile
6.创建安装目录(数据库安装目录、数据库文件目录):
[root@localhost ~]# mount -o loop /run/media/root/nsV7Update6-x86_64/ /mnt
mount: /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]# ls
DM8 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 2020pts/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 下载]# ls
unixODBC-2.3.0 unixODBC-2.3.0.tar.gz
[root@localhost 下载]# cd unixODBC-2.3.0/
2.安装ODBC
[root@localhost unixODBC-2.3.0]# ls
acinclude.m4 cur INSTALL missing README.SOLARIS
aclocal.m4 depcomp install-sh mkinstalldirs README.VMS
AUTHORS doc Interix NEWS samples
ChangeLog DriverManager libltdl odbcinst vms
config.guess Drivers log README vmsbuild.com
config.h.in DRVConfig lst README.AIX ylwrap
config.sub exe ltmain.sh README.CYGWIN
configure extras m4 README.INTERIX
configure.in include Makefile.am README.OSX
COPYING 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]# ls
acinclude.m4 configure.in ini Makefile.am README.QNX
aclocal.m4 COPYING INSTALL Makefile.in README.SOLARIS
AUTHORS cur install-sh missing README.VMS
ChangeLog depcomp Interix mkinstalldirs samples
config.guess doc libltdl NEWS stamp-h1
config.h DriverManager libtool odbcinst vms
config.h.in Drivers log README vmsbuild.com
config.log DRVConfig lst README.AIX ylwrap
config.status exe ltmain.sh README.CYGWIN
config.sub extras m4 README.INTERIX
configure include Makefile README.OSX
[root@localhost unixODBC-2.3.0]# make
3.配置ODBC
[root@localhost unixODBC-2.3.0]# odbc_config --version
2.3.0
[root@localhost unixODBC-2.3.0]# odbcinst -j
unixODBC 2.3.0
DRIVERS............: /usr/local/etc/odbcinst.ini
SYSTEM DATA SOURCES: /usr/local/etc/odbc.ini
FILE DATA SOURCES..: /usr/local/etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW 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 DM8
Driver = /dm8/dmdbms/bin/libdodbc.so
[dmdba@localhost etc]$ cat odbc.ini
[dm8]
Description = DM ODBC DSND
Driver = DM8 ODBC DRIVER
SERVER = localhost
UID = SYSDBA
PWD = master159357
TCP_PORT = 5236
4.disql查询
1.查表空间
SQL> desc v$tablespace;
行号 NAME TYPE$ NULLABLE
---------- ------------- ------------ --------
1 ID INTEGER Y
2 NAME VARCHAR(128) Y
3 CACHE VARCHAR(20) Y
4 TYPE$ TINYINT Y
5 STATUS$ TINYINT Y
6 MAX_SIZE BIGINT Y
7 TOTAL_SIZE BIGINT Y
8 FILE_NUM INTEGER Y
9 ENCRYPT_NAME VARCHAR(128) Y
10 ENCRYPTED_KEY VARCHAR(500) Y
11 COPY_NUM INTEGER Y
行号 NAME TYPE$ NULLABLE
---------- --------- ------------ --------
12 SIZE_MODE VARCHAR(128) Y
12 rows got
SQL> select name,status$ from v$tablespace;
行号 NAME STATUS$
---------- ------ -----------
1 SYSTEM 0
2 ROLL 0
3 TEMP 0
4 MAIN 0
已用时间: 22.982(毫秒). 执行号:508.
SQL> select tablespace_name from dba_tablespaces;
行号 TABLESPACE_NAME
---------- ---------------
1 SYSTEM
2 ROLL
3 TEMP
4 MAIN
5 PERSON
6 HMAIN
6 rows got
2.查数据文件
SQL> desc v$datafile;
行号 NAME TYPE$ NULLABLE
---------- -------------- ------------ --------
1 GROUP_ID INTEGER Y
2 ID INTEGER Y
3 PATH VARCHAR(256) Y
4 CLIENT_PATH VARCHAR(256) Y
5 CREATE_TIME DATETIME(0) Y
6 STATUS$ TINYINT Y
7 RW_STATUS TINYINT Y
8 LAST_CKPT_TIME DATETIME(0) Y
9 MODIFY_TIME DATETIME(0) Y
10 MODIFY_TRX BIGINT Y
11 TOTAL_SIZE BIGINT Y
行号 NAME TYPE$ NULLABLE
---------- ------------- ------------ --------
12 FREE_SIZE BIGINT Y
13 FREE_PAGE_NO BIGINT Y
14 PAGES_READ BIGINT Y
15 PAGES_WRITE BIGINT Y
16 PAGE_SIZE INTEGER Y
17 READ_REQUEST INTEGER Y
18 WRITE_REQUEST INTEGER Y
19 AUTO_EXTEND INTEGER Y
20 MAX_SIZE INTEGER Y
21 NEXT_SIZE INTEGER Y
22 MIRROR_PATH VARCHAR(256) Y
22 rows got
已用时间: 26.439(毫秒). 执行号:509.
SQL> select path,status$ from v$datafile;
行号 PATH STATUS$
---------- ----------------------------------- -----------
1 /dm8/dmdbms/data/DM02/DM/SYSTEM.DBF 1
2 /dm8/dmdbms/data/DM02/DM/ROLL.DBF 1
3 /dm8/dmdbms/data/DM02/DM/TEMP.DBF 1
4 /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_2020_08_05_14_59_54” backupset ‘TS_DMHR_FULL_2020_08_05_14_59_54’;
表备份: backup table “TEST”.“TEST11” to “TAB_TEST_TEST11_2020_08_05_15_01_16” backupset ‘TAB_TEST_TEST11_2020_08_05_15_01_16’;
归档备份: backup archivelog all to “ARCH_2020_08_05_15_05_27” backupset
‘ARCH_2020_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
---------- ---- ----------- ---------
1 DM 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]$ ./dmrman
RMAN> 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 = 0
EP[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 = 0
EP[0]'s cur_lsn[34895]
EP[0]'s apply_lsn[34895] >= end_lsn[34895]
recover successfully!
time used: 973.951(ms)
RMAN>
总结
提示:这里对文章进行总结:
例如:以上就是今天要讲的内容,本文仅仅简单介绍了pandas的使用,而pandas提供了大量能使我们快速便捷地处理数据的函数和方法。