当前位置:网站首页>表空间创建管理及控制文件管理
表空间创建管理及控制文件管理
2022-07-03 09:49:00 【用户8006012】
表空间是一个逻辑概念,物理上对应一个或多个数据文件 datafile 或临时文件 tempfiles,逻辑上表空间是存储段的容器。(段也是逻辑概念,是数据库中的对象如表、索引等)
表空间类型
①PERMANENT 永久表空间
②UNDO 撤销表空间
③TEMPORARY 临时表空间
管理方式重点是段的管理方式和区的管理方式, 是在建立表空间时确定的。
1.1查看表空间类型、段和区管理方式
[email protected]> select tablespace_name,contents,segment_space_management,extent_management from dba_tablespaces;
TABLESPACE_NAME CONTENTS SEGMEN EXTENT_MAN
------------------------------ --------- ------ ----------
SYSTEM PERMANENT MANUAL LOCAL
SYSAUX PERMANENT AUTO LOCAL
UNDOTBS1 UNDO MANUAL LOCAL
TEMPTS1 TEMPORARY MANUAL LOCAL
USERS PERMANENT MANUAL LOCAL
[email protected]> select * from v$tablespace;
TS# NAME INC BIG FLA ENC
---------- ------------------------------ --- --- --- ---
0 SYSTEM YES NO YES
1 SYSAUX YES NO YES
2 UNDOTBS1 YES NO YES
3 TEMPTS1 NO NO YES
4 USERS YES NO YES
1.2 查看表空间(数据文件)大小、是否自动扩展
select file_id,file_name,tablespace_name,bytes/1024/1024 M,status,
AUTOEXTENSIBLE from dba_data_files order by 1;
1.3 查看表空间大小
select TABLESPACE_NAME,sum(bytes)/1024/1024 from dba_data_files group by tablespace_name;
1.4 查看表空间空闲大小
select tablespace_name,sum(bytes)/1024/1024 from dba_free_space group by tablespace_name;
1.5 创建 smallfile 表空间
表空间的大小等同它下的数据文件大小之和,默认使用 small 表空间
当发生表空间不足的问题时常用的 3 个解决办法:
1)增加原有数据文件大小(resize)
2)增加一个数据文件(add datafile)
3)设置表空间自动增长(autoextend)
create tablespace test datafile '/u01/app/oracle/oradata/orcl/test01.dbf' size 5m;
1.5.1 resize 扩充表空间
select file_id,file_name,tablespace_name from dba_data_files;
alter database datafile 6 resize 10m;
1.5.2 add datafile 扩充表空间:
alter tablespace test add datafile '/u01/app/oracle/oradata/orcl/test02.dbf' size 30G;
1.5.3 autoextend on 扩充表空间
alter database datafile 6 autoextend on maxsize 30G;
select FILE_ID,TABLESPACE_NAME,BYTES/1024/1024 M_size,
AUTOEXTENSIBLE,MAXBYTES/1024/1024 M_max from dba_data_files;
1.6 建立大文件(bigfile)的表空间
①smallfile:一个表空间可以包含多个数据文件(默认), 块大小 8k 时, 大小需小于 32G。
②bigfile:一个表空间只包含一个数据文件, 8k 的 block 时,最大可达 32T。
create bigfile tablespace bigtbs
datafile '/u01/app/oracle/oradata/orcl/bigtbs01.dbf' size 20m
autoextend on maxsize 4T
extent management local uniform size 2m
segment space management auto;
1.61. 查看大表空间文件
select name,bigfile from v$tablespace;
1.7 删除表空间
drop tablespace test including contents and datafiles;
drop tablespace bigtbs including contents and datafiles;
2.控制文件
2.1 功能和特点:
1) 记录数据库当前物理状态
2) 维护数据库的一致性
3)是一个二进制小文件
4) 在 mount 阶段被读取
5) 记录 RMAN 备份的元数据
select name from v$datafile;
select member from v$logfile;
查看控制文件位置:
show parameter control_files;
select name from v$controlfile;
2.2 实时更新机制
①当增加、重命名、删除一个数据文件或者一个联机日志文件时, Oracle 服务器进程(Server
Process)会立即更新控制文件以反映数据库结构的变化。
②日志写进程 LGWR 负责把当前日志序列号记录到控制文件中。
③检查点进程 CKPT 负责把校验点的信息记录到控制文件中。
④归档进程 ARCN 负责把归档日志的信息记录到控制文件中。
通过视图 v$controlfile_record_section 可以了解到控制文件中记录了大量的数据库当前状态信息
2.3 控制文件多路复用
2.3.1 修改 spfile 中的 control_files 参数
[email protected]>create pfile from spfile;
[email protected]>select name from v$controlfile;
[email protected]>alter system set control_files='/u01/app/oracle/oradata/PROD1/control01.ctl',
'/u01/app/oracle/oradata/PROD1/control02.ctl','/u01/app/oracle/oradata/PROD1/control03.ctl' scope=spfile;
2.3.2 正常关库,启动到 nomount 状态查看
[email protected]>shutdown immediate;
[email protected]>startup nomount;
[email protected]>show parameter control_files
2.3.3 复制控制文件,建议分配在不同的物理磁盘上
[email protected]>! cp /u01/app/oracle/oradata/PROD1/control02.ctl /u01/app/oracle/oradata/PROD1/control03.ctl
[email protected]> alter database mount;
[email protected]> alter database open;
边栏推荐
- TypeScript学习总结
- Typescript learning summary
- QT: QSS custom qtoolbar and qtoolbox instances
- The element form shows the relationship between elementary transformation and elementary matrix
- Flink-- custom function
- Matlab memory variable management command
- Qt:qss custom qspinbox instance
- "Core values of testing" and "super complete learning guide for 0 basic software testing" summarized by test engineers for 8 years
- MAUI Developer Day in GCR
- UI自动化测试如何走出困境?价值又如何体现?
猜你喜欢
My understanding of testing (summarized by senior testers)
The highest monthly salary of 18K has a good "mentality and choice", and success is poor "seriousness and persistence"~
A simple method of adding dividing lines in recyclerview
10. Nacos source code construction
QT: QSS custom qtabwidget and qtabbar instances
Programming examples of stm32f1 and stm32subeide -tm1637 drives 4-bit 7-segment nixie tubes
我对测试工作的一些认识(资深测试人员总结)
多路IO转接——前导
How to realize automatic testing in embedded software testing?
T5 attempt
随机推荐
The five-year itch of software testing engineers tells the experience of breaking through bottlenecks for two years
2021 reading summary (continuously updating)
Differences among norm, normalize and normalized in eigen
今晚要修稿子準備發佈。但是,仍卡在這裡,也許你需要的是一個段子。
有些能力,是工作中学不来的,看看这篇超过90%同行
如何清理v$rman_backup_job_details视图 报错ORA-02030
Qt:qss custom QSlider instance
Programming examples of stm32f1 and stm32subeide -tm1637 drives 4-bit 7-segment nixie tubes
QT: QSS custom qsplitter instance
EPS电动转向系统分析
Is it OK to test the zero basis software?
Qt:qss custom qpprogressbar instance
(二)进制
硬 货 | 一改测试步骤代码就全写?为什么不试试用 Yaml实现数据驱动?
【Proteus仿真】74HC154 四线转12线译码器组成的16路流水灯
T5 attempt
那些一門心思研究自動化測試的人,後來怎樣了?
Qt:qss custom qmenu instance
Using activity to realize a simple inputable dialog box
我对测试工作的一些认识(资深测试人员总结)