Summary of how to upgrade NEM nodes.


この記事の日本文は下記にあります。
https://qiita.com/Solve/items/22ebda461c943fcc1e45


I have upgraded the NEM node to the latest version (v0.6.98 Harlock), so I tried to summarize how to do it.
Since it describes the case of uploading to root, please change it as appropriate, such as adding sudo. 

##1．Stop node

```
systemctl stop nem-nis.service
systemctl stop nem-servant.service
```

:::note info
The above is when registered with systemd. It doesn't matter how you start or stop it. In addition, I wrote a postscript about the method of automatic startup.
:::

##2．Back up

Rename the folder nemServer (same as backing up).
The new folder nemServer will be created later. 

```
mv nemServer nemServer_backup
```

Make a backup of the nem folder (it will take a few minutes). 

```
cp -rpi nem/ nem_backup/
```

##3．Download new version

```
wget https://github.com/NemProject/nis/releases/download/v0.6.98/nis-0.6.98.tgz

If necessary, download the servant as well.
wget http://bob.nem.ninja/servant_0_0_4.zip
```

##4．Unzip

```
tar xzf nis-0.6.98.tgz
unzip -q servant_0_0_4.zip
```

##5．Put them together in one folder called nemServer

```
mv servant package
mv package nemServer
chmod -R g-w nemServer
```

##6．Copy the following 4 files from backup to nemServer

```
cp -i nemServer_backup/nis/config.properties nemServer/nis
cp -i nemServer_backup/servant/config.properties nemServer/servant

cp -i nemServer_backup/nix.runNis.sh nemServer
cp -i nemServer_backup/servant/startservant.sh nemServer/servant
```

##7．Give execute permission

```
chmod u+x nemServer/nix.runNis.sh
chmod u+x nemServer/servant/startservant.sh
```

##8．Start

```
systemctl daemon-reload

systemctl enable nem-nis.service
systemctl enable nem-servant.service

systemctl start nem-nis.service
systemctl start nem-servant.service
```

##9．Check if it is double started

```
pgrep -fa org.nem
```

##10．Check if it is the latest version

At the link below, if the height is increasing, the startup is successful!
http://(IP address):7890/chain/height

Synchronization will be completed after 5 or 6 hours.
In the link below, if the version is "version": "0.6.98", the upgrade is successful. 
http://(IP address):7890/node/info

After a while, the NEM node list will be updated.
https://nemnodes.org/nodes/

That's all.

I was able to upgrade this way, so I've summarized it. 

##Postscript：The setting of automatic start

《How to use vi》
esc ・ ・ ・ command mode
i ・ ・ ・・ Insert mode
:wq ・ ・ ・ End of writing

(1) Setting for automatic startup of NIS server

```
vi /etc/systemd/system/nem-nis.service
```
Paste the following with i (insert mode) and write with :wq.

↓↓↓↓↓↓↓↓↓↓
[Unit]
Description = NEM NIS Server
After = network.target

[Service]
WorkingDirectory = /root/nemServer
ExecStart = /root/nemServer/nix.runNis.sh
Restart = always

[Install]
WantedBy = multi-user.target
↑↑↑↑↑↑↑↑↑↑

:wq

(2) Setting for automatic startup of Servant server

```
vi /etc/systemd/system/nem-servant.service
```

Paste the following with i (insert mode) and write with :wq.

↓↓↓↓↓↓↓↓↓↓
[Unit]
Description = NEM Servant program
After = network.target nem-nis.target

[Service]
WorkingDirectory = /root/nemServer/servant
ExecStart = /root/nemServer/servant/startservant.sh
Restart = always

[Install]
WantedBy = multi-user.target
↑↑↑↑↑↑↑↑↑↑

:wq

(3) Then register the NIS server and Servant server with systemd

```
systemctl daemon-reload
systemctl enable nem-nis.service
systemctl enable nem-servant.service
```