Skip to content

Commit

Permalink
feat(redis): redis打包方式优化 #1439
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemakeit committed Oct 27, 2023
1 parent e5ed500 commit 2c51ae5
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 53 deletions.
15 changes: 11 additions & 4 deletions dbm-services/redis/db-tools/dbactuator/Makefile
Original file line number Diff line number Diff line change
@@ -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
25 changes: 19 additions & 6 deletions dbm-services/redis/db-tools/dbactuator/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ Copyright © 2022 NAME HERE <EMAIL ADDRESS>
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"
)

Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dbm-services/redis/db-tools/dbactuator/tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
22 changes: 4 additions & 18 deletions dbm-services/redis/db-tools/dbmon/Makefile
Original file line number Diff line number Diff line change
@@ -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
25 changes: 12 additions & 13 deletions dbm-services/redis/db-tools/dbmon/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
echo "$tarName success"
1 change: 1 addition & 0 deletions dbm-services/redis/db-tools/dbmon/pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 3 additions & 5 deletions dbm-services/redis/redis-dts/Makefile
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
{{DST_ADDR}}|{{DST_PASSWORD}}

0 comments on commit 2c51ae5

Please sign in to comment.