github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/docs/distributed/distributed-from-config-file.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -e
     4  
     5  cleanup() {
     6  	echo "Cleaning up instances of MinIO"
     7  	pkill minio || true
     8  	pkill -9 minio || true
     9  	rm -rf /tmp/xl/ || true
    10  	rm -rf /tmp/minio.configfile.{1,2,3,4} || true
    11  }
    12  
    13  cleanup
    14  
    15  unset MINIO_KMS_KES_CERT_FILE
    16  unset MINIO_KMS_KES_KEY_FILE
    17  unset MINIO_KMS_KES_ENDPOINT
    18  unset MINIO_KMS_KES_KEY_NAME
    19  
    20  export MINIO_CI_CD=1
    21  
    22  if [ ! -f ./mc ]; then
    23  	os="$(uname -s)"
    24  	arch="$(uname -m)"
    25  	wget -O mc https://dl.minio.io/client/mc/release/${os,,}-${arch,,}/mc &&
    26  		chmod +x mc
    27  fi
    28  
    29  for i in $(seq 1 4); do
    30  	s3Port="$((9000 + i))"
    31  	consolePort="$((s3Port + 1000))"
    32  
    33  	cat <<EOF >/tmp/minio.configfile.$i
    34  version: v1
    35  address: ':${s3Port}'
    36  console-address: ':${consolePort}'
    37  rootUser: 'minr0otUS2r'
    38  rootPassword: 'pBU94AGAY85e'
    39  pools: # Specify the nodes and drives with pools
    40    -
    41       - 'http://localhost:9001/tmp/xl/node9001/mnt/disk{1...4}/'
    42       - 'http://localhost:9002/tmp/xl/node9002/mnt/disk{1,2,3,4}/'
    43    -
    44       - 'http://localhost:9003/tmp/xl/node9003/mnt/disk{1...4}/'
    45       - 'http://localhost:9004/tmp/xl/node9004/mnt/disk1/'
    46       - 'http://localhost:9004/tmp/xl/node9004/mnt/disk2/'
    47       - 'http://localhost:9004/tmp/xl/node9004/mnt/disk3/'
    48       - 'http://localhost:9004/tmp/xl/node9004/mnt/disk4/'
    49  EOF
    50  done
    51  
    52  minio server --config /tmp/minio.configfile.1 >/tmp/minio1_1.log 2>&1 &
    53  site1_pid=$!
    54  minio server --config /tmp/minio.configfile.2 >/tmp/minio2_1.log 2>&1 &
    55  site2_pid=$!
    56  minio server --config /tmp/minio.configfile.3 >/tmp/minio3_1.log 2>&1 &
    57  site3_pid=$!
    58  minio server --config /tmp/minio.configfile.4 >/tmp/minio4_1.log 2>&1 &
    59  site4_pid=$!
    60  
    61  sleep 30
    62  
    63  export MC_HOST_minio1=http://minr0otUS2r:pBU94AGAY85e@localhost:9001
    64  export MC_HOST_minio3=http://minr0otUS2r:pBU94AGAY85e@localhost:9003
    65  
    66  ./mc ready minio1
    67  ./mc ready minio3
    68  
    69  ./mc mb minio1/testbucket
    70  # copy large upload to newbucket on minio1
    71  truncate -s 17M lrgfile
    72  expected_checksum=$(cat ./lrgfile | md5sum)
    73  
    74  ./mc cp ./lrgfile minio1/testbucket
    75  
    76  actual_checksum=$(./mc cat minio3/testbucket/lrgfile | md5sum)
    77  
    78  if [ "${expected_checksum}" != "${actual_checksum}" ]; then
    79  	echo "unexpected object checksum, expected: ${expected_checksum} got: ${actual_checksum}"
    80  	exit
    81  fi
    82  
    83  # Compare the difference of the list of disks and their location, with the below expected output
    84  diff <(./mc admin info minio1 --json | jq -r '.info.servers[].drives[] | "\(.pool_index),\(.set_index),\(.disk_index) \(.endpoint)"' | sort) <(
    85  	cat <<EOF
    86  0,0,0 http://localhost:9001/tmp/xl/node9001/mnt/disk1
    87  0,0,1 http://localhost:9002/tmp/xl/node9002/mnt/disk1
    88  0,0,2 http://localhost:9001/tmp/xl/node9001/mnt/disk2
    89  0,0,3 http://localhost:9002/tmp/xl/node9002/mnt/disk2
    90  0,0,4 http://localhost:9001/tmp/xl/node9001/mnt/disk3
    91  0,0,5 http://localhost:9002/tmp/xl/node9002/mnt/disk3
    92  0,0,6 http://localhost:9001/tmp/xl/node9001/mnt/disk4
    93  0,0,7 http://localhost:9002/tmp/xl/node9002/mnt/disk4
    94  1,0,0 http://localhost:9003/tmp/xl/node9003/mnt/disk1
    95  1,0,1 http://localhost:9004/tmp/xl/node9004/mnt/disk1
    96  1,0,2 http://localhost:9003/tmp/xl/node9003/mnt/disk2
    97  1,0,3 http://localhost:9004/tmp/xl/node9004/mnt/disk2
    98  1,0,4 http://localhost:9003/tmp/xl/node9003/mnt/disk3
    99  1,0,5 http://localhost:9004/tmp/xl/node9004/mnt/disk3
   100  1,0,6 http://localhost:9003/tmp/xl/node9003/mnt/disk4
   101  1,0,7 http://localhost:9004/tmp/xl/node9004/mnt/disk4
   102  EOF
   103  )
   104  
   105  cleanup