From c5efed56cc4bbd7a90df118d8c9a6bed81e6c904 Mon Sep 17 00:00:00 2001 From: Song Gao Date: Tue, 31 Mar 2020 15:19:32 +0800 Subject: [PATCH] use tidb-lightning in restore instead of loader (#2068) * use tidb-lightning * Update restore.go * Update cmd/backup-manager/app/import/restore.go Co-Authored-By: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com> * Update images/tidb-backup-manager/Dockerfile Co-Authored-By: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com> Co-authored-by: DanielZhangQD <36026334+DanielZhangQD@users.noreply.github.com> Co-authored-by: pingcap-github-bot --- cmd/backup-manager/app/import/restore.go | 15 +++++++++------ images/tidb-backup-manager/Dockerfile | 11 +++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cmd/backup-manager/app/import/restore.go b/cmd/backup-manager/app/import/restore.go index dfcee888c4..22c00511f5 100644 --- a/cmd/backup-manager/app/import/restore.go +++ b/cmd/backup-manager/app/import/restore.go @@ -58,14 +58,17 @@ func (ro *Options) loadTidbClusterData(restorePath string) error { return fmt.Errorf("dir %s does not exist or is not a dir", restorePath) } args := []string{ - fmt.Sprintf("-d=%s", restorePath), - fmt.Sprintf("-h=%s", ro.Host), - fmt.Sprintf("-P=%d", ro.Port), - fmt.Sprintf("-u=%s", ro.User), - fmt.Sprintf("-p=%s", ro.Password), + "--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("/loader", args...).CombinedOutput() + 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) } diff --git a/images/tidb-backup-manager/Dockerfile b/images/tidb-backup-manager/Dockerfile index 17fdc3e216..f69b0e6573 100644 --- a/images/tidb-backup-manager/Dockerfile +++ b/images/tidb-backup-manager/Dockerfile @@ -1,6 +1,7 @@ FROM pingcap/tidb-enterprise-tools:latest ARG VERSION=v1.51.0 ARG SHUSH_VERSION=v1.4.0 +ARG TOOLKIT_VERSION=v3.0.12 RUN apk update && apk add ca-certificates RUN wget -nv https://github.com/ncw/rclone/releases/download/${VERSION}/rclone-${VERSION}-linux-amd64.zip \ @@ -19,7 +20,17 @@ RUN wget -nv https://github.com/realestate-com-au/shush/releases/download/${SHUS && mv shush_linux_amd64 /usr/local/bin/shush \ && chmod 755 /usr/local/bin/shush +RUN \ + wget -nv https://download.pingcap.org/tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \ + && tar -xzf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \ + && mv tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64/bin/tidb-lightning /tidb-lightning \ + && mv tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64/bin/tidb-lightning-ctl /tidb-lightning-ctl \ + && chmod 755 /tidb-lightning /tidb-lightning-ctl \ + && rm -rf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64.tar.gz \ + && rm -rf tidb-toolkit-${TOOLKIT_VERSION}-linux-amd64 + COPY bin/tidb-backup-manager /tidb-backup-manager COPY entrypoint.sh /entrypoint.sh + ENTRYPOINT ["/entrypoint.sh"]