ORACLE log management

Source: Internet
Author: User

The log file $ ORACLE_BASE/admin/orasid/bdump/alert_orasid.log of the ORACLE database records the duplicate
For log conversion, database startup and shutdown, database structure change, rollback segment modification, deadlock, internal error and other information
The database administrator needs to check whether this file has a ORA-error and regularly archive the log file.
In UNIX, you can use the grep command to save errors in alert_orasid.log to another file. Then go
Cause.
$ Grep ORA-alert_orasid.log> error. log
As we all know, the larger the file, the higher the overhead of opening and reading/writing. If the log file is too large (more than 5 MB), you must
It is not a good method to directly delete it and re-generate ORACLE. Because ORACLE uses a pointer to a file
When the database is running, this file is deleted. ORACLE still uses the original file pointer for write operations. It is possible to write
Use the following method: $ tail-100 $ ORACLE_BASE/admin/orasid/bdump/alert_orasid.log>/tmp/oracle_temp.log
$ Cp/tmp/oracle_temp.log $ ORACLE_BASE/admin/orasid/bdump/alert_orasid.log
$ Rm/tmp/oracle_temp.log
Truncate log files.
The listener log File $ ORACLE_HOME/network/log/listener. log records that are processed by listener.
Network request information, which includes the client request time, connection method (dedicated or shared), Connection Program, network protocol
We also need to periodically truncate it by stopping the log recording of listener first:
$ Lsnrctl set log_status off
Then process the file (Save the original log to the backup folder and leave the original listener. log empty)
$ Cp $ ORACLE_HOME/network/log/listener. log $ ORACLE_BACKUP/network
$ Cp/dev/$ ORACLE_HOME/network/log/listener. log
After the file operation is complete, open listener to log:
$ Lsnrctl set log_status on
If you write a simple shell program, you can solidify the above steps into a script, set a timetable, and let the operation
The following is a file named auto_listener.sh that saves listener. log by day.
Rq = 'date + "% d "'
Cp $ ORACLE_HOME/network/log/listener. log $ ORACLE_BACKUP/network/
Su-oracle-c "lsnrctl set log_status off"
Cp/dev/$ ORACLE_HOME/network/log/listener. log
Su-oracle-c "lsnrctl set log_status on"

You can define the environment variables ORACLE_HOME and ORACLE_BACKUP as needed or directly change them to the actual
Then, the root user of the operating system can run the shell script at to split the log files.

Author "justplayoop1"
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.