Migration von Cloud Object Storage (COS) Anwendungen und Daten zwischen IBM Cloud Konten
Klassische Infrastruktur Virtuelle Private Cloud
In diesem Tutorial migrieren Sie eine COS-Anwendung und Daten von einem IBM Cloud Kubernetes Service-Cluster in einem Konto zu einem Red Hat OpenShift on IBM Cloud-Cluster in einem anderen Konto.
Voraussetzungen
Konto 1
In Konto 1 müssen Sie Folgendes haben.
-
Ein IBM Cloud Kubernetes Service-Cluster.
-
Eine COS-Instanz und eine Reihe von HMAC-Zugangsdaten. Weitere Informationen finden Sie unter Dienstanmeldeinformationen.
Konto 2
In Konto 2, dem Zielkonto, auf das migriert werden soll, müssen Sie Folgendes haben.
-
Ein Red Hat OpenShift on IBM Cloud Cluster.
-
Eine COS-Instanz und eine Reihe von HMAC-Zugangsdaten. Weitere Informationen finden Sie unter Dienstanmeldeinformationen.
-
Ein leerer Bucket in Ihrer COS-Instanz.
Optional: Bereitstellen einer App in Ihrem Cluster
Konto 1
Wenn Sie noch keine Anwendung haben, die Sie migrieren möchten, können Sie die folgende Beispielanwendung einsetzen.
-
Erstellen Sie eine PVC, die auf Ihre Objektspeicherkonfiguration verweist.
kind: PersistentVolumeClaim apiVersion: v1 metadata: name: demo #Enter a name for your PVC. namespace: default annotations: ibm.io/auto-create-bucket: "true" ibm.io/auto-delete-bucket: "false" ibm.io/secret-name: SECRET-NAME #Enter the name of the secret you created earlier. ibm.io/secret-namespace: NAMESPACE #Enter the namespace where you want to create the PVC. spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: ibmc-s3fs-cos #The storage class that you want to use. -
Erstellen Sie die PVC in Ihrem Cluster.
oc apply -f pvc-cos.yaml -
Erstellen Sie eine YAML-Konfigurationsdatei für einen Pod, der das von Ihnen erstellte PVC mountet.
apiVersion: v1 kind: Pod metadata: name: demo-pod namespace: default spec: securityContext: runAsUser: 2000 fsGroup: 2000 volumes: - name: demo-vol persistentVolumeClaim: claimName: demo containers: - name: test image: nginxinc/nginx-unprivileged imagePullPolicy: Always volumeMounts: - name: demo-vol mountPath: /mnt/cosvol -
Erstellen Sie den Pod in Ihrem Cluster.
oc apply -f demo-pod.yaml -
Überprüfen Sie, ob der Pod bereitgestellt wurde. Beachten Sie, dass es einige Minuten dauern kann, bis Ihre App in den Status 'Aktiv' (
Running) wechselt.oc get podsNAME READY STATUS RESTARTS AGE demo-pod 1/1 Running 0 2m58s -
Überprüfen Sie, ob die App auf Ihren Blockspeicherdatenträger schreiben kann, indem Sie sich bei Ihrem Pod anmelden.
oc exec demo-pod -- bash -c "ls /mnt/cosvol"
Erhalten Sie die Details Ihrer App
Konto 1
- Liste der Hülsen und PVCs.
oc get pods - Beschreiben Sie Ihr PVC, prüfen Sie die Details und notieren Sie sich den Namen des Eimers.
oc describe PVC -o yaml
Installation rclone
Folgen Sie der rclone Dokumentation für Installationsschritte.
Konfigurieren Sie ' rclone für Ihren Bucket in Konto 1
Konto 1
Nachdem Sie rclone installiert haben, müssen Sie eine Konfigurationsdatei erstellen, die die COS-Instanz definiert, von der Sie Daten migrieren möchten.
-
Führen Sie den Befehl
rclone configaus.rclone configBeispielausgabe
2020/01/16 09:39:33 NOTICE: Config file "/Users/ryan/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config -
Eingeben
num eine neue Fernbedienung einzurichten, und geben Sie Ihrer Fernbedienung dann einen Namen.n/s/q> nBeispiel für einen Remote-Namen
name> cos-instance-1 -
Wählen Sie aus der Liste der Anbieter
Amazon S3 Compliant Storage Providerwelches beinhaltetIBM COS.Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" ... provider> 4 -
Wählen Sie
IBM COSals Ihren s3 Anbieter.Choose your S3 provider. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Amazon Web Services (AWS) S3 \ "AWS" 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun \ "Alibaba" 3 / Ceph Object Storage \ "Ceph" 4 / Digital Ocean Spaces \ "DigitalOcean" 5 / Dreamhost DreamObjects \ "Dreamhost" 6 / IBM COS S3 \ "IBMCOS" 7 / Minio Object Storage \ "Minio" 8 / Netease Object Storage (NOS) \ "Netease" 9 / Wasabi Object Storage \ "Wasabi" 10 / Any other S3 compatible provider \ "Other" -
Fügen Sie Ihre COS-Anmeldeinformationen hinzu, indem Sie die Option auswählen
1.Option env_auth. Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars). Only applies if access_key_id and secret_access_key is blank. Choose a number from below, or type in your own boolean value (true or false). Press Enter for the default (false). 1 / Enter AWS credentials in the next step. \ (false) 2 / Get AWS credentials from the environment (env vars or IAM). \ (true) env_auth> 1 -
Geben Sie bei entsprechender Aufforderung die
access_key_idUndsecret_access_keyIhrer COS-Instanz. Weitere Informationen finden Sie unter Dienstanmeldeinformationen.AWS Access Key ID. Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). access_key_id> xxxxxxxxxxxxxxxxxxxxx AWS Secret Access Key (password) Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). secret_access_key> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
Im
Region to connect toEingabeaufforderung, Option auswählen1.Region to connect to. Leave blank if you are using an S3 clone and you don't have a region. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Use this if unsure. Will use v4 signatures and an empty region. \ "" 2 / Use this only if v4 signatures don't work, eg pre Jewel/v10 CEPH. \ "other-v2-signature" region> 1 -
Im
Endpoint for IBM COS S3 APIEingabeaufforderung, Option auswählen1.Endpoint for IBM COS S3 API. Specify if using an IBM COS On Premise. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Endpoint \ "s3-api.us-geo.objectstorage.softlayer.net" 2 / US Cross Region Dallas Endpoint \ "s3-api.dal.us-geo.objectstorage.softlayer.net" 3 / US Cross Region Washington DC Endpoint \ "s3-api.wdc-us-geo.objectstorage.softlayer.net" ... endpoint> 1 -
Im
Location constraintdrücken Sie Zurückkehren um die Standardeinstellung zu verwenden.Location constraint - must match endpoint when using IBM Cloud Public. For on-prem COS, do not make a selection from this list, hit enter Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Standard \ "us-standard" 2 / US Cross Region Vault \ "us-vault" 3 / US Cross Region Cold \ "us-cold" 4 / US Cross Region Flex \ "us-flex" ... -
Wählen Sie in der ACL-Richtlinienaufforderung
private.Note that this ACL is applied when server side copying objects as S3 doesn't copy the ACL from the source but rather writes a fresh one. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Owner gets FULL_CONTROL. No one else has access rights (default). This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise COS \ "private" 2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access. This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise IBM COS \ "public-read" 3 / Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access. This acl is available on IBM Cloud (Infra), On-Premise IBM COS \ "public-read-write" 4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access. Not supported on Buckets. This acl is available on IBM Cloud (Infra) and On-Premise IBM COS \ "authenticated-read" acl> 1 -
Überspringen Sie die erweiterte Konfigurationsoption und bestätigen Sie Ihre Einrichtung.
Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config -------------------- [cos-instance-1] type = s3 provider = IBMCOS env_auth = false access_key_id = xxxxxx secret_access_key = xxxxxxxxx endpoint = s3-api.us-geo.objectstorage.softlayer.net location_constraint = us-standard acl = private -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== cos-instance-1 s3 -
Wiederholen Sie die vorherigen Schritte, um die COS-Instanz in Ihrem zweiten Konto hinzuzufügen. Wenn Sie die Informationen überprüft haben, drücken Sie
q, um den Konfigurationsprozess zu beenden.
Konfigurieren Sie ' rclone für Ihren Bucket in Konto 2
Konto 2
Wiederholen Sie die Schritte, um rclone für Konto 2 zu konfigurieren.
-
Führen Sie den Befehl
rclone configaus.rclone configBeispielausgabe
2020/01/16 09:39:33 NOTICE: Config file "/Users/ryan/.config/rclone/rclone.conf" not found - using defaults No remotes found - make a new one n) New remote s) Set configuration password q) Quit config -
Eingeben
num eine neue Fernbedienung einzurichten, und geben Sie Ihrer Fernbedienung dann einen Namen.n/s/q> nBeispiel für einen Remote-Namen
name> cos-instance-2 -
Wählen Sie aus der Liste der Anbieter
Amazon S3 Compliant Storage Providerwelches beinhaltetIBM COS.Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / 1Fichier \ "fichier" 2 / Alias for an existing remote \ "alias" 3 / Amazon Drive \ "amazon cloud drive" 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc) \ "s3" 5 / Backblaze B2 \ "b2" ... provider> 4 -
Wählen Sie
IBM COSals Ihren s3 Anbieter.Choose your S3 provider. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Amazon Web Services (AWS) S3 \ "AWS" 2 / Alibaba Cloud Object Storage System (OSS) formerly Aliyun \ "Alibaba" 3 / Ceph Object Storage \ "Ceph" 4 / Digital Ocean Spaces \ "DigitalOcean" 5 / Dreamhost DreamObjects \ "Dreamhost" 6 / IBM COS S3 \ "IBMCOS" 7 / Minio Object Storage \ "Minio" 8 / Netease Object Storage (NOS) \ "Netease" 9 / Wasabi Object Storage \ "Wasabi" 10 / Any other S3 compatible provider \ "Other" -
Fügen Sie Ihre COS-Anmeldeinformationen hinzu, indem Sie die Option auswählen
1.Option env_auth. Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars). Only applies if access_key_id and secret_access_key is blank. Choose a number from below, or type in your own boolean value (true or false). Press Enter for the default (false). 1 / Enter AWS credentials in the next step. \ (false) 2 / Get AWS credentials from the environment (env vars or IAM). \ (true) env_auth> 1 -
Geben Sie bei entsprechender Aufforderung die
access_key_idUndsecret_access_keyIhrer COS-Instanz. Weitere Informationen finden Sie unter Dienstanmeldeinformationen.AWS Access Key ID. Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). access_key_id> xxxxxxxxxxxxxxxxxxxxx AWS Secret Access Key (password) Leave blank for anonymous access or runtime credentials. Enter a string value. Press Enter for the default (""). secret_access_key> xxxxxxxxxxxxxxxxxxxxxxxxxxxxx -
Im
Region to connect toEingabeaufforderung, Option auswählen1.Region to connect to. Leave blank if you are using an S3 clone and you don't have a region. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Use this if unsure. Will use v4 signatures and an empty region. \ "" 2 / Use this only if v4 signatures don't work, eg pre Jewel/v10 CEPH. \ "other-v2-signature" region> 1 -
Im
Endpoint for IBM COS S3 APIEingabeaufforderung, Option auswählen1.Endpoint for IBM COS S3 API. Specify if using an IBM COS On Premise. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Endpoint \ "s3-api.us-geo.objectstorage.softlayer.net" 2 / US Cross Region Dallas Endpoint \ "s3-api.dal.us-geo.objectstorage.softlayer.net" 3 / US Cross Region Washington DC Endpoint \ "s3-api.wdc-us-geo.objectstorage.softlayer.net" ... endpoint> 1 -
Im
Location constraintdrücken Sie Zurückkehren um die Standardeinstellung zu verwenden.Location constraint - must match endpoint when using IBM Cloud Public. For on-prem COS, do not make a selection from this list, hit enter Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / US Cross Region Standard \ "us-standard" 2 / US Cross Region Vault \ "us-vault" 3 / US Cross Region Cold \ "us-cold" 4 / US Cross Region Flex \ "us-flex" ... -
Wählen Sie in der ACL-Richtlinienaufforderung
private.Note that this ACL is applied when server side copying objects as S3 doesn't copy the ACL from the source but rather writes a fresh one. Enter a string value. Press Enter for the default (""). Choose a number from below, or type in your own value 1 / Owner gets FULL_CONTROL. No one else has access rights (default). This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise COS \ "private" 2 / Owner gets FULL_CONTROL. The AllUsers group gets READ access. This acl is available on IBM Cloud (Infra), IBM Cloud (Storage), On-Premise IBM COS \ "public-read" 3 / Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access. This acl is available on IBM Cloud (Infra), On-Premise IBM COS \ "public-read-write" 4 / Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access. Not supported on Buckets. This acl is available on IBM Cloud (Infra) and On-Premise IBM COS \ "authenticated-read" acl> 1 -
Überspringen Sie die erweiterte Konfigurationsoption und bestätigen Sie Ihre Einrichtung.
Edit advanced config? (y/n) y) Yes n) No y/n> n Remote config -------------------- [cos-instance-2] type = s3 provider = IBMCOS env_auth = false access_key_id = xxxxxx secret_access_key = xxxxxxxxx endpoint = s3-api.us-geo.objectstorage.softlayer.net location_constraint = us-standard acl = private -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y Current remotes: Name Type ==== ==== cos-instance-1 s3 cos-instance-2 s3 -
Wiederholen Sie die vorherigen Schritte, um die COS-Instanz in Ihrem zweiten Konto hinzuzufügen. Wenn Sie die Informationen überprüft haben, drücken Sie
q, um den Konfigurationsprozess zu beenden.
Anzeigen des Inhalts Ihrer COS-Eimer
Konto 1 Konto 2
Überprüfen Sie nach der Konfiguration von rclone den Inhalt der einzelnen Buckets und synchronisieren Sie dann die Daten zwischen den Buckets der einzelnen Konten.
-
Sehen Sie sich zunächst den Inhalt des Buckets an.
rclone ls cos-instance-1:bucket-1 45338 test.txt -
Sehen Sie sich den Inhalt des Buckets in Instanz 2 an. In diesem Beispiel lautet der Bucket-Name
bucket-2.rclone ls cos-instance-2:bucket-2
Inhalte zwischen Buckets synchronisieren
Konto 1 Konto 2
-
Um die Daten von einem Bucket in einen anderen zu verschieben, können Sie den
rclone syncBefehl. In diesem Beispielcos-instance-1:bucket-1ist in einem Konto, währendcos-instance-2:bucket-2ist eine zweite Instanz von COS in einem separaten Konto.Beispiel
rclone sync -P cos-instance-1:bucket-1 cos-instance-2:bucket-2Beispielausgabe
Transferred: 754.933k / 754.933 kBytes, 100%, 151.979 kBytes/s, ETA 0s Errors: 0 Checks: 0 / 0, - Transferred: 18 / 18, 100% Elapsed time: 4.9 -
Überprüfen Sie den Inhalt des Eimers in
cos-instance-1wurden mit dem Bucket synchronisiert incos-instance-2.rclone ls cos-instance-2:bucket-2Beispielausgabe
45338 test.txt
Stellen Sie Ihre Anwendung in Konto 2 erneut bereit
Konto 2
-
Kopieren Sie den folgenden PVC-Code und speichern Sie ihn in einer Datei namens
pvc.yamlkind: PersistentVolumeClaim apiVersion: v1 metadata: name: demo # Enter a name for your PVC. namespace: default annotations: ibm.io/bucket-name: "bucket-2" # Enter the name of the bucket in Account 2 ibm.io/auto-create-bucket: "false" ibm.io/auto-delete-bucket: "false" ibm.io/secret-name: SECRET-NAME #Enter the name of the secret you created earlier. ibm.io/secret-namespace: NAMESPACE #Enter the namespace where you want to create the PVC. spec: accessModes: - ReadWriteOnce resources: requests: storage: 10Gi storageClassName: ibmc-s3fs-cos #The storage class that you want to use. -
Erstellen Sie die PVC in Ihrem Cluster.
oc apply -f pvc.yaml -
Erstellen Sie eine YAML-Konfigurationsdatei für einen Pod, der das von Ihnen erstellte PVC mountet.
apiVersion: v1 kind: Pod metadata: name: demo-pod namespace: default spec: securityContext: runAsUser: 2000 fsGroup: 2000 volumes: - name: demo-vol persistentVolumeClaim: claimName: demo containers: - name: test image: nginxinc/nginx-unprivileged imagePullPolicy: Always volumeMounts: - name: demo-vol mountPath: /mnt/cosvol -
Erstellen Sie den Pod in Ihrem Cluster.
oc apply -f demo-pod.yaml -
Überprüfen Sie, ob der Pod bereitgestellt wurde. Beachten Sie, dass es einige Minuten dauern kann, bis Ihre App in den Status 'Aktiv' (
Running) wechselt.oc get podsNAME READY STATUS RESTARTS AGE demo-pod 1/1 Running 0 2m58s -
Überprüfen Sie, ob die App auf Ihren Blockspeicherdatenträger schreiben kann, indem Sie sich bei Ihrem Pod anmelden.
oc exec demo-pod -- bash -c "ls /mnt/cosvol"test.txt