From 458dd3285c4c46735b527e1fab0fde184dde85df Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Tue, 21 Apr 2020 21:05:56 +0800 Subject: [PATCH 01/10] fix the config error in restore --- cmd/backup-manager/app/import/restore.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index 22c00511f5..63db0b3299 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -58,14 +58,14 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { return fmt.Errorf("dir %s does not exist or is not a dir", restorePath) } args := []string{ - "--status-addr=0.0.0.0:8289", - "--backend=tidb", - "--server-mode=false", - "–-log-file=", - fmt.Sprintf("--tidb-user=%s", ro.User), - fmt.Sprintf("--tidb-password=%s", ro.Password), - fmt.Sprintf("--tidb-host=%s", ro.Host), - fmt.Sprintf("--d=%s", restorePath), + "-status-addr=0.0.0.0:8289", + "-backend=tidb", + "-server-mode=false", + "-log-file=", + fmt.Sprintf("-tidb-user=%s", ro.User), + fmt.Sprintf("-tidb-password=%s", ro.Password), + fmt.Sprintf("-tidb-host=%s", ro.Host), + fmt.Sprintf("-d=%s", restorePath), } output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() From c7256d48375a23c5e24ad8865ef172928d735c50 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Tue, 21 Apr 2020 23:17:48 +0800 Subject: [PATCH 02/10] Update restore.go --- cmd/backup-manager/app/import/restore.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index 63db0b3299..6a7ea5cf5c 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -22,6 +22,7 @@ import ( "github.com/mholt/archiver" "github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants" "github.com/pingcap/tidb-operator/cmd/backup-manager/app/util" + "k8s.io/klog" ) // Options contains the input arguments to the restore command @@ -62,12 +63,14 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { "-backend=tidb", "-server-mode=false", "-log-file=", + "-tidb-port=4000", fmt.Sprintf("-tidb-user=%s", ro.User), fmt.Sprintf("-tidb-password=%s", ro.Password), fmt.Sprintf("-tidb-host=%s", ro.Host), fmt.Sprintf("-d=%s", restorePath), } + klog.Infof("/tidb-lightning %v", args) output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() if err != nil { return fmt.Errorf("cluster %s, execute loader command %v failed, output: %s, err: %v", ro, args, string(output), err) From 5aaa93e1dad36643544022a18b485f6e90615554 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 10:20:43 +0800 Subject: [PATCH 03/10] remove log --- cmd/backup-manager/app/import/restore.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index 6a7ea5cf5c..dd49a94d80 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -69,8 +69,7 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { fmt.Sprintf("-tidb-host=%s", ro.Host), fmt.Sprintf("-d=%s", restorePath), } - - klog.Infof("/tidb-lightning %v", args) + output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() if err != nil { return fmt.Errorf("cluster %s, execute loader command %v failed, output: %s, err: %v", ro, args, string(output), err) From 5d60fbd21d39192ba8348364a5e1ec48697b1cde Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 10:22:46 +0800 Subject: [PATCH 04/10] go fmt --- cmd/backup-manager/app/import/restore.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index dd49a94d80..60ca270383 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -22,7 +22,6 @@ import ( "github.com/mholt/archiver" "github.com/pingcap/tidb-operator/cmd/backup-manager/app/constants" "github.com/pingcap/tidb-operator/cmd/backup-manager/app/util" - "k8s.io/klog" ) // Options contains the input arguments to the restore command @@ -69,7 +68,7 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { fmt.Sprintf("-tidb-host=%s", ro.Host), fmt.Sprintf("-d=%s", restorePath), } - + output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() if err != nil { return fmt.Errorf("cluster %s, execute loader command %v failed, output: %s, err: %v", ro, args, string(output), err) From ee6fe811d105b8ca856214c7e3d563d4b3778af4 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 10:54:10 +0800 Subject: [PATCH 05/10] revert change --- cmd/backup-manager/app/import/restore.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index 60ca270383..b7de8eaf13 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -58,15 +58,15 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { return fmt.Errorf("dir %s does not exist or is not a dir", restorePath) } args := []string{ - "-status-addr=0.0.0.0:8289", - "-backend=tidb", - "-server-mode=false", - "-log-file=", - "-tidb-port=4000", - fmt.Sprintf("-tidb-user=%s", ro.User), - fmt.Sprintf("-tidb-password=%s", ro.Password), - fmt.Sprintf("-tidb-host=%s", ro.Host), - fmt.Sprintf("-d=%s", restorePath), + "--status-addr=0.0.0.0:8289", + "--backend=tidb", + "--server-mode=false", + "--log-file=", + "--tidb-port=4000", + fmt.Sprintf("--tidb-user=%s", ro.User), + fmt.Sprintf("--tidb-password=%s", ro.Password), + fmt.Sprintf("--tidb-host=%s", ro.Host), + fmt.Sprintf("--d=%s", restorePath), } output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() From ffec3c736a964285b4d882498fb49a0797cab1bd Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 11:28:16 +0800 Subject: [PATCH 06/10] address the comment --- cmd/backup-manager/app/import/restore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index b7de8eaf13..c0b034862f 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -62,7 +62,7 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { "--backend=tidb", "--server-mode=false", "--log-file=", - "--tidb-port=4000", + fmt.Sprintf("--tidb-port=%d", ro.Port), fmt.Sprintf("--tidb-user=%s", ro.User), fmt.Sprintf("--tidb-password=%s", ro.Password), fmt.Sprintf("--tidb-host=%s", ro.Host), From db480bee36a4a92cb21f9c2a27047d710c2cf84d Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 17:30:07 +0800 Subject: [PATCH 07/10] Update restore.go --- cmd/backup-manager/app/import/restore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index c0b034862f..ffd6be451d 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -62,11 +62,11 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { "--backend=tidb", "--server-mode=false", "--log-file=", - fmt.Sprintf("--tidb-port=%d", ro.Port), fmt.Sprintf("--tidb-user=%s", ro.User), fmt.Sprintf("--tidb-password=%s", ro.Password), fmt.Sprintf("--tidb-host=%s", ro.Host), fmt.Sprintf("--d=%s", restorePath), + fmt.Sprintf("--tidb-port=%d", ro.Port), } output, err := exec.Command("/tidb-lightning", args...).CombinedOutput() From 5553d59c4aad16fb23ace1cf7d23fca2d8ab4fc9 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 17:36:02 +0800 Subject: [PATCH 08/10] add note --- cmd/backup-manager/app/import/restore.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index ffd6be451d..fc28da5ed3 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -57,6 +57,7 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { if exist := util.IsDirExist(restorePath); !exist { return fmt.Errorf("dir %s does not exist or is not a dir", restorePath) } + // args for restore args := []string{ "--status-addr=0.0.0.0:8289", "--backend=tidb", From de8af8f9898356f562d6516a0a408ec0fb174aeb Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 17:36:35 +0800 Subject: [PATCH 09/10] Update restore.go --- cmd/backup-manager/app/import/restore.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index fc28da5ed3..8b1af7231a 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -62,7 +62,6 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { "--status-addr=0.0.0.0:8289", "--backend=tidb", "--server-mode=false", - "--log-file=", fmt.Sprintf("--tidb-user=%s", ro.User), fmt.Sprintf("--tidb-password=%s", ro.Password), fmt.Sprintf("--tidb-host=%s", ro.Host), From ed127862d921aa4a137c246c7da157d49fe42357 Mon Sep 17 00:00:00 2001 From: Song Gao <2695690803@qq.com> Date: Wed, 22 Apr 2020 17:37:15 +0800 Subject: [PATCH 10/10] add logfile --- cmd/backup-manager/app/import/restore.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index 8b1af7231a..fc28da5ed3 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -62,6 +62,7 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { "--status-addr=0.0.0.0:8289", "--backend=tidb", "--server-mode=false", + "--log-file=", fmt.Sprintf("--tidb-user=%s", ro.User), fmt.Sprintf("--tidb-password=%s", ro.Password), fmt.Sprintf("--tidb-host=%s", ro.Host),