mirror of
https://git.deuxfleurs.fr/Deuxfleurs/garage.git
synced 2024-11-21 23:51:00 +00:00
Merge pull request 'Add more scripts to ease Garage's development' (#17) from feature/new-script into master
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/17
This commit is contained in:
commit
5dc304ac41
8 changed files with 62 additions and 49 deletions
27
README.md
27
README.md
|
@ -20,27 +20,14 @@ Our main use case is to provide a distributed storage layer for small-scale self
|
||||||
|
|
||||||
We propose the following quickstart to setup a full dev. environment as quickly as possible:
|
We propose the following quickstart to setup a full dev. environment as quickly as possible:
|
||||||
|
|
||||||
1. Setup a rust/cargo environment
|
1. Setup a rust/cargo environment and install s3cmd. eg. `dnf install rust cargo s3cmd`
|
||||||
2. Run `cargo build` to build the project
|
2. Run `cargo build` to build the project
|
||||||
3. Run `./example/dev-cluster.sh` to launch a test cluster (feel free to read the script)
|
3. Run `./script/dev-cluster.sh` to launch a test cluster (feel free to read the script)
|
||||||
4. Set a convenient alias `alias grg=./target/debug/garage`
|
4. Run `./script/dev-configure.sh` to configure your test cluster with default values (same datacenter, 100 tokens)
|
||||||
5. Get your node IDs with `grg status`
|
5. Run `./script/dev-bucket.sh` to create a bucket named `éprouvette` and an API key that will be stored in `/tmp/garage.s3`
|
||||||
6. Configure them, eg. `grg node configure -d dc1 -n 10 dd79867e0f5a9e08`
|
6. Run `source ./script/dev-env.sh` to configure your CLI environment
|
||||||
7. Create a bucket, eg. `grg bucket create éprouvette`
|
7. You can use `garage` to manage the cluster. Try `garage --help`.
|
||||||
8. Create a key, eg. `grg key new --name opérateur`
|
8. You can use `s3grg` to add, remove, and delete files. Try `s3grg --help`, `s3grg put /proc/cpuinfo s3://éprouvette/cpuinfo.txt`, `s3grg ls s3://éprouvette`. `s3grg` is a wrapper on `s3cmd` configured with the previously generated API key (the one in `/tmp/garage.s3`).
|
||||||
9. Bind the key with the bucket, eg. `grg bucket allow éprouvette --read --write --key GK108acc0d179b13826e54442b`
|
|
||||||
10. Install s3cmd, eg. `dnf install s3cmd`
|
|
||||||
11. s3cmd example command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
s3cmd \
|
|
||||||
--host 127.0.0.1:3900 \
|
|
||||||
--access_key=GK108acc0d179b13826e54442b \
|
|
||||||
--secret_key=f52aac5722c48f038ddf8612d1e91e8d0a9535048f1f1cd402cd0416f9f8807f \
|
|
||||||
--region=garage \
|
|
||||||
--no-ssl \
|
|
||||||
ls s3://éprouvette
|
|
||||||
```
|
|
||||||
|
|
||||||
Now you should be ready to start hacking on garage!
|
Now you should be ready to start hacking on garage!
|
||||||
|
|
||||||
|
|
16
script/dev-bucket.sh
Executable file
16
script/dev-bucket.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_FOLDER="`dirname \"$0\"`"
|
||||||
|
REPO_FOLDER="${SCRIPT_FOLDER}/../"
|
||||||
|
GARAGE_DEBUG="${REPO_FOLDER}/target/debug/"
|
||||||
|
GARAGE_RELEASE="${REPO_FOLDER}/target/release/"
|
||||||
|
PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH"
|
||||||
|
|
||||||
|
garage bucket create éprouvette
|
||||||
|
KEY_INFO=`garage key new --name opérateur`
|
||||||
|
ACCESS_KEY=`echo $KEY_INFO|grep -Po 'GK[a-f0-9]+'`
|
||||||
|
SECRET_KEY=`echo $KEY_INFO|grep -Po 'secret_key: "[a-f0-9]+'|grep -Po '[a-f0-9]+$'`
|
||||||
|
garage bucket allow éprouvette --read --write --key $ACCESS_KEY
|
||||||
|
echo "$ACCESS_KEY $SECRET_KEY" > /tmp/garage.s3
|
||||||
|
|
||||||
|
echo "Bucket s3://éprouvette created. Credentials stored in /tmp/garage.s3."
|
|
@ -13,6 +13,9 @@ export RUST_BACKTRACE=1
|
||||||
export RUST_LOG=garage=info
|
export RUST_LOG=garage=info
|
||||||
MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m"
|
MAIN_LABEL="\e[${FANCYCOLORS[0]}[main]\e[49m"
|
||||||
|
|
||||||
|
WHICH_GARAGE=$(which garage || exit 1)
|
||||||
|
echo -en "${MAIN_LABEL} Found garage at: ${WHICH_GARAGE}\n"
|
||||||
|
|
||||||
for count in $(seq 1 3); do
|
for count in $(seq 1 3); do
|
||||||
CONF_PATH="/tmp/config.$count.toml"
|
CONF_PATH="/tmp/config.$count.toml"
|
||||||
LABEL="\e[${FANCYCOLORS[$count]}[$count]\e[49m"
|
LABEL="\e[${FANCYCOLORS[$count]}[$count]\e[49m"
|
||||||
|
@ -24,8 +27,8 @@ data_dir = "/tmp/garage-data-$count"
|
||||||
rpc_bind_addr = "127.0.0.$count:3901" # the port other Garage nodes will use to talk to this node
|
rpc_bind_addr = "127.0.0.$count:3901" # the port other Garage nodes will use to talk to this node
|
||||||
bootstrap_peers = [
|
bootstrap_peers = [
|
||||||
"127.0.0.1:3901",
|
"127.0.0.1:3901",
|
||||||
"127.0.0.2:3901",
|
"127.0.0.2:3901",
|
||||||
"127.0.0.3:3901"
|
"127.0.0.3:3901"
|
||||||
]
|
]
|
||||||
max_concurrent_rpc_requests = 12
|
max_concurrent_rpc_requests = 12
|
||||||
data_replication_factor = 3
|
data_replication_factor = 3
|
||||||
|
@ -37,7 +40,7 @@ api_bind_addr = "127.0.0.$count:3900" # the S3 API port, HTTP without TLS. Add a
|
||||||
s3_region = "garage" # set this to anything. S3 API calls will fail if they are not made against the region set here.
|
s3_region = "garage" # set this to anything. S3 API calls will fail if they are not made against the region set here.
|
||||||
|
|
||||||
[s3_web]
|
[s3_web]
|
||||||
web_bind_addr = "127.0.0.$count:3902"
|
bind_addr = "127.0.0.$count:3902"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo -en "$LABEL configuration written to $CONF_PATH\n"
|
echo -en "$LABEL configuration written to $CONF_PATH\n"
|
15
script/dev-configure.sh
Executable file
15
script/dev-configure.sh
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_FOLDER="`dirname \"$0\"`"
|
||||||
|
REPO_FOLDER="${SCRIPT_FOLDER}/../"
|
||||||
|
GARAGE_DEBUG="${REPO_FOLDER}/target/debug/"
|
||||||
|
GARAGE_RELEASE="${REPO_FOLDER}/target/release/"
|
||||||
|
PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH"
|
||||||
|
|
||||||
|
garage status \
|
||||||
|
| grep UNCONFIGURED \
|
||||||
|
| grep -Po '^[0-9a-f]+' \
|
||||||
|
| while read id; do
|
||||||
|
garage node configure -d dc1 -n 100 $id
|
||||||
|
done
|
||||||
|
|
18
script/dev-env.sh
Executable file
18
script/dev-env.sh
Executable file
|
@ -0,0 +1,18 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
SCRIPT_FOLDER="`dirname \"${BASH_SOURCE[0]}\"`"
|
||||||
|
REPO_FOLDER="${SCRIPT_FOLDER}/../"
|
||||||
|
GARAGE_DEBUG="${REPO_FOLDER}/target/debug/"
|
||||||
|
GARAGE_RELEASE="${REPO_FOLDER}/target/release/"
|
||||||
|
PATH="${GARAGE_DEBUG}:${GARAGE_RELEASE}:$PATH"
|
||||||
|
|
||||||
|
ACCESS_KEY=`cat /tmp/garage.s3 |cut -d' ' -f1`
|
||||||
|
SECRET_KEY=`cat /tmp/garage.s3 |cut -d' ' -f2`
|
||||||
|
|
||||||
|
alias s3grg="s3cmd \
|
||||||
|
--host 127.0.0.1:3900 \
|
||||||
|
--access_key=$ACCESS_KEY \
|
||||||
|
--secret_key=$SECRET_KEY \
|
||||||
|
--region=garage \
|
||||||
|
--no-ssl"
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
for FILE in $(find target); do
|
|
||||||
curl localhost:3900/$FILE -X DELETE -H 'Host: garage'
|
|
||||||
done
|
|
||||||
|
|
13
test_read.sh
13
test_read.sh
|
@ -1,13 +0,0 @@
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
for FILE in $(find target/debug/deps); do
|
|
||||||
SHA2=$(curl localhost:3900/$FILE -H 'Host: garage' 2>/dev/null | sha256sum | cut -d ' ' -f 1)
|
|
||||||
SHA2REF=$(sha256sum $FILE | cut -d ' ' -f 1)
|
|
||||||
if [ "$SHA2" = "$SHA2REF" ]; then
|
|
||||||
echo "OK $FILE"
|
|
||||||
else
|
|
||||||
echo "!!!! ERROR $FILE !!!!"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
for FILE in $(find target/debug/deps); do
|
|
||||||
echo -n "$FILE "
|
|
||||||
curl localhost:3900/$FILE -X PUT -H 'Host: garage' -H 'Content-Type: application/blob' --data-binary "@$FILE" || echo "ERROR"
|
|
||||||
done
|
|
||||||
|
|
Loading…
Reference in a new issue