监控 Oracle XE 中的表空间使用情况

发布于 2024-10-27 16:07:03 字数 889 浏览 7 评论 0原文

正如 Oracle XE 概述页面上所述:

Oracle Database XE 可以安装在具有任意数量 CPU 的任何规模主机上(每台计算机一个数据库),但 XE 将存储最多 4GB 的用户数据,最多使用 1GB 内存,并在主机上使用一个CPU。

现在,如果我想监视数据库以查看正在使用多少用户数据或数据库使用了多少内存,我该怎么做?可以从 Oracle Application Express 监控这些值,但我想从集中监控系统监控数据库。 Oracle XE 文档返回闪存恢复区域使用情况的查询,因此我猜测用户数据使用情况也有类似的查询。

SELECT
NAME,
TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,'999,999,999,999')
   AS SPACE_AVAILABLE,
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
   AS PERCENT_FULL
FROM V$RECOVERY_FILE_DEST;

另外,当用户数据超过限制时会发生什么?

As it says on the Oracle XE overview page:

Oracle Database XE can be installed on any size host machine with any number of CPUs (one database per machine), but XE will store up to 4GB of user data, use up to 1GB of memory, and use one CPU on the host machine.

Now if I want to monitor the database to see how much user data is in use or how much memory is the database using, how would I do that? It is possible to monitor these values from Oracle Application Express, but I want to monitor the database from a centralized monitoring system. Oracle XE documentation presents a query which returns Flash Recovery Area usage, so I'm guessing there's a similar query for user data usage also.

SELECT
NAME,
TO_CHAR(SPACE_LIMIT, '999,999,999,999') AS SPACE_LIMIT,
TO_CHAR(SPACE_LIMIT - SPACE_USED + SPACE_RECLAIMABLE,'999,999,999,999')
   AS SPACE_AVAILABLE,
ROUND((SPACE_USED - SPACE_RECLAIMABLE)/SPACE_LIMIT * 100, 1)
   AS PERCENT_FULL
FROM V$RECOVERY_FILE_DEST;

Also, what happens when user data is above the limit?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

や莫失莫忘 2024-11-03 16:07:03

无耻地取自 Oracle FAQ 网站,这里有一个查询,通过以下方式检查已用空间表空间:

SELECT /* + RULE */  df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Size (MB)",
       SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
       Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
       Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
  FROM dba_free_space fs,
       (SELECT tablespace_name,SUM(bytes) bytes
          FROM dba_data_files
         GROUP BY tablespace_name) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
       fs.bytes / (1024 * 1024),
       SUM(df.bytes_free) / (1024 * 1024),
       Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
       Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
  FROM dba_temp_files fs,
       (SELECT tablespace_name,bytes_free,bytes_used
          FROM v$temp_space_header
         GROUP BY tablespace_name,bytes_free,bytes_used) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
 ORDER BY 4 DESC;

默认情况下,用户数据是USERS 表空间中使用的空间。

至于当你达到极限时会发生什么,我只能猜测:

  • 当尝试插入数据时,你会得到一些空间不足错误(一些Oracle错误消息似乎总是来自无论如何,空间不足;-)
  • 你可能会面临一生中最大的支票......

Shamelessly taken from the Oracle FAQ website, here is a query that checks used space by tablespace:

SELECT /* + RULE */  df.tablespace_name "Tablespace",
       df.bytes / (1024 * 1024) "Size (MB)",
       SUM(fs.bytes) / (1024 * 1024) "Free (MB)",
       Nvl(Round(SUM(fs.bytes) * 100 / df.bytes),1) "% Free",
       Round((df.bytes - SUM(fs.bytes)) * 100 / df.bytes) "% Used"
  FROM dba_free_space fs,
       (SELECT tablespace_name,SUM(bytes) bytes
          FROM dba_data_files
         GROUP BY tablespace_name) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,df.bytes
UNION ALL
SELECT /* + RULE */ df.tablespace_name tspace,
       fs.bytes / (1024 * 1024),
       SUM(df.bytes_free) / (1024 * 1024),
       Nvl(Round((SUM(fs.bytes) - df.bytes_used) * 100 / fs.bytes), 1),
       Round((SUM(fs.bytes) - df.bytes_free) * 100 / fs.bytes)
  FROM dba_temp_files fs,
       (SELECT tablespace_name,bytes_free,bytes_used
          FROM v$temp_space_header
         GROUP BY tablespace_name,bytes_free,bytes_used) df
 WHERE fs.tablespace_name (+)  = df.tablespace_name
 GROUP BY df.tablespace_name,fs.bytes,df.bytes_free,df.bytes_used
 ORDER BY 4 DESC;

By default, user data is the space used in the USERS tablespace.

As for what happens when you are at the limit, I can only guess that:

  • You will get some out of space error when trying to insert data (some Oracle error message always seem to come from out of space anyway ;-)
  • You may be in for the biggest check in your life...
情域 2024-11-03 16:07:03

一个密切相关的问题:用户的表空间使用情况(找出空间的去向):

select owner,tablespace_name,
sum(bytes)/1024/1024 as mbytes
from dba_segments
group by owner,tablespace_name
order by mbytes desc;

A closely-related matter: tablespace usage by user (to find out where the space is going):

select owner,tablespace_name,
sum(bytes)/1024/1024 as mbytes
from dba_segments
group by owner,tablespace_name
order by mbytes desc;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文