forked from TencentBlueKing/blueking-dbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(redis): tendisplus如果数据盘和备份盘是同一个盘,则通过硬链接方式备份 TencentBlueKing#6184
- Loading branch information
1 parent
bc37c40
commit 2831915
Showing
5 changed files
with
100 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
dbm-services/redis/db-tools/dbmon/pkg/monitormemoryusage/monitormemoryusage.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Package monitormemoryusage TODO | ||
package monitormemoryusage | ||
|
||
import ( | ||
"os" | ||
"runtime" | ||
"time" | ||
|
||
"dbm-services/mongodb/db-tools/dbactuator/mylog" | ||
"dbm-services/redis/db-tools/dbmon/config" | ||
"dbm-services/redis/db-tools/dbmon/pkg/consts" | ||
"dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup" | ||
"dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup" | ||
"dbm-services/redis/db-tools/dbmon/pkg/redismaxmemory" | ||
"dbm-services/redis/db-tools/dbmon/util" | ||
) | ||
|
||
// MonitorMemoryUsg 检测内存使用情况 | ||
func MonitorMemoryUsg() { | ||
var m runtime.MemStats | ||
var times int64 = 0 | ||
binlogBackupGlob := redisbinlogbackup.GetGlobRedisBinlogBackupJob(config.GlobalConf) | ||
fullBackupGlob := redisfullbackup.GetGlobRedisFullCheckJob(config.GlobalConf) | ||
checkFullBackGlob := redisfullbackup.GetGlobRedisFullCheckJob(config.GlobalConf) | ||
maxmemoryGlob := redismaxmemory.GetGlobRedisMaxmemorySet(config.GlobalConf) | ||
for { | ||
time.Sleep(5 * time.Second) | ||
times++ | ||
runtime.ReadMemStats(&m) | ||
// 分配内存超过500M就终止程序,等待crontab自动拉起 | ||
if m.Alloc >= 500*consts.MiByte { | ||
if binlogBackupGlob.IsRunning || fullBackupGlob.IsRunning || | ||
checkFullBackGlob.IsRunning || maxmemoryGlob.IsRunning { | ||
mylog.Logger.Error("dbmon memory usage %s exceed 500M, but binlogbackup or fullbackup or maxmemory is running", | ||
util.SizeToHumanStr(int64(m.Alloc))) | ||
continue | ||
} | ||
mylog.Logger.Error("dbmon memory usage %s exceed 500M,now exit", util.SizeToHumanStr(int64(m.Alloc))) | ||
os.Exit(1) | ||
} | ||
// 超过100MB,每隔2分钟秒打印一次内存使用情况 | ||
if m.Alloc >= 100*consts.MiByte && times%24 == 0 { | ||
mylog.Logger.Error("dbmon memory usage %s exceed 100M", util.SizeToHumanStr(int64(m.Alloc))) | ||
} | ||
} | ||
} |