DCA
数据库安装
新建用户以及用户组
groupadd dinstall
useradd -g dinstall -m -d /home/dmdba -s /bin/bash dmdba
passwd dmdba
规划目录
mkdir /dm
chown dmdba:dinstall /dm
cat /etc/security/limits.conf
dmdba soft nofile 65536
dmdba hard nofile 65536
安装数据库
./DMInstall.bin -i
实例安装
实例安装 (dmdba)
su - dmdba;
cd /dm/bin;
./dminit
path=/dm/data
db_name=DMDB
instance_NAME=PROD sysdba_pwd=Dameng123 port_num=5238 PAGE_SIZE=16 CHARSET=1 EXTENT_SIZE=8;
exit;
./dm/script/root/root_installer.sh
注册服务(root)
cd /dm/script/root;
./dm_service_installer.sh -t dmserver -p DMTESTSVR -dm_ini
/dm8/data/DMTEST/dm.ini
参数修改
----修改模式兼容Oracle
alter system set 'COMPATIBLE_MODE'=2 spfile;
表空间管理
----新建表空间
create TABLESPACE MIDINX DATAFILE 'MINDINX01.DBF' SIZE 64;
create TABLESPACE OADATA DATAFILE 'DMDATA01.DBF' SIZE 64;
----修改表空间自增
alter TABLESPACE OADATA DATAFILE 'DMDATA01.DBF' AUTOEXTEND ON NEXT 2 MAXSIZE 1024;
----迁移表空间数据文件
alter tablespace "DMDATA" offline;
alter tablespace "DMDATA" rename datafile 'DMDATA01.DBF' to '/dm/data/DMTEST/DMDATA02.DBF';
alter tablespace "DMDATA" online;
----表空间新增数据文件
alter TABLESPACE DMDATA ADD DATAFILE 'DMDATA02.DBF' SIZE 64;
alter TABLESPACE DMDATA ADD DATAFILE 'DMDATA03.DBF' SIZE 64 AUTOEXTEND ON NEXT 2 MAXSIZE 1024;
----删除表空间
drop TABLESPACE OADATA;
用户管理
用户管理
- ---- 创建用户
create USER test IDENTIFIED BY "Dameng123" password_policy 1 DEFAULT TABLESPACE DMDATA ;
----锁/解锁用户
alter USER TEST ACCOUNT LOCK;
alter USER TEST ACCOUNT UNLOCK;
----修改用户默认表空间
alter USER TEST DEFAULT TABLESPACE MIDINX;
----删除用户
drop USER TEST;
权限管理
- -----授权
grant create table to TEST;
----回收权限
revoke CREATE TABLE FROM TEST;
角色管理
- ---- 创建角色
create role r1;
-----角色授权
grant create TABLE TO r1;
grant create INDEX to r1;
grant SELECT on "SYSDBA"."T_TEST02" to "R1";
-----角色授权用户
grant r1 to test;
-----回收用户角色
REVOKE r1 from test;
----删除角色
drop role r1;
模式管理
管理模式
- ---- 创建归属某个用户下的模式
create SCHEMA TEST01 AUTHORIZATION TEST;
----切换模式
set SCHEMA TEST01;
set SCHEMA TEST;
----删除模式
drop SCHEMA TEST01;
管理表
- grant select ON "SYSDBA"."CONFIG_INFO" TO test;
---建表
create table test LIKE SYSDBA.CONFIG_INFO;
---创建表非空约束
alter table TEST.TEST MODIFY id NOT NULL;
---创建表唯一主键约束
alter TABLE TEST.TEST ADD CONSTRAINT p_id PRIMARY KEY("ID");
---创建表检查约束
alter table TEST.TEST ADD CONSTRAINT ck_id CHECK (ID is NOT NULL);
CREATE TABLE "TEST"."T_PARENT"
(
"ID" INT) STORAGE(ON "MIDINX", CLUSTERBTR) ;
CREATE UNIQUE INDEX "p_id" ON "TEST"."T_PARENT"("ID" ASC) STORAGE(ON "MIDINX", CLUSTERBTR) ;
create table test.t_chrilden (id int ,parent_id int, name VARCHAR(20), email varchar(20));
----创建表的外键约束
alter table TEST.T_CHRILDEN add constraint "fk_parent_id" FOREIGN KEY("PARENT_ID") REFERENCES test.T_PARENT(ID) ;
----禁用/启用表的约束条件
alter TABLE TEST.TEST DISABLE CONSTRAINT "p_id";
alter TABLE TEST.TEST ENABLE CONSTRAINT "p_id";
管理索引
- ----创建索引
create INDEX id_md5 ON TEST.TEST(MD5);
----开启索引使用监控
alter index TEST."p_id" MONITORING USAGE;
----关闭索引使用监控
alter index test."p_id" NOMONITORING USAGE;
----查看索引的监控信息
select * from v$object_usage;
管理视图
- ----新建视图
create VIEW v_config AS SELECT TEST.GROUP_ID,COUNT(1) as counts FROM TEST.TEST GROUP BY TEST.GROUP_ID HAVING count(1) > 1;
----查询视图
select * from TEST.V_CONFIG;
----删除视图
drop VIEW TEST.V_CONFIG;
导入脚本
第一种
SQL>start /dm/backup/test.sql
第二种
SQL> set TIMING off;
SQL> set feedback off;
SQL> set echo off;
SQL> `/dm/backup/test.sql
归档管理
----挂载
alter database MOUNT;
----开启归档
alter database ARCHIVELOG;
----配置归档
alter database ADD ARCHIVELOG 'dest=/dm/arch,type=local,file_size=128,space_limit=10240';
----开启
alter database OPEN;
数据库备份
联机备份
- ---全量备份
backup database ;
backup TABLESPACE DMDATA ;
---增量备份
backup database INCREMENT;
backup TABLESPACE DMDATA INCREMENT;
---指定备份到某个目录
backup database full to "DMTEST_FULL" backupset '/dm/backup/FULL/DMTEST_FULL';
脱机备份
- 目录 /dm/bin,使用dmrman备份
RMAN> backup database '/dm/data/DMTEST/dm.ini' to "DMTEST_FULL_1114" backupset '/dm/backup/FULL/DMTEST_FULL_1114';
逻辑备份
- 目录/dm/bin
全库备份
$ mkdir /dm/backup/dexp
$ ./dexp userid=sysdba/SYSDBA:5236 directory=/dm/backup/dexp file=full.dmp log=full.log full=y
按用户导出
dexp userid=sysdba/SYSDBA:5238 directory=/dm8/backup/dexp file=dmtest.dmp log=dmtest.log owner=dmtest
数据库管理
还原
- 目录 /dm/bin,使用dmrman备份
RMAN>restore database '/dm/data/DMTEST/dm.ini' tablespace DMDATA from backupset '/dm/backup/FULL/DMTEST_FULL_1114';
恢复
- 目录 /dm/bin,使用dmrman备份
RMAN>recover database '/dm/data/DMTEST/dm.ini' tablespace DMDATA
逻辑还原
- $ ./dimp userid=sysdba/SYSDBA:5237 directory=/dm/backup/dexp file=full.dmp log=impfull.log full=y
DM作业
ODBC配置
安装odbc
tar -zxf unixODBC-2.3.0.tar.gz
cd unixODBC-2.3.0/
./configure
make
make install
配置/usr/local/etc/odbc.ini
[DM8] # 这个按要求改
Description = DM ODBC DSN
Driver = DM8 ODBC DRIVER
SERVER = localhost
UID = SYSDBA
PWD = SYSDBA
TCP_PORT = 5236
配置/usr/local/etc/odbcinst.ini
[DM8 ODBC DRIVER] # 这块要和上边对应
Drscription = ODBC DRIVER FOR DM8
Driver = /dm/bin/libdodbc.so
测试连接
su - dmdba
$ isql dm8 -v
故障模拟
XMind: ZEN - Trial Version
