Last active
March 7, 2022 00:12
-
-
Save sanderpick/8660d93abd7cef3c8372565081e280fe to your computer and use it in GitHub Desktop.
Install an ipfs-cluster peer on Amazon Linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
[ -z "$CLUSTER_SECRET" ] && echo "Need to set CLUSTER_SECRET" && exit 1; | |
echo 'export IPFS_PATH=/data/ipfs' >>~/.bash_profile | |
echo 'export IPFS_CLUSTER_PATH=/data/ipfs-cluster' >>~/.bash_profile | |
source ~/.bash_profile | |
# ipfs daemon | |
wget https://dist.ipfs.io/go-ipfs/v0.4.15/go-ipfs_v0.4.15_linux-amd64.tar.gz | |
tar xvfz go-ipfs_v0.4.15_linux-amd64.tar.gz | |
rm go-ipfs_v0.4.15_linux-amd64.tar.gz | |
sudo mv go-ipfs/ipfs /usr/local/bin | |
rm -rf go-ipfs | |
# ipfs cluster service | |
wget https://dist.ipfs.io/ipfs-cluster-service/v0.4.0/ipfs-cluster-service_v0.4.0_linux-amd64.tar.gz | |
tar xvfz ipfs-cluster-service_v0.4.0_linux-amd64.tar.gz | |
rm ipfs-cluster-service_v0.4.0_linux-amd64.tar.gz | |
sudo mv ipfs-cluster-service/ipfs-cluster-service /usr/local/bin | |
rm -rf ipfs-cluster-service | |
# ipfs cluster ctl | |
wget https://dist.ipfs.io/ipfs-cluster-ctl/v0.4.0/ipfs-cluster-ctl_v0.4.0_linux-amd64.tar.gz | |
tar xvfz ipfs-cluster-ctl_v0.4.0_linux-amd64.tar.gz | |
rm ipfs-cluster-ctl_v0.4.0_linux-amd64.tar.gz | |
sudo mv ipfs-cluster-ctl/ipfs-cluster-ctl /usr/local/bin | |
rm -rf ipfs-cluster-ctl | |
# init ipfs | |
sudo mkdir -p $IPFS_PATH | |
sudo chown ec2-user:ec2-user $IPFS_PATH | |
ipfs init -p server | |
ipfs config Datastore.StorageMax 100GB | |
# uncomment if you want direct access to the instance's gateway | |
#ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080 | |
# init ipfs-cluster-service | |
sudo mkdir -p $IPFS_CLUSTER_PATH | |
sudo chown ec2-user:ec2-user $IPFS_CLUSTER_PATH | |
ipfs-cluster-service init | |
if [ ! -z "$CLUSTER_BOOTSTRAP" ]; then | |
sed -i -e "s;\"bootstrap\": \[\];\"bootstrap\": [\"${CLUSTER_BOOTSTRAP}\"];" "${IPFS_CLUSTER_PATH}/service.json" | |
fi | |
sed -i -e 's;127\.0\.0\.1/tcp/9095;0.0.0.0/tcp/9095;' "${IPFS_CLUSTER_PATH}/service.json" | |
# ipfs systemctl service | |
sudo bash -c 'cat >/lib/systemd/system/ipfs.service <<EOL | |
[Unit] | |
Description=ipfs daemon | |
[Service] | |
ExecStart=/usr/local/bin/ipfs daemon --enable-gc | |
Restart=always | |
User=ec2-user | |
Group=ec2-user | |
Environment="IPFS_PATH=/data/ipfs" | |
[Install] | |
WantedBy=multi-user.target | |
EOL' | |
# ipfs-cluster systemctl service | |
sudo bash -c 'cat >/lib/systemd/system/ipfs-cluster.service <<EOL | |
[Unit] | |
Description=ipfs-cluster-service daemon | |
Requires=ipfs.service | |
After=ipfs.service | |
[Service] | |
ExecStart=/usr/local/bin/ipfs-cluster-service daemon | |
Restart=always | |
User=ec2-user | |
Group=ec2-user | |
Environment="IPFS_CLUSTER_PATH=/data/ipfs-cluster" | |
[Install] | |
WantedBy=multi-user.target | |
EOL' | |
# enable the new services | |
sudo systemctl daemon-reload | |
sudo systemctl enable ipfs.service | |
sudo systemctl enable ipfs-cluster.service | |
# start the ipfs-cluster-service daemon (the ipfs daemon will be started first) | |
sudo systemctl start ipfs-cluster |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
First node (node_0) setup
Jump down to Run the installer.
Other nodes (node_n>0) setup
On node_0 after running the installer,
In the above log output, look under the line
INFO cluster: IPFS Cluster v0.3.0 listening on: cluster.go:91
and make a note of the full non-loopback ip4 cluster multiaddress (cluster.listen_multiaddress
). This will reference your instance's private IP address and will be used to bootstrap other nodes.Back to other nodes (node_n>0),
Run the installer
Sanity check
Tail Cluster Logs