Support log compression & max retention time (#294)

This commit is contained in:
dimstars
2021-08-25 19:17:34 +08:00
committed by wangzelin.wzl
parent 27b470466f
commit 61b6d05660
15 changed files with 646 additions and 14 deletions

View File

@ -74,6 +74,7 @@
#include "observer/ob_server_memory_cutter.h"
#include "share/ob_bg_thread_monitor.h"
#include "observer/omt/ob_tenant_timezone_mgr.h"
#include "lib/oblog/ob_log_compressor.h"
//#include "share/ob_ofs.h"
using namespace oceanbase::lib;
@ -172,10 +173,19 @@ int ObServer::init(const ObServerOptions& opts, const ObPLogWriterCfg& log_cfg)
// set large page param
ObLargePageHelper::set_param(config_.use_large_pages);
if (OB_SUCC(ret)) {
if (OB_FAIL(log_compressor_.init())) {
LOG_ERROR("log compressor init error.", K(ret));
}
}
if (OB_SUCC(ret)) {
if (OB_FAIL(OB_LOGGER.init(log_cfg))) {
LOG_ERROR("async log init error.", K(ret));
ret = OB_ELECTION_ASYNC_LOG_WARN_INIT;
} else if (OB_FAIL(OB_LOGGER.set_log_compressor(&log_compressor_))) {
LOG_ERROR("set log compressor error.", K(ret));
ret = OB_ELECTION_ASYNC_LOG_WARN_INIT;
}
}
@ -420,6 +430,8 @@ void ObServer::destroy()
LOG_WARN("memory dump destroyed");
tenant_timezone_mgr_.destroy();
LOG_WARN("tenant timezone manager destroyed");
log_compressor_.destroy();
LOG_WARN("log compressor destroyed");
LOG_WARN("destroy observer end");
has_destroy_ = true;
}
@ -951,10 +963,14 @@ int ObServer::init_pre_setting()
// oblog configuration
if (OB_SUCC(ret)) {
const int max_log_cnt = static_cast<int32_t>(config_.max_syslog_file_count);
const int64_t max_log_time = config_.max_syslog_file_time;
const bool enable_log_compress = config_.enable_syslog_file_compress;
const bool record_old_log_file = config_.enable_syslog_recycle;
const bool log_warn = config_.enable_syslog_wf;
const bool enable_async_syslog = config_.enable_async_syslog;
OB_LOGGER.set_max_file_index(max_log_cnt);
OB_LOGGER.set_max_file_time(max_log_time);
OB_LOGGER.set_enable_file_compress(enable_log_compress);
OB_LOGGER.set_record_old_log_file(record_old_log_file);
LOG_INFO("Whether record old log file", K(record_old_log_file));
OB_LOGGER.set_log_warn(log_warn);

View File

@ -46,6 +46,7 @@
#include "observer/ob_service.h"
#include "observer/ob_server_reload_config.h"
#include "observer/ob_root_service_monitor.h"
#include "lib/oblog/ob_log_compressor.h"
namespace oceanbase {
namespace omt {
@ -426,6 +427,7 @@ private:
blocksstable::ObStorageEnv storage_env_;
share::ObSchemaStatusProxy schema_status_proxy_;
ObSignalWorker sig_worker_;
common::ObLogCompressor log_compressor_;
bool is_log_dir_empty_;
sql::ObConnectResourceMgr conn_res_mgr_;

View File

@ -32,6 +32,10 @@ int ObReloadConfig::reload_ob_logger_set()
K(ret));
} else if (OB_FAIL(OB_LOGGER.set_max_file_index(static_cast<int32_t>(conf_->max_syslog_file_count)))) {
OB_LOG(ERROR, "fail to set_max_file_index", K(conf_->max_syslog_file_count.get()), K(ret));
} else if (OB_FAIL(OB_LOGGER.set_max_file_time(conf_->max_syslog_file_time))) {
OB_LOG(ERROR, "fail to set_max_file_time", K(conf_->max_syslog_file_time.get()), K(ret));
} else if (OB_FAIL(OB_LOGGER.set_enable_file_compress(conf_->enable_syslog_file_compress))) {
OB_LOG(ERROR, "fail to set_enable_file_compress", K(conf_->enable_syslog_file_compress.str()), K(ret));
} else if (OB_FAIL(OB_LOGGER.set_record_old_log_file(conf_->enable_syslog_recycle))) {
OB_LOG(ERROR, "fail to set_record_old_log_file", K(conf_->enable_syslog_recycle.str()), K(ret));
} else {

View File

@ -203,6 +203,15 @@ DEF_INT(cluster_id, OB_CLUSTER_PARAMETER, "0", "[1,4294901759]", "ID of the clus
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_STR(obconfig_url, OB_CLUSTER_PARAMETER, "", "URL for OBConfig service",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_BOOL(enable_syslog_file_compress, OB_CLUSTER_PARAMETER, "False",
"specifies whether to compress archive log files"
"Value: True:turned on; False: turned off",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_TIME(max_syslog_file_time, OB_CLUSTER_PARAMETER, "0s", "[0s, 3650d]",
"specifies the maximum retention time of the log files. "
"When this value is set to 0s, no log file will be removed due to time. "
"with default 0s. Range: [0s, 3650d]",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_LOG_LEVEL(syslog_level, OB_CLUSTER_PARAMETER, "INFO",
"specifies the current level of logging. There are DEBUG, TRACE, INFO, WARN, USER_ERR, ERROR, six different log "
"levels.",
@ -214,7 +223,7 @@ DEF_INT(max_syslog_file_count, OB_CLUSTER_PARAMETER, "0", "[0,]",
"specifies the maximum number of the log files "
"that can co-exist before the log file recycling kicks in. "
"Each log file can occupy at most 256MB disk space. "
"When this value is set to 0, no log file will be removed. Range: [0, +∞) in integer",
"When this value is set to 0, no log file will be removed due to the file count. Range: [0, +∞) in integer",
ObParameterAttr(Section::OBSERVER, Source::DEFAULT, EditLevel::DYNAMIC_EFFECTIVE));
DEF_BOOL(enable_async_syslog, OB_CLUSTER_PARAMETER, "True",
"specifies whether use async log for observer.log, elec.log and rs.log",