github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/bucket/replication/setup_3site_replication.sh (about) 1 #!/usr/bin/env bash 2 3 echo "Running $0" 4 5 if [ -n "$TEST_DEBUG" ]; then 6 set -x 7 fi 8 9 trap 'catch $LINENO' ERR 10 11 # shellcheck disable=SC2120 12 catch() { 13 if [ $# -ne 0 ]; then 14 echo "error on line $1" 15 for site in sitea siteb sitec; do 16 echo "$site server logs =========" 17 cat "/tmp/${site}_1.log" 18 echo "===========================" 19 cat "/tmp/${site}_2.log" 20 done 21 fi 22 23 echo "Cleaning up instances of MinIO" 24 pkill minio 25 pkill -9 minio 26 rm -rf /tmp/multisitea 27 rm -rf /tmp/multisiteb 28 rm -rf /tmp/multisitec 29 } 30 31 catch 32 33 set -e 34 export MINIO_CI_CD=1 35 export MINIO_BROWSER=off 36 export MINIO_ROOT_USER="minio" 37 export MINIO_ROOT_PASSWORD="minio123" 38 export MINIO_KMS_AUTO_ENCRYPTION=off 39 export MINIO_PROMETHEUS_AUTH_TYPE=public 40 export MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= 41 unset MINIO_KMS_KES_CERT_FILE 42 unset MINIO_KMS_KES_KEY_FILE 43 unset MINIO_KMS_KES_ENDPOINT 44 unset MINIO_KMS_KES_KEY_NAME 45 46 ( 47 cd ./docs/debugging/s3-check-md5 48 go install -v 49 ) 50 51 wget -q -O mc https://dl.minio.io/client/mc/release/linux-amd64/mc && 52 chmod +x mc 53 54 if [ ! -f mc.RELEASE.2021-03-12T03-36-59Z ]; then 55 wget -q -O mc.RELEASE.2021-03-12T03-36-59Z https://dl.minio.io/client/mc/release/linux-amd64/archive/mc.RELEASE.2021-03-12T03-36-59Z && 56 chmod +x mc.RELEASE.2021-03-12T03-36-59Z 57 fi 58 59 minio server --address 127.0.0.1:9001 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \ 60 "http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_1.log 2>&1 & 61 minio server --address 127.0.0.1:9002 "http://127.0.0.1:9001/tmp/multisitea/data/disterasure/xl{1...4}" \ 62 "http://127.0.0.1:9002/tmp/multisitea/data/disterasure/xl{5...8}" >/tmp/sitea_2.log 2>&1 & 63 64 minio server --address 127.0.0.1:9003 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \ 65 "http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_1.log 2>&1 & 66 minio server --address 127.0.0.1:9004 "http://127.0.0.1:9003/tmp/multisiteb/data/disterasure/xl{1...4}" \ 67 "http://127.0.0.1:9004/tmp/multisiteb/data/disterasure/xl{5...8}" >/tmp/siteb_2.log 2>&1 & 68 69 minio server --address 127.0.0.1:9005 "http://127.0.0.1:9005/tmp/multisitec/data/disterasure/xl{1...4}" \ 70 "http://127.0.0.1:9006/tmp/multisitec/data/disterasure/xl{5...8}" >/tmp/sitec_1.log 2>&1 & 71 minio server --address 127.0.0.1:9006 "http://127.0.0.1:9005/tmp/multisitec/data/disterasure/xl{1...4}" \ 72 "http://127.0.0.1:9006/tmp/multisitec/data/disterasure/xl{5...8}" >/tmp/sitec_2.log 2>&1 & 73 74 sleep 30 75 76 export MC_HOST_sitea=http://minio:minio123@127.0.0.1:9001 77 export MC_HOST_siteb=http://minio:minio123@127.0.0.1:9004 78 export MC_HOST_sitec=http://minio:minio123@127.0.0.1:9006 79 80 ./mc mb sitea/bucket 81 ./mc version enable sitea/bucket 82 ./mc mb -l sitea/olockbucket 83 84 ./mc mb siteb/bucket/ 85 ./mc version enable siteb/bucket/ 86 ./mc mb -l siteb/olockbucket/ 87 88 ./mc mb sitec/bucket/ 89 ./mc version enable sitec/bucket/ 90 ./mc mb -l sitec/olockbucket 91 92 echo "adding replication rule for a -> b : ${remote_arn}" 93 sleep 1 94 ./mc replicate add sitea/bucket/ \ 95 --remote-bucket http://minio:minio123@127.0.0.1:9004/bucket \ 96 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" 97 sleep 1 98 99 echo "adding replication rule for b -> a : ${remote_arn}" 100 ./mc replicate add siteb/bucket/ \ 101 --remote-bucket http://minio:minio123@127.0.0.1:9001/bucket \ 102 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" 103 sleep 1 104 105 echo "adding replication rule for a -> c : ${remote_arn}" 106 ./mc replicate add sitea/bucket/ \ 107 --remote-bucket http://minio:minio123@127.0.0.1:9006/bucket \ 108 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 2 109 sleep 1 110 111 echo "adding replication rule for c -> a : ${remote_arn}" 112 ./mc replicate add sitec/bucket/ \ 113 --remote-bucket http://minio:minio123@127.0.0.1:9001/bucket \ 114 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 2 115 sleep 1 116 117 echo "adding replication rule for b -> c : ${remote_arn}" 118 ./mc replicate add siteb/bucket/ \ 119 --remote-bucket http://minio:minio123@127.0.0.1:9006/bucket \ 120 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 3 121 sleep 1 122 123 echo "adding replication rule for c -> b : ${remote_arn}" 124 ./mc replicate add sitec/bucket/ \ 125 --remote-bucket http://minio:minio123@127.0.0.1:9004/bucket \ 126 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 3 127 sleep 1 128 129 echo "adding replication rule for olockbucket a -> b : ${remote_arn}" 130 ./mc replicate add sitea/olockbucket/ \ 131 --remote-bucket http://minio:minio123@127.0.0.1:9004/olockbucket \ 132 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" 133 sleep 1 134 135 echo "adding replication rule for olockbucket b -> a : ${remote_arn}" 136 ./mc replicate add siteb/olockbucket/ \ 137 --remote-bucket http://minio:minio123@127.0.0.1:9001/olockbucket \ 138 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" 139 sleep 1 140 141 echo "adding replication rule for olockbucket a -> c : ${remote_arn}" 142 ./mc replicate add sitea/olockbucket/ \ 143 --remote-bucket http://minio:minio123@127.0.0.1:9006/olockbucket \ 144 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 2 145 sleep 1 146 147 echo "adding replication rule for olockbucket c -> a : ${remote_arn}" 148 ./mc replicate add sitec/olockbucket/ \ 149 --remote-bucket http://minio:minio123@127.0.0.1:9001/olockbucket \ 150 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 2 151 sleep 1 152 153 echo "adding replication rule for olockbucket b -> c : ${remote_arn}" 154 ./mc replicate add siteb/olockbucket/ \ 155 --remote-bucket http://minio:minio123@127.0.0.1:9006/olockbucket \ 156 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 3 157 sleep 1 158 159 echo "adding replication rule for olockbucket c -> b : ${remote_arn}" 160 ./mc replicate add sitec/olockbucket/ \ 161 --remote-bucket http://minio:minio123@127.0.0.1:9004/olockbucket \ 162 --replicate "existing-objects,delete,delete-marker,replica-metadata-sync" --priority 3 163 sleep 1 164 165 echo "Set default governance retention 30d" 166 ./mc retention set --default governance 30d sitea/olockbucket 167 168 echo "Copying data to source sitea/bucket" 169 ./mc cp --encrypt "sitea/" --quiet /etc/hosts sitea/bucket 170 sleep 1 171 172 echo "Copying data to source sitea/olockbucket" 173 ./mc cp --quiet /etc/hosts sitea/olockbucket 174 sleep 1 175 176 echo "Verifying the metadata difference between source and target" 177 if diff -pruN <(./mc stat --json sitea/bucket/hosts | jq .) <(./mc stat --json siteb/bucket/hosts | jq .) | grep -q 'COMPLETED\|REPLICA'; then 178 echo "verified sitea-> COMPLETED, siteb-> REPLICA" 179 fi 180 181 if diff -pruN <(./mc stat --json sitea/bucket/hosts | jq .) <(./mc stat --json sitec/bucket/hosts | jq .) | grep -q 'COMPLETED\|REPLICA'; then 182 echo "verified sitea-> COMPLETED, sitec-> REPLICA" 183 fi 184 185 echo "Verifying the metadata difference between source and target" 186 if diff -pruN <(./mc stat --json sitea/olockbucket/hosts | jq .) <(./mc stat --json siteb/olockbucket/hosts | jq .) | grep -q 'COMPLETED\|REPLICA'; then 187 echo "verified sitea-> COMPLETED, siteb-> REPLICA" 188 fi 189 190 if diff -pruN <(./mc stat --json sitea/olockbucket/hosts | jq .) <(./mc stat --json sitec/olockbucket/hosts | jq .) | grep -q 'COMPLETED\|REPLICA'; then 191 echo "verified sitea-> COMPLETED, sitec-> REPLICA" 192 fi 193 194 sleep 5 195 196 head -c 221227088 </dev/urandom >200M 197 ./mc.RELEASE.2021-03-12T03-36-59Z cp --config-dir ~/.mc --encrypt "sitea" --quiet 200M "sitea/bucket/200M-enc-v1" 198 ./mc.RELEASE.2021-03-12T03-36-59Z cp --config-dir ~/.mc --quiet 200M "sitea/bucket/200M-v1" 199 200 ./mc cp --encrypt "sitea" --quiet 200M "sitea/bucket/200M-enc-v2" 201 ./mc cp --quiet 200M "sitea/bucket/200M-v2" 202 203 sleep 10 204 205 echo "Verifying ETag for all objects" 206 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9001/ -bucket bucket 207 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9002/ -bucket bucket 208 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9003/ -bucket bucket 209 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9004/ -bucket bucket 210 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9005/ -bucket bucket 211 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9006/ -bucket bucket 212 213 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9001/ -bucket olockbucket 214 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9002/ -bucket olockbucket 215 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9003/ -bucket olockbucket 216 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9004/ -bucket olockbucket 217 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9005/ -bucket olockbucket 218 s3-check-md5 -versions -access-key minio -secret-key minio123 -endpoint http://127.0.0.1:9006/ -bucket olockbucket 219 220 # additional tests for encryption object alignment 221 go install -v github.com/minio/multipart-debug@latest 222 223 upload_id=$(multipart-debug --endpoint 127.0.0.1:9001 --accesskey minio --secretkey minio123 multipart new --bucket bucket --object new-test-encrypted-object --encrypt) 224 225 dd if=/dev/urandom bs=1 count=7048531 of=/tmp/7048531.txt 226 dd if=/dev/urandom bs=1 count=2847391 of=/tmp/2847391.txt 227 228 sudo apt install jq -y 229 230 etag_1=$(multipart-debug --endpoint 127.0.0.1:9002 --accesskey minio --secretkey minio123 multipart upload --bucket bucket --object new-test-encrypted-object --uploadid ${upload_id} --file /tmp/7048531.txt --number 1 | jq -r .ETag) 231 etag_2=$(multipart-debug --endpoint 127.0.0.1:9001 --accesskey minio --secretkey minio123 multipart upload --bucket bucket --object new-test-encrypted-object --uploadid ${upload_id} --file /tmp/2847391.txt --number 2 | jq -r .ETag) 232 multipart-debug --endpoint 127.0.0.1:9002 --accesskey minio --secretkey minio123 multipart complete --bucket bucket --object new-test-encrypted-object --uploadid ${upload_id} 1.${etag_1} 2.${etag_2} 233 234 sleep 10 235 236 ./mc stat sitea/bucket/new-test-encrypted-object 237 ./mc stat siteb/bucket/new-test-encrypted-object 238 ./mc stat sitec/bucket/new-test-encrypted-object 239 240 ./mc ls -r sitea/bucket/ 241 ./mc ls -r siteb/bucket/ 242 ./mc ls -r sitec/bucket/ 243 244 catch