Bad DBA :( https://baddba.com/ A collection of stuff that I have found useful as an Oracle DBA. Sun, 17 Dec 2023 02:57:13 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 Have your linux server email you when it gets rebooted https://baddba.com/2023/12/08/have-your-linux-server-email-you-when-it-gets-rebooted/ https://baddba.com/2023/12/08/have-your-linux-server-email-you-when-it-gets-rebooted/#respond Fri, 08 Dec 2023 20:05:26 +0000 https://baddba.com/?p=31 Did your linux server get accidentally or mysteriously rebooted? Did it come up after a crash? You probably want to know about it as soon as possible so you can check on your database to make sure it’s okay. If your linux server is configured to send mail, you can add a cron job to […]

The post Have your linux server email you when it gets rebooted appeared first on Bad DBA :(.

]]>
Did your linux server get accidentally or mysteriously rebooted? Did it come up after a crash?

You probably want to know about it as soon as possible so you can check on your database to make sure it’s okay.

If your linux server is configured to send mail, you can add a cron job to tell you when your server has been rebooted. Just add this entry to your crontab and substitute mail@example.com with your own email address:

@reboot /bin/sleep 120 && echo "*** $(hostname) has been rebooted $(date "+%h %d, %Y %H:%M %Z") ***" | /bin/mail -s "*** $(hostname) has been rebooted ***" mail@example.com

This cron job executes when the server comes back online. The cron entry above sleeps for 120 seconds before it sends an email to you. You can adjust the sleep time or remove it from the cron entry altogether:

@reboot echo "*** $(hostname) has been rebooted $(date "+%h %d, %Y %H:%M %Z") ***" | /bin/mail -s "Attention DBA team: $(hostname) has been rebooted" mail@example.com

@reboot is a non-standard crontab value that takes the place of the first 5 fields of the crontab entry (minute, hour, day of month, month, day of week).

The post Have your linux server email you when it gets rebooted appeared first on Bad DBA :(.

]]>
https://baddba.com/2023/12/08/have-your-linux-server-email-you-when-it-gets-rebooted/feed/ 0 31
Quick summary of ASM disk group sizes https://baddba.com/2023/11/02/quick-summary-of-asm-disk-group-sizes/ https://baddba.com/2023/11/02/quick-summary-of-asm-disk-group-sizes/#respond Thu, 02 Nov 2023 15:45:06 +0000 https://baddba.com/?p=26 A small query to give a snapshot of your ASM disk group sizes

The post Quick summary of ASM disk group sizes appeared first on Bad DBA :(.

]]>
A small query to give a snapshot of your ASM disk group sizes

set lines 200
select name,
       trunc(total_mb/1024,2) as total_gb,
       trunc(free_mb/1024,2) as free_gb,
       trunc((total_mb - free_mb)/1024,2) as used_gb,
       trunc((free_mb/total_mb) * 100,2) as free_percent
  from gv$asm_diskgroup
 order by name;

The post Quick summary of ASM disk group sizes appeared first on Bad DBA :(.

]]>
https://baddba.com/2023/11/02/quick-summary-of-asm-disk-group-sizes/feed/ 0 26
What’s in your recycle bin? https://baddba.com/2023/11/02/dba_recyclebin/ https://baddba.com/2023/11/02/dba_recyclebin/#respond Thu, 02 Nov 2023 00:40:40 +0000 https://baddba.com/?p=12 Are you an Oracle DBA who needs to free up disk space? Does your database have the recycle bin enabled? Did you know that the recycle bin just renames your segments when you drop them and doesn’t free up any space in your tablespace? Here’s a query you can run to see the segments that […]

The post What’s in your recycle bin? appeared first on Bad DBA :(.

]]>
Are you an Oracle DBA who needs to free up disk space? Does your database have the recycle bin enabled? Did you know that the recycle bin just renames your segments when you drop them and doesn’t free up any space in your tablespace?

Here’s a query you can run to see the segments that are in your recycle bin that are still taking up space in your tablespaces.

set pages 999
set lines 200
column owner format a20
column original_name format a30
select r.owner, 
       r.original_name, 
       r.type, 
       r.ts_name, 
       r.droptime, (t.block_size * r.space)/1024/1024 as megabytes
  from dba_recyclebin r, 
       dba_tablespaces t
 where t.tablespace_name = r.ts_name
 order by r.ts_name, 
          r.owner,
          r.original_name;

In this query, we are joining dba_recyclebin to dba_tablespaces to get the block size, since tablespaces may have custom block sizes and we’re not relying on the db_block_size initialization parameter.

Do you need all of these segments? Can they be purged to free up space? Make sure you talk to your users before you purge your recycle bin.

The post What’s in your recycle bin? appeared first on Bad DBA :(.

]]>
https://baddba.com/2023/11/02/dba_recyclebin/feed/ 0 12