Now all business systems are deployed with various types of monitoring for various aspects, so oracle is no exception. We also need to perform oracle monitoring, such as Instance Storage
Now all business systems are deployed with various types of monitoring for various aspects, so oracle is no exception. We also need to perform oracle monitoring, such as Instance Storage
Now all business systems are deployed with various types of monitoring for various aspects, so Oracle is no exception. We also need to monitor oracle, such as the instance survival status, the survival status of the listener and the running status of the system (including disk usage, number of processes, number of users logged on to the system, system load, and usage of various types of table spaces) there are many monitoring software based on system running conditions, such as nagios, which are not used or monitored here. However, to monitor the running status of an oracle instance, you must always observe the oracle alarm log. You can use the script to monitor the running status of an oracle instance, when a ORA error occurs in the alarm log, immediately extract the error information in the alarm log and send it to our DBA engineers by email or SMS. As for table space monitoring, it is not enough to rely solely on scripts to understand the table space usage, which must be queried using SQL statements, then we can monitor the oracle tablespace through scripts + SQL statements. The following describes how to monitor the oracle alarm log and tablespace.
How to monitor oracle alarm logs:
1. Create a profile file.
Vim/etc/oracle. profile
######################################## ###############################
# Oracle. profile ##
######################################## ###############################
EDITOR = vi; export EDITOR
ORACLE_BASE =/u01/app/oracle; export
ORACLE_HOME = $ ORACLE_BASE/product/11.2.0/db_1; export
LD_LIBRARY_PATH = $ ORACLE_HOME/lib:/lib64:/usr/lib64; export
LD_LIBRARY_PATH TNS_ADMIN = $ ORACLE_HOME/network/admin; export
TNS_ADMIN NLS_LANG = 'American _ China. ZHS16GBK '; export
NLS_LANG NLS_DATE_FORMAT = 'yyyy-MM-DD HH24: MI: ss'; export
NLS_DATE_FORMAT RATAB =/etc/oratab; export
# Oratab path = $ PATH: $ ORACLE_HOME/bin:/usr/ccs/bin:/usr/sbin :/
# Sbin:/usr/openwin/bin:/opt/bin:.; export
PATH = $ ORACLE_HOME/bin: $ PATH: $ HOME/bin
DBALIST = "xujinhua@uniits.com, xujinhua@cbc.cn"; export DBALIST
2. Write a script to check the oracle alter log (oracle user)
#! /Bin/ksh
Source/etc/oracle. profile
# For SID in 'cat $ ORACLE_HOME/sidlist'
For SID in 'orcl'
Do
Cd/u01/app/oracle/diag/rdbms/orcl/trace
If [-f alert _ $ {SID}. log]
Then
Mv alert _ $ {SID}. log alert_work.log
Touch alert _ $ {SID}. log
Cat alert_work.log> alert _ $ {SID}. hist
Grep ORA-alert_work.log> alert. err
Fi
If ['cat alert. err | wc-l'-gt 0]
Then
Mailx-s "mobile-testdb $ {SID} oracle alert errors" $ DBALIST <alert. err
Fi
Rm-f alert. err
Rm-f alert_work.log
Done
3. oracle users can use crontab to regularly run scripts for checking oracle alter logs.
How to monitor tablespaces:
Currently, the automatic scaling mode is used for table space. During Database Planning, the data file size is planned based on the amount of data that the business runs for a period of time, this determines the number of data files, the initial size of each data file, and the size of each extension. Therefore, it is meaningless to monitor the utilization of tablespaces, because the running data increases to the initial size after a period of time, and insufficient alarm tablespaces are triggered, but in fact it will automatically expand. But we can't say that we don't want to monitor the table space. We can regularly understand the usage of the table space and check the estimated size of the data file. This can also monitor the table space. [Linux community]
1) write the following script:
[Root @ woodpecker oracle] # cat tbs_monitor.sh
#! /Bin/sh
# This is a script. of monitor
# Login
Su-oracle-c "sqlplus/as sysdba" < < p><>
Start/home/oracle/tb_check/spool. SQL
Exit;
EOF
# Out
Export ORACLE_SID = orcl
Export TODAY = 'date' + % Y % m % d''
MONITOR = monitor $ TODAY. lst
# Mail for user
Mail-s "$ ORACLE_SID TABLESPACE $ MONITOR" xujinhua@uniits.com <$ MONITOR ---f xujinhua@uniits.com
2) write the following SQL:
[Root @ woodpecker oracle] # cat/home/oracle/tb_check/spool. SQL
Spool on;
Set echo off
Set feedback off;
Set termout off;
Set heading on;
Set term off
Column dat new_value date;
Select to_char (sysdate, 'yyyymmdd') dat from dual;
Spool monitor & date;
Set linesize 80;
Select d. tablespace_name, space sum_space,
Space-nvl (free_space, 0) used_space,
Round (1-nvl (free_space, 0)/space) *, 2) used_rate,
Free_space
From (select tablespace_name,
Round (sum (bytes)/(1024*1024), 2) space,
Sum (blocks) blocks
From dba_data_files
Group by tablespace_name) d,
(Select tablespace_name,
Round (sum (bytes)/(1024*1024), 2) free_space
From dba_free_space
Group by tablespace_name) f
Where d. tablespace_name = f. tablespace_name (+ );
Spool off;
Exit;
3) The system uses crontab to schedule a script every day to tell the dba about the usage of all tablespaces in the database every day.