DEV Community

leo
leo

Posted on

openGauss routine maintenance: check and clear logs

Check and clean up logs
Logs are a key means to check system operation and locate faults. It is recommended to check the operating system logs and database operation logs on a monthly basis. At the same time, as time goes by, the increase of logs will take up more disk space. It is recommended to clear the running logs of the database on a monthly basis.

Check operating system logs
It is recommended to check the operating system logs on a monthly basis to eliminate the hidden dangers of abnormal operation of the operating system.

Run the following command to view the operating system log files.

vim /var/log/messages
Pay attention to the words kernel, error, fatal, etc. that have appeared in the past month, and deal with them according to the system alarm information.

Check the openGauss operation log
When the database is running, errors may occur during the execution of some operations, but the database can still run. But at this time, the data in the database may have been inconsistent. It is recommended to check the openGauss operation log on a monthly basis to detect hidden dangers in time.

prerequisite

The network of the host that collects the logs is smooth and not down, and the mutual trust between the database installation users is normal.
The log collection tool relies on operating system tools such as gstack. If the tool is not installed, an error will be displayed and the collection item will be skipped.
Steps

Log in to the active database node as the operating system user omm.

Run the following commands to collect database logs.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59"
20160616 01:01 is the start time of the log, and 20160616 23:59 is the end time of the log.

According to the interface output prompt in 2 , enter the corresponding log collection directory, decompress the collected logs, and check the database logs.

The following takes the log collection path "/opt/gaussdb/tmp/gaussdba_mppdb/collector_20160726_105158.tar.gz" as an example.

tar -xvzf /opt/gaussdb/tmp/gaussdba_mppdb/collector_20160726_105158.tar.gz
cd /opt/gaussdb/tmp/gaussdba_mppdb/collector_20160726_105158
example

Execute the gs_collector command with --begin-time and --end-time parameters.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59"
When information similar to the following is displayed, the log has been archived.

Successfully collected files
All results are stored in /tmp/gaussdba_mppdb/collector_20160616_175615.tar.gz.
Execute the gs_collector command with --begin-time, --end-time, and -h as parameters.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59" -h plat2
When information similar to the following is displayed, the log has been archived.

Successfully collected files
All results are stored in /tmp/gaussdba_mppdb/collector_20160616_190225.tar.gz.
Execute the gs_collector command with --begin-time, --end-time, and -f parameters.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59" -f /opt/software/gaussdb/output
When information similar to the following is displayed, the log has been archived.

Successfully collected files
All results are stored in /opt/software/gaussdb/output/collector_20160616_190511.tar.gz.
Execute the gs_collector command with --begin-time, --end-time, and --keyword as parameters.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59" --keyword="os"
When information similar to the following is displayed, the log has been archived.

Successfully collected files.
All results are stored in /tmp/gaussdba_mppdb/collector_20160616_190836.tar.gz.
Execute the gs_collector command with --begin-time, --end-time, and -o as parameters.

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59" -o /opt/software/gaussdb/output
When information similar to the following is displayed, the log has been archived.

Successfully collected files.
All results are stored in /opt/software/gaussdb/output/collector_20160726_113711.tar.gz.
Execute the gs_collector command with --begin-time, --end-time, and -l as parameters (the file name must be suffixed with .log).

gs_collector --begin-time="20160616 01:01" --end-time="20160616 23:59" -l /opt/software/gaussdb/logfile.log
When information similar to the following is displayed, the log has been archived.

Successfully collected files.
All results are stored in /opt/software/gaussdb/output/collector_20160726_113711.tar.gz.
Clean up the running log
During the operation of the database, a large number of operation logs will be generated, which will occupy a large amount of disk space. It is recommended to clean up expired log files and keep only one month's logs.

Steps

Log in to the active database node as the operating system user omm.

Clean up logs.

a. Back up logs older than one month to other disks.

b. Enter the log storage directory.

cd $GAUSSLOG
c. Enter the corresponding subdirectory, and use the following method to delete the logs generated one month ago.

rm 日志名称
The naming format of the log file is "postgresql-year-month-day_HHMMSS".

Latest comments (0)