diff --git a/dbm-services/redis/db-tools/dbactuator/Makefile b/dbm-services/redis/db-tools/dbactuator/Makefile index cc8041e156..568a1c226a 100644 --- a/dbm-services/redis/db-tools/dbactuator/Makefile +++ b/dbm-services/redis/db-tools/dbactuator/Makefile @@ -1,9 +1,16 @@ +SHELL := /bin/bash +BASE_DIR = $(shell pwd) SRV_NAME=dbactuator_redis +VERSION = 0.0.1 + +PACKAGE_PATH="dbm-services/redis/db-tools/dbactuator/cmd" + +BUILD_FLAG = " -X ${PACKAGE_PATH}.version=${VERSION} -X ${PACKAGE_PATH}.buildstamp=`date -u '+%Y-%m-%d_%I:%M:%S%z'` -X ${PACKAGE_PATH}.githash=`git rev-parse HEAD` " + +build: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -gcflags="all=-trimpath=${PWD}" -asmflags="all=-trimpath=${PWD}" -ldflags ${BUILD_FLAG} -o ${BASE_DIR}/build/$(SRV_NAME) -v main.go clean: -rm ./bin/${SRV_NAME} -build:clean - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/$(SRV_NAME) -v main.go - -.PHONY: init clean build +.PHONY: init clean build all diff --git a/dbm-services/redis/db-tools/dbactuator/cmd/root.go b/dbm-services/redis/db-tools/dbactuator/cmd/root.go index 198aeceec7..2e6f560765 100644 --- a/dbm-services/redis/db-tools/dbactuator/cmd/root.go +++ b/dbm-services/redis/db-tools/dbactuator/cmd/root.go @@ -6,15 +6,16 @@ Copyright © 2022 NAME HERE package cmd import ( - "dbm-services/redis/db-tools/dbactuator/pkg/consts" - "dbm-services/redis/db-tools/dbactuator/pkg/jobmanager" - "dbm-services/redis/db-tools/dbactuator/pkg/util" "encoding/base64" "fmt" "log" "os" "strings" + "dbm-services/redis/db-tools/dbactuator/pkg/consts" + "dbm-services/redis/db-tools/dbactuator/pkg/jobmanager" + "dbm-services/redis/db-tools/dbactuator/pkg/util" + "github.com/spf13/cobra" ) @@ -34,11 +35,23 @@ var multiProcessConcurrency int var showSupportedAtomJobs bool +var ( + buildstamp, githash, version, external string +) + // RootCmd represents the base command when called without any subcommands var RootCmd = &cobra.Command{ - Use: "dbactuator_redis", - Short: "redis原子任务合集", - Long: `redis原子任务合集,包含Redis 以及 RedisProxy 安装、集群创建、备份、回档等等原子任务`, + Use: "dbactuator_redis", + Short: fmt.Sprintf(`redis原子任务合集 +Version: %s +Githash: %s +External: %s +Buildstamp:%s`, version, githash, strings.ToUpper(external), buildstamp), + Long: fmt.Sprintf(`redis原子任务合集,包含Redis 以及 RedisProxy 安装、集群创建、备份、回档等等原子任务 +Version: %s +Githash: %s +External: %s +Buildstamp:%s`, version, githash, strings.ToUpper(external), buildstamp), // Uncomment the following line if your bare application // has an action associated with it: Run: func(cmd *cobra.Command, args []string) { diff --git a/dbm-services/redis/db-tools/dbactuator/tests/test.sh b/dbm-services/redis/db-tools/dbactuator/tests/test.sh index 437b87b5e3..c235844c5c 100644 --- a/dbm-services/redis/db-tools/dbactuator/tests/test.sh +++ b/dbm-services/redis/db-tools/dbactuator/tests/test.sh @@ -88,7 +88,7 @@ echo "DIR==$DIR" cd .. && make build -cp ./bin/dbactuator_redis /data/install/ +cp ./build/dbactuator_redis /data/install/ localTendisplusPkgName="/data/install/$tendisplusPkgName" localTendisplusPkgMd5="" diff --git a/dbm-services/redis/db-tools/dbmon/Makefile b/dbm-services/redis/db-tools/dbmon/Makefile index b4c971362d..54fda22058 100644 --- a/dbm-services/redis/db-tools/dbmon/Makefile +++ b/dbm-services/redis/db-tools/dbmon/Makefile @@ -1,24 +1,10 @@ SRV_NAME=bk-dbmon -clean: - -rm ./bin/${SRV_NAME} - -build:clean - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./bin/$(SRV_NAME) -v main.go - +build: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/$(SRV_NAME) -v main.go -LOCAL_PKG_DIR := $(shell eval "./bin/bk-dbmon -v|awk '{print $2}'") -version:=$(shell sh -c "./bin/bk-dbmon -v|awk '{print $1}'") - -package:build - mkdir -p bkdbmon - cp ./bin/$(SRV_NAME) ./bkdbmon/ - cp ./start.sh ./bkdbmon/ - cp ./stop.sh ./bkdbmon/ - cp ./dbmon-config.yaml ./bkdbmon/ +clean: + -rm ./build/${SRV_NAME} -version:build - @echo LOCAL_PKG_DIR=$(LOCAL_PKG_DIR) - @echo version=$(version) .PHONY: init clean build diff --git a/dbm-services/redis/db-tools/dbmon/package.sh b/dbm-services/redis/db-tools/dbmon/package.sh index 21a69965dd..1e8ad762a5 100644 --- a/dbm-services/redis/db-tools/dbmon/package.sh +++ b/dbm-services/redis/db-tools/dbmon/package.sh @@ -5,26 +5,25 @@ cd $DIR make build -version=$(./bin/bk-dbmon -v|awk '{print $2}') -version="v0.14" +cd build + +version=$(./bk-dbmon -v | awk '{print $2}') targetDir="bk-dbmon-$version" tarName="$targetDir.tar.gz" -if [[ ! -d $targetDir ]] -then +if [[ ! -d $targetDir ]]; then mkdir -p $targetDir fi -cp ./bin/bk-dbmon $targetDir/ -cp ./start.sh $targetDir/ -cp ./stop.sh $targetDir/ -cp ./dbmon-config.yaml $targetDir/ +cp ./bk-dbmon $targetDir/ +cp ../start.sh $targetDir/ +cp ../stop.sh $targetDir/ +cp ../dbmon-config.yaml $targetDir/ -if [[ -e $tarName ]] -then -rm -rf $tarName +if [[ -e $tarName ]]; then + rm -rf $tarName fi -tar -zcf $tarName $targetDir +tar --remove-files -zcf $tarName $targetDir -echo "$tarName success" \ No newline at end of file +echo "$tarName success" diff --git a/dbm-services/redis/db-tools/dbmon/pkg/consts/consts.go b/dbm-services/redis/db-tools/dbmon/pkg/consts/consts.go index 0360b55534..4d6c81238a 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/consts/consts.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/consts/consts.go @@ -138,6 +138,7 @@ const ( ForeverBackupType = "forever_backup" IBSBackupClient = "/usr/local/bin/backup_client" COSBackupClient = "/usr/local/backup_client/bin/backup_client" + COSInfoFile = "/home/mysql/.cosinfo.toml" RedisFullBackupTAG = "REDIS_FULL" RedisBinlogTAG = "REDIS_BINLOG" diff --git a/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/job.go b/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/job.go index ac070daefa..1521019927 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/job.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/job.go @@ -60,7 +60,8 @@ func (job *Job) Run() { defer job.Reporter.Close() // job.backupClient = backupsys.NewIBSBackupClient(consts.IBSBackupClient, consts.RedisBinlogTAG) - job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, "", consts.RedisBinlogTAG) + job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, + consts.COSInfoFile, consts.RedisBinlogTAG) if job.Err != nil { return } diff --git a/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/task.go b/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/task.go index 596621e1fb..323343901e 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/task.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/redisbinlogbackup/task.go @@ -83,7 +83,8 @@ func NewBinlogBackupTask(bkBizID string, bkCloudID int64, domain, ip string, por ShardValue: shardValue, } // ret.backupClient = backupsys.NewIBSBackupClient(consts.IBSBackupClient, consts.RedisBinlogTAG) - ret.backupClient, err = backupsys.NewCosBackupClient(consts.COSBackupClient, "", consts.RedisBinlogTAG) + ret.backupClient, err = backupsys.NewCosBackupClient(consts.COSBackupClient, + consts.COSInfoFile, consts.RedisBinlogTAG) return ret, err } diff --git a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/backupjob.go b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/backupjob.go index 6419189480..1ff858e14d 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/backupjob.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/backupjob.go @@ -62,7 +62,8 @@ func (job *Job) Run() { defer job.Reporter.Close() // job.backupClient = backupsys.NewIBSBackupClient(consts.IBSBackupClient, consts.RedisFullBackupTAG) - job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, "", consts.RedisFullBackupTAG) + job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, + consts.COSInfoFile, consts.RedisFullBackupTAG) if job.Err != nil { return } diff --git a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/checkjob.go b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/checkjob.go index d3ae8f2c2a..76da29c0c0 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/checkjob.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/checkjob.go @@ -53,7 +53,8 @@ func (job *CheckJob) Run() { defer job.Reporter.Close() // job.backupClient = backupsys.NewIBSBackupClient(consts.IBSBackupClient, consts.RedisFullBackupTAG) - job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, "", consts.RedisFullBackupTAG) + job.backupClient, job.Err = backupsys.NewCosBackupClient(consts.COSBackupClient, + consts.COSInfoFile, consts.RedisFullBackupTAG) if job.Err != nil { return } diff --git a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/task.go b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/task.go index 815b4b78e8..8c19f937af 100644 --- a/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/task.go +++ b/dbm-services/redis/db-tools/dbmon/pkg/redisfullbackup/task.go @@ -88,7 +88,8 @@ func NewFullBackupTask(bkBizID string, bkCloudID int64, domain, ip string, port reporter: reporter, } // ret.backupClient = backupsys.NewIBSBackupClient(consts.IBSBackupClient, consts.RedisFullBackupTAG) - ret.backupClient, err = backupsys.NewCosBackupClient(consts.COSBackupClient, "", consts.RedisFullBackupTAG) + ret.backupClient, err = backupsys.NewCosBackupClient(consts.COSBackupClient, + consts.COSInfoFile, consts.RedisFullBackupTAG) return } diff --git a/dbm-services/redis/redis-dts/Makefile b/dbm-services/redis/redis-dts/Makefile index 95cac954d2..7d817c492d 100644 --- a/dbm-services/redis/redis-dts/Makefile +++ b/dbm-services/redis/redis-dts/Makefile @@ -1,11 +1,9 @@ SRV_NAME= redis_dts_server -binDir=bin - -clean: - -rm ./${binDir}/${SRV_NAME} build:clean - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./${binDir}/$(SRV_NAME) -v main.go + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./build/$(SRV_NAME) -v main.go +clean: + -rm ./build/${SRV_NAME} .PHONY: init clean build gotool clean help api curl \ No newline at end of file diff --git a/dbm-services/redis/redis-dts/bin/config-template.yaml b/dbm-services/redis/redis-dts/build/config-template.yaml similarity index 100% rename from dbm-services/redis/redis-dts/bin/config-template.yaml rename to dbm-services/redis/redis-dts/build/config-template.yaml diff --git a/dbm-services/redis/redis-dts/bin/redis-shake-template.conf b/dbm-services/redis/redis-dts/build/redis-shake-template.conf similarity index 100% rename from dbm-services/redis/redis-dts/bin/redis-shake-template.conf rename to dbm-services/redis/redis-dts/build/redis-shake-template.conf diff --git a/dbm-services/redis/redis-dts/bin/start.sh b/dbm-services/redis/redis-dts/build/start.sh similarity index 100% rename from dbm-services/redis/redis-dts/bin/start.sh rename to dbm-services/redis/redis-dts/build/start.sh diff --git a/dbm-services/redis/redis-dts/bin/stop.sh b/dbm-services/redis/redis-dts/build/stop.sh similarity index 100% rename from dbm-services/redis/redis-dts/bin/stop.sh rename to dbm-services/redis/redis-dts/build/stop.sh diff --git a/dbm-services/redis/redis-dts/bin/tendisplus-sync-template.conf b/dbm-services/redis/redis-dts/build/tendisplus-sync-template.conf similarity index 100% rename from dbm-services/redis/redis-dts/bin/tendisplus-sync-template.conf rename to dbm-services/redis/redis-dts/build/tendisplus-sync-template.conf diff --git a/dbm-services/redis/redis-dts/bin/tendisssd-sync-template.conf b/dbm-services/redis/redis-dts/build/tendisssd-sync-template.conf similarity index 96% rename from dbm-services/redis/redis-dts/bin/tendisssd-sync-template.conf rename to dbm-services/redis/redis-dts/build/tendisssd-sync-template.conf index f93a9034d8..0e4c488d40 100755 --- a/dbm-services/redis/redis-dts/bin/tendisssd-sync-template.conf +++ b/dbm-services/redis/redis-dts/build/tendisssd-sync-template.conf @@ -34,4 +34,4 @@ key-black-regex={{KEY_BLACK_REGEX}} {{DST_ADDR}}|{{DST_PASSWORD}} {{DST_ADDR}}|{{DST_PASSWORD}} {{DST_ADDR}}|{{DST_PASSWORD}} -{{DST_ADDR}}|{{DST_PASSWORD}} \ No newline at end of file +{{DST_ADDR}}|{{DST_PASSWORD}}