From 1a7bf42633f1a7737e7c1ef0492dffb66a9a80e5 Mon Sep 17 00:00:00 2001 From: phahulin Date: Tue, 9 Jan 2018 16:59:29 +0300 Subject: [PATCH 1/4] Separate doc files; Add note about running playbook on multiple hosts --- README.md | 135 +------------------------------------- docs/Blockchain-backup.md | 76 +++++++++++++++++++++ docs/Spec-hardfork.md | 75 +++++++++++++++++++++ 3 files changed, 153 insertions(+), 133 deletions(-) create mode 100644 docs/Blockchain-backup.md create mode 100644 docs/Spec-hardfork.md diff --git a/README.md b/README.md index 65b3cc4..ab144e2 100644 --- a/README.md +++ b/README.md @@ -1,135 +1,4 @@ ## DevOps scripts -### 1. Setup blockchain backup from a node: -1. connect to the node as `root`. - -2. clone this repository to `root`'s home folder: -``` -git clone https://github.com/poanetwork/poa-devops.git -``` - -3. make sure `python` (v2.6+ or v3.5+) is installed on the node. - -4. install `pip` and/or upgrade it to the newest version: -``` -apt-get install python-pip -pip install --upgrade pip -``` - -5. upgrade `setuptools` to the newest version: -``` -pip install --upgrade setuptools -``` - -6. install `boto` and `boto3` packages: -``` -pip install boto boto3 -``` - -7. install `ansible`: -``` -pip install ansible -``` - -8. create `group_vars/all` file: -``` -cp group_vars/all.example group_vars/all -``` -and set the following variables: -* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`) -* `access_key` - s3 access key -* `secret_key` - s3 secret key -* `s3_bucket` - s3 bucket name - -you can ignore other variables in this file - -9. create `hosts` file: -``` -touch hosts -``` -and set it to run `backup` on localhost: -``` -[backup] -localhost -``` - -10. run playbook (still, do this on the node) -``` -ansible-playbook -i hosts -c local site.yml -``` - -11. if all is well, setup a cronjob to run every hour: -``` -crontab -e -``` -append the following line: -``` -30 * * * * /bin/bash /root/poa-devops/bkp-blockchain-cron.sh -``` - -12. configure logrotate to archive old log files. Create file `/etc/cron.hourly/poa-devops-logrotate` with the following content: -``` -#!/bin/bash -/usr/sbin/logrotate /root/poa-devops/bkp-blockchain-logrotate.conf -``` -and set permission to run it: -``` -chmod 755 /etc/cron.hourly/poa-devops-logrotate -``` - -### 2. Make a spec.json hard-fork -0. this guide assumes that you're running this playbook from the same machine you used to make initial deployment of your node. So that you already have `python` and `ansible` installed, and you have the correct ssh keypair to root-access the node. - -1. clone this repository: -``` -git clone https://github.com/poanetwork/poa-devops.git -cd poa-devops -``` - -2. create `group_vars/all` file: -``` -cp group_vars/all.example group_vars/all -``` -and set the following variables: -* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`) -* `MAIN_REPO_FETCH` - github account where spec.json is located (e.g. "poanetwork") -* `GENESIS_BRANCH` - correct branch name to fetch from (e.g. "sokol" for testnet, "core" for mainnet) - -ignore other variables in this file - -3. create `hosts` file: -``` -touch hosts -``` -and put your node's ip address (assuming it's 192.0.2.1) there with the following header: -``` -[hf-spec-change] -192.0.2.1 -``` - -4. run the playbook: -``` -ansible-playbook -i hosts site.yml -``` - -5. verify that your node is active in the netstat of the corresponding network - -6. connect to the node -``` -ssh root@192.0.2.1 -``` -switch to the home folder of corresponding role: -``` -# substitute validator with your node's role (bootnode, moc, ...) -cd /home/validator -``` -and check the update time of `spec.json` (should be about the time you started the playbook) -``` -ls -lh -# a long list should appear here, look for spec.json in the rightmost column and check the date and time on the same row -``` -also check that backup was created: -``` -ls -lh spec-hfs/ -# look for a file named similar to spec-hf-20180108-174649.json Numbers represent date and time in UTC when the playbook was started -``` +1. [Setup blockchain backup from a node](Blockchain-backup) +2. [Make a spec.json hard-fork](Spec-hardforck) diff --git a/docs/Blockchain-backup.md b/docs/Blockchain-backup.md new file mode 100644 index 0000000..518d2f8 --- /dev/null +++ b/docs/Blockchain-backup.md @@ -0,0 +1,76 @@ +## Setup blockchain backup from a node +1. connect to the node as `root`. + +2. clone this repository to `root`'s home folder: +``` +git clone https://github.com/poanetwork/poa-devops.git +``` + +3. make sure `python` (v2.6+ or v3.5+) is installed on the node. + +4. install `pip` and/or upgrade it to the newest version: +``` +apt-get install python-pip +pip install --upgrade pip +``` + +5. upgrade `setuptools` to the newest version: +``` +pip install --upgrade setuptools +``` + +6. install `boto` and `boto3` packages: +``` +pip install boto boto3 +``` + +7. install `ansible`: +``` +pip install ansible +``` + +8. create `group_vars/all` file: +``` +cp group_vars/all.example group_vars/all +``` +and set the following variables: +* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`) +* `access_key` - s3 access key +* `secret_key` - s3 secret key +* `s3_bucket` - s3 bucket name + +you can ignore other variables in this file + +9. create `hosts` file: +``` +touch hosts +``` +and set it to run `backup` on localhost: +``` +[backup] +localhost +``` + +10. run playbook (still, do this on the node) +``` +ansible-playbook -i hosts -c local site.yml +``` + +11. if all is well, setup a cronjob to run every hour: +``` +crontab -e +``` +append the following line: +``` +30 * * * * /bin/bash /root/poa-devops/bkp-blockchain-cron.sh +``` + +12. configure logrotate to archive old log files. Create file `/etc/cron.hourly/poa-devops-logrotate` with the following content: +``` +#!/bin/bash +/usr/sbin/logrotate /root/poa-devops/bkp-blockchain-logrotate.conf +``` +and set permission to run it: +``` +chmod 755 /etc/cron.hourly/poa-devops-logrotate +``` diff --git a/docs/Spec-hardfork.md b/docs/Spec-hardfork.md new file mode 100644 index 0000000..6cd1f97 --- /dev/null +++ b/docs/Spec-hardfork.md @@ -0,0 +1,75 @@ +## Make a spec.json hard-fork +0. this guide assumes that you're running this playbook from the same machine you used to make initial deployment of your node. So that you already have `python` and `ansible` installed, and you have the correct ssh keypair to root-access the node. + +1. clone this repository: +``` +git clone https://github.com/poanetwork/poa-devops.git +cd poa-devops +``` + +2. create `group_vars/all` file: +``` +cp group_vars/all.example group_vars/all +``` +and set the following variables: +* `poa_role` - node's role (one of `bootnode`, `validator`, `moc`, `explorer`, `netstat`) +* `MAIN_REPO_FETCH` - github account where spec.json is located (e.g. "poanetwork") +* `GENESIS_BRANCH` - correct branch name to fetch from (e.g. "sokol" for testnet, "core" for mainnet) + +ignore other variables in this file + +3. create `hosts` file: +``` +touch hosts +``` +and put your node's ip address (assuming it's 192.0.2.1) there with the following header: +``` +[hf-spec-change] +192.0.2.1 +``` + +**NOTE** for those who host multiple nodes: +* if all your nodes are of the same role (e.g. all bootnodes), you can run this playbook on all of them by listing their ips, e.g. +``` +[hf-spec-change] +192.0.2.1 +192.0.2.2 +192.0.2.3 +192.0.2.4 +``` +* if you host nodes of different types you can set `poa_role` individually against the corresponding ip address like so: +``` +[hf-spec-change] +192.0.2.1 poa_role=explorer +192.0.2.2 +192.0.2.3 poa_role=moc +192.0.2.4 +``` +when you omit explicit `poa_role` in a row here, the value from `group_vars/all` is used. + +4. run the playbook: +``` +ansible-playbook -i hosts site.yml +``` + +5. verify that your node is active in the netstat of the corresponding network + +6. connect to the node +``` +ssh root@192.0.2.1 +``` +switch to the home folder of corresponding role: +``` +# substitute validator with your node's role (bootnode, moc, ...) +cd /home/validator +``` +and check the update time of `spec.json` (should be about the time you started the playbook) +``` +ls -lh +# a long list should appear here, look for spec.json in the rightmost column and check the date and time on the same row +``` +also check that backup was created: +``` +ls -lh spec-hfs/ +# look for a file named similar to spec-hf-20180108-174649.json Numbers represent date and time in UTC when the playbook was started +``` From 82e58977b33ea353f14b61fcb96550da34c837de Mon Sep 17 00:00:00 2001 From: phahulin Date: Tue, 9 Jan 2018 17:00:34 +0300 Subject: [PATCH 2/4] Fix path to docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab144e2..f0a6821 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## DevOps scripts -1. [Setup blockchain backup from a node](Blockchain-backup) -2. [Make a spec.json hard-fork](Spec-hardforck) +1. [Setup blockchain backup from a node](docs/Blockchain-backup) +2. [Make a spec.json hard-fork](docs/Spec-hardforck) From bd6b0a13c34414e2edc937342058f52b59bcc7ed Mon Sep 17 00:00:00 2001 From: phahulin Date: Tue, 9 Jan 2018 17:01:47 +0300 Subject: [PATCH 3/4] Fix path to docs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0a6821..7ca654f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## DevOps scripts -1. [Setup blockchain backup from a node](docs/Blockchain-backup) -2. [Make a spec.json hard-fork](docs/Spec-hardforck) +1. [Setup blockchain backup from a node](./docs/Blockchain-backup.md) +2. [Make a spec.json hard-fork](./docs/Spec-hardforck.md) From 237f96aa732f28271b61f1c590cd8901d4160373 Mon Sep 17 00:00:00 2001 From: phahulin Date: Tue, 9 Jan 2018 17:02:25 +0300 Subject: [PATCH 4/4] Fix typo in doc path --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ca654f..dbc8c71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ ## DevOps scripts 1. [Setup blockchain backup from a node](./docs/Blockchain-backup.md) -2. [Make a spec.json hard-fork](./docs/Spec-hardforck.md) +2. [Make a spec.json hard-fork](./docs/Spec-hardfork.md)