Skip to content

Commit 345fb4f

Browse files
committed
Updated README with more information.
- Corrected an issue with the user setup step. - Added a new service installation script.
1 parent 4e7c8b0 commit 345fb4f

File tree

5 files changed

+114
-56
lines changed

5 files changed

+114
-56
lines changed

terra/README.md

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,14 @@ This will create a ".terrad" directory in the home folder. It comes with a file
9090

9191
For the Mainnet (columbus-4), the genesis file can be downloaded from https://columbus-genesis.s3-ap-northeast-1.amazonaws.com/columbus-4-genesis.json (reference [docs.terra.money](https://docs.terra.money/node/join-network.html#download-the-genesis-file)).
9292

93-
The address book can be found at https://network.terra.dev/addrbook.json (reference [docs.terra.money](https://docs.terra.money/node/join-network.html#picking-a-network)).
93+
~~The address book can be found at https://network.terra.dev/addrbook.json (reference [docs.terra.money](https://docs.terra.money/node/join-network.html#picking-a-network)).~~ The address book is not actually required.
9494

9595
For the Testnet (tequila-0004), the genesis file can be downloaded from https://raw.githubusercontent.com/terra-project/testnet/master/tequila-0004/genesis.json (reference [github.com](https://github.com/terra-project/testnet)).
9696

9797
The address book can be found at https://network.terra.dev/testnet/addrbook.json
9898

99+
> For Bombay testnet, the genesis file is at https://raw.githubusercontent.com/terra-project/testnet/master/bombay-0007/genesis.json
100+
99101
Update the seeds (~/.terrad/config/config.toml) to begin running the blockchain. The seeds for Mainnet are (reference: [docs.terra.money](https://docs.terra.money/node/join-network.html#define-seed-nodes)):
100102

101103
```
@@ -120,18 +122,93 @@ The daemon can now be started to run through the blocks.
120122

121123
# For a replacement server
122124

125+
One key consideration when preparing a replacement server is whether the blockchain data is migrated or is a new one created.
126+
127+
## Replacement server with new data
128+
123129
Do the same steps for initializing the server. This includes downloading the snapshot file and extracting it.
124130

125131
To do the migration:
126132

127-
1. Stop the old terrad server
133+
1. Stop the old terrad server.
128134
2. Copy `.terrad/config/priv_validator_key.json` to the new node.
129135
3. Copy `.terrad/data/priv_validator_state.json` to the new node.
136+
4. Start the new terrad server.
130137

131138
(Reference: [https://discord.com/channels/566086600560214026/566126867686621185/842673595117207573])
132139

133140
(No need to move .terrad/config/node_key.json - [https://discord.com/channels/566086600560214026/566126867686621185/842673595117207573])
134141

142+
## Replacement server with existing data
143+
144+
Prepare the server by making the software components are in place. There is no need to download the blockchain snapshot since the data is already available for migration.
145+
146+
What _needs_ to be done is to re-attach the block storage when doing the migration. To prepare for this step, the following commands can be run prior to the stopping of the old server.
147+
148+
```bash
149+
sudo mkdir /mnt/columbus4
150+
sudo chown $USER:$USER -R /mnt/columbus4
151+
mkdir -p ~/columbus
152+
mv -i ~/.terrad/data ~/columbus
153+
ln -s /mnt/columbus4/data ~/.terrad/data
154+
```
155+
156+
To do the migration:
157+
158+
1. Stop the old terrad server.
159+
2. Unmount the storage volume.
160+
3. Copy `.terrad/config/priv_validator_key.json` to the new node.
161+
4. Mount the storage volume to the new server.
162+
5. Start the new terrad server.
163+
164+
The sequence of commands is described in the next section.
165+
166+
## Synchronization
167+
168+
To sync data quickly and easily, the replacement server (Server B) needs to generate a set of SSH keys to access the origin server (Server A).
169+
170+
```bash
171+
# Server B
172+
## Create a hosts file entry for the origin server server-a.
173+
vi /etc/hosts
174+
ssh-keygen -t ed25519 -C <name-of-key>
175+
ssh-copy-id -i ~/.ssh/id_ed25519.pub -p 22 server-a
176+
```
177+
178+
Sync the CLI folder to make that the keys are transferred correctly.
179+
180+
```bash
181+
rsync server-a:.terracli/ ~/.terracli/ -e 'ssh -p 22' -vzrcn
182+
# Remove `n` for an actual sync.
183+
```
184+
185+
Create the following sync script in Server B:
186+
187+
```bash
188+
#!/bin/bash
189+
mkdir -p /tmp/staging
190+
rsync server-a:.terrad/config/priv_validator_key.json /tmp/staging/ -e 'ssh -p 22' -vzrc
191+
mv -i /tmp/staging/priv_validator_key.json ~/.terrad/config/
192+
193+
# Include the below for a replacement server with new data.
194+
rsync server-a:.terrad/data/priv_validator_state.json /tmp/staging/ -e 'ssh -p 22' -vzrc
195+
mv -i /tmp/staging/priv_validator_state.json ~/.terrad/data/
196+
```
197+
198+
## Commands:
199+
200+
```bash
201+
# server-a
202+
sudo systemctl terrad stop
203+
umount /dev/sda
204+
205+
# server-b
206+
bash sync.sh
207+
# console: mount the volume
208+
sudo mount -o discard,defaults,noatime /dev/disk/by-id/scsi-0DO_Volume_columbus4e /mnt/columbus4
209+
sudo systemctl terrad start
210+
```
211+
135212
# Client
136213

137214
## Create the keys
@@ -160,8 +237,6 @@ terracli config chain-id tequila-0004 # Testnet
160237
terracli tx oracle set-feeder terra139ycju27xcek7n2ulew308p28pdh6a6mdqac5a --from=terra1rjmzlljxwu2qh6g2sm9uldmtg0kj4qgyy27m6x --fees 33954000ukrw
161238
```
162239

163-
The
164-
165240
## Configure the oracle feeder
166241

167242
terracli tx oracle set-feeder terra139ycju27xcek7n2ulew308p28pdh6a6mdqac5a --from=terra1rjmzlljxwu2qh6g2sm9uldmtg0kj4qgyy27m6x --fees 33954000ukrw
@@ -177,11 +252,10 @@ This creates a file voter.json
177252

178253
cd /home/terrau/oracle-feeder/feeder
179254
/usr/local/bin/npm start vote --\
180-
--source http://localhost:8532/latest \
181-
--lcd https://lcd.terra.dev \
182-
--chain-id "${CHAIN_ID}" \
255+
--source http://localhost:8532/latest \
256+
--lcd https://lcd.terra.dev \
257+
--chain-id "${CHAIN_ID}" \
183258
--denoms sdr,krw,usd,mnt,eur,cny,jpy,gbp,inr,cad,chf,hkd,aud,sgd,thb \
184259
--validator "${VALIDATOR_KEY}" \
185-
--password "${ORACLE_PASS}" \
186-
--gas-prices 169.77ukrw
187-
260+
--password "${ORACLE_PASS}" \
261+
--gas-prices 169.77ukrw

terra/root2.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ then
77
exit
88
fi
99

10-
if [[ -d /home/root/.ssh ]]
10+
if [[ -d /root/.ssh ]]
1111
then
12-
echo "> Copying SSH keys to new user account..."
12+
echo -n "> Copying SSH keys to new user account..."
1313

1414
cp -r .ssh /home/$TERRA_USER
1515
chown -R $TERRA_USER:$TERRA_USER /home/$TERRA_USER/.ssh
1616
chmod 644 /home/$TERRA_USER/.ssh/authorized_keys
1717

18-
echo " Done."
18+
echo " done."
1919
fi
2020

21-
echo "> Enabling sudo without password..."
21+
echo -n "> Enabling sudo without password..."
2222

2323
echo "$TERRA_USER ALL=NOPASSWD: ALL" >> /etc/sudoers
2424

25-
echo " Done."
25+
echo " done."
2626

27-
echo "> Extending resource limits..."
27+
echo -n "> Extending resource limits..."
2828

2929
echo "* soft nofile 65535" >> /etc/security/limits.conf
3030
echo "* hard nofile 65535" >> /etc/security/limits.conf
3131

32-
echo " Done."
32+
echo " done."
3333

34-
echo "> Changing default SSH port, password login, and root configurations..."
34+
echo -n "> Changing default SSH port, password login, and root configurations..."
3535

3636
echo "Port 9560" >> /etc/ssh/sshd_config
3737
echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
3838
echo "PermitRootLogin no" >> /etc/ssh/sshd_config
3939
systemctl restart sshd
4040

41-
echo " Done."
41+
echo " done."

terra/sample/terrad.service

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ After=network.target
44

55
[Service]
66
Type=simple
7-
User=terrau
8-
ExecStart=/home/terrau/go/bin/terrad start
7+
User=$USER
8+
ExecStart=/home/$USER/go/bin/terrad start
99
Restart=on-failure
1010
RestartSec=5s
1111

@@ -14,5 +14,3 @@ WantedBy=multi-user.target
1414

1515
[Service]
1616
LimitNOFILE=65537
17-
18-

terra/user1.sh

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
11
#!/bin/bash
22

3-
# This script is meant to be run as a user.
4-
5-
# The following prerequisite steps are meant to be run as root.
6-
7-
## Create a non-root user. (Copy and run)
8-
#> USER={USER}
9-
#> useradd -m -s /bin/bash $USER
10-
#> usermod -aG sudo $USER
11-
#> passwd $USER
12-
#> cp -r .ssh /home/$USER
13-
#> chown -R $USER:$USER /home/$USER/.ssh
14-
#> chmod 644 /home/$USER/.ssh/authorized_keys
15-
16-
## Enable sudo without password.
17-
#> echo "$USER ALL=NOPASSWD: ALL" >> /etc/sudoers
18-
19-
## Change the default port and remove root SSH
20-
#> vi /etc/ssh/sshd_config
21-
## Port 8888
22-
## PermitRootLogin no
23-
## PasswordAuthentication no
24-
## systemctl restart sshd
25-
26-
# Actual steps to run.
27-
283
## Update the repos.
294
echo "Updating the system"
305
echo "==================="
@@ -33,25 +8,27 @@ sudo apt-get update && sudo apt-get upgrade -y
338
# Installation of build tools.
349
echo "Installing build tools"
3510
echo "======================"
36-
sudo apt-get install -y build-essential
11+
sudo apt-get install -y build-essential
3712
sudo apt-get install -y jq
3813

3914
# System configuration
15+
GOPATH=$HOME/go
16+
GOROOT=/usr/local/go
4017
echo "Configuration"
4118
echo "============="
42-
echo -n "Updating bash profile"
43-
echo "export GOROOT=/usr/local/go" >> ~/.profile
44-
echo "export GOPATH=$HOME/go" >> ~/.profile
19+
echo -n "Updating bash profile..."
20+
echo "export GOROOT=$GOROOT" >> ~/.profile
21+
echo "export GOPATH=$GOPATH" >> ~/.profile
4522
source ~/.profile
4623
echo "export PATH=$GOPATH/bin:$GOROOT/bin:$PATH" >> ~/.profile
4724
source ~/.profile
48-
echo " - done"
25+
echo " done."
4926

5027
echo "Software installation"
5128
echo "====================="
5229
mkdir /home/$USER/downloads
5330

54-
# Installation of Go
31+
# Installation of Go
5532
echo "Installing Go"
5633
echo "-------------"
5734
cd /home/$USER/downloads
@@ -74,14 +51,14 @@ terrad version
7451

7552
# Add alias `tc` and `td` for faster typing
7653
cd /home/$USER/downloads
77-
echo -n "Adding autocompletion for terrad & terracli commands"
54+
echo -n "Adding autocompletion for terrad & terracli commands..."
7855
# Add autocompletion.
7956
terrad completion > terrad_completion
8057
terracli completion > terracli_completion
8158
cat terrad_completion >> ~/.bash_aliases
8259
cat terracli_completion >> ~/.bash_aliases
8360
source ~/.profile
84-
echo " - done"
61+
echo " done."
8562

8663
# Install the Price Server
8764
echo "Downloading Node.js"

terra/user2.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
echo -n "Installing terrad..."
4+
sudo cp -i sample/terrad.service /etc/systemd/system/
5+
sudo sed -i -e 's/$USER/'"$USER"'' /etc/systemd/system/terrad.service
6+
echo " done."
7+
8+
sudo systemctl daemon-reload
9+
sudo systemctl enable terrad

0 commit comments

Comments
 (0)