RaspberryPiで新型コロナウイルスの解析

COVID-19の解析プロジェクトに参加してみます。
IoT MONITOR

Boinc manager covid-19.jpg

具合

Folding@home
ベータ版

Rosetta@home
3B+WU3個はリソースを食い尽くすことがある 何で?
3B+はI/Oがひどく瀕死 3Bは死にそうだけど空元気

環境

SBC Raspberry Pi 3 Model B, B+
OS Raspberry Pi OS Lite 2020-08-20
ストレージ SanDisk microSDHC 16GB CLASS10
ネットワーク 標準搭載の有線LAN
リモート操作 Windows

ヒートシンク 40×40×25
銅サイコロ 20×20×20
熱伝導性両面テープ 200x300

下調べ

ARM64

必要条件 64-bit ARM = ARMv8 (64bit)
確認
https://ja.wikipedia.org/wiki/Raspberry_Pi
https://elinux.org/RPi_HardwareHistory

Folding@home

https://www.neocortix.com/coronablog
https://foldingathome.org/beta/

SSH
$ wget https://download.foldingathome.org/releases/beta/release/fahclient/debian-stable-arm64/v7.6/fahclient_7.6.18_arm64.deb
$ sudo dpkg -i fahclient_7.6.18_arm64.deb
$ sudo reboot
$ sudo nano /etc/fahclient/config.xml
<allow v='127.0.0.1 192.168.1.0/24'/>
<web-allow v='127.0.0.1 192.168.1.0/24'/>
<command-allow-no-pass v='127.0.0.1 192.168.1.0/24'/>
$ sudo reboot
$ tail -f /var/lib/fahclient/log.txt
Windows
http://<Raspberry Pi IP>:7396
https://download.foldingathome.org/releases/beta/release/fah-installer/windows-10-32bit/v7.6/fah-installer_7.6.18_x86.exe
FAHControl > Clients +Add > Connection > IP:<Raspberry Pi IP>, Port:36330
Remote Access > Allow > 127.0.0.1 192.168.1.0/24
Reboot

No WUs available for this configuration

Uninstall
$ sudo dpkg -P fahclient

Rosetta@home

Raspberry Pi 3 Model BとRaspbian Buster LiteでRosetta@home - Pastebin.com
Running Rosetta (COVID-19 workunits) on Raspberry Pi 3B+ (how to guide) - reddit.com

物理メモリ不足をzramとswapで補ってる

リモート環境

リモート操作用にする

OS

Raspberry Pi Downloads

microSDHC、モニター、キーボード、有線LANを取り付け
電源ON

raspberrypi login: pi
Password: raspberry

expand

$ sudo raspi-config
7.Advanced Options > A1 Expand Filesystem > <Ok> > tab > Finish > reboot<Yes>

keyboard

$ sudo raspi-config
4 Localisation Options > I3 Change Keyboard Layout > Generic 105-key PC (intl.) > Other > Japanese > Japanese > The default for the keyboard layout > No compose key > tab > Finish
$ sudo reboot

firmware

$ sudo rpi-update
$ sudo reboot

kernel

$ sudo nano /boot/config.txt

末尾に追記

arm_64bit=1
gpu_mem=16

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo reboot

確認

$ uname -a
aarch64

hostname

$ sudo raspi-config
2 Network Options > N1 Hostname > <Ok>

変更

covid-19
tab > OK > tab > Finish > <Yes>

SSH

$ sudo raspi-config
5 Interfacing Options > P2 SSH > <Yes> > <Ok> > tab > Finish

電源OFF

$ sudo shutdown -h now

モニター、キーボードを取り外し
電源ON

SSH接続
WindowsのTeraterm使用

ホスト: covid-19.local
ユーザ名: pi
パスフレーズ: raspberry

update

$ sudo apt update
$ sudo apt upgrade

zram

$ sudo nano /usr/bin/zram.sh

設定

#!/bin/bash
cores=$(nproc --all)
modprobe zram num_devices=$cores
swapoff -a
totalmem=`free | grep -e "^Mem:" | awk '{print $2}'`
mem=$(( ($totalmem * 2 / $cores)* 1024 ))
modprobe deflate
modprobe zlib
modprobe lz4hc_compress
core=0
while [ $core -lt $cores ]; do
  echo deflate > /sys/block/zram$core/comp_algorithm ||
   echo zlib > /sys/block/zram$core/comp_algorithm ||
   echo lz4hc > /sys/block/zram$core/comp_algorithm ||
   echo lz4 > /sys/block/zram$core/comp_algorithm
# not sure which one this kernel has
  echo $mem > /sys/block/zram$core/disksize
  mkswap /dev/zram$core
  swapon --discard -p 5 /dev/zram$core # reclaim memory better
  let core=core+1
done

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo chmod +x /usr/bin/zram.sh
$ sudo nano /etc/rc.local

末尾のexit 0手前に追記

/usr/bin/zram.sh &

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo reboot

確認

$ zramctl

swap

$ sudo nano /etc/dphys-swapfile

変更

CONF_SWAPSIZE=2048

保存: Ctrl + o > リターン
終了: Ctrl + x
確認

$ sudo systemctl restart dphys-swapfile
$ swapon

folder2ram

$ sudo wget -O /sbin/folder2ram https://raw.githubusercontent.com/bobafetthotmail/folder2ram/master/debian_package/sbin/folder2ram
$ sudo chmod +x /sbin/folder2ram
$ sudo folder2ram -configure
$ sudo nano /etc/folder2ram/folder2ram.conf

末尾に追記

tmpfs		/var/cache
tmpfs		/tmp
tmpfs		/var/tmp
tmpfs		/var/log
tmpfs		/var/spool

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo folder2ram -mountall
$ sudo folder2ram -enablesystemd
$ sudo reboot

確認

$ df -h

fstab

設定

$ sudo nano /etc/fstab

nodiratime追記と末尾に追記

tmpfs    /tmp                              tmpfs    defaults,noatime,nodiratime,mode=1777  0       0
tmpfs    /run/user/1000                    tmpfs    defaults,noatime,nodiratime,mode=1777  0       0
tmpfs    /home/pi/.cache/lxsession/LXDE-pi tmpfs    defaults,noatime,nodiratime,mode=1777  0       0
tmpfs    /var/lib/netdata                  tmpfs    defaults,noatime,nodiratime,mode=1777  0       0

保存: Ctrl + o リターン
終了: Ctrl + x

再起動

$ sudo reboot

確認

$ df -h

service

$ sudo systemctl stop rsyslog
$ sudo systemctl disable rsyslog
$ sudo systemctl stop hciuart bluetooth
$ sudo systemctl disable hciuart bluetooth
$ sudo systemctl stop systemd-timesyncd systemd-timesync
$ sudo systemctl disable systemd-timesyncd systemd-timesync
$ sudo systemctl stop cron.service
$ sudo systemctl disable cron.service

確認

$ sudo reboot
$ systemctl list-units --type=service

journal

$ sudo nano /etc/systemd/journald.conf

末尾に追記

Storage=none

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo reboot

cpufreq

固定

$ echo "performance"| sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

overclock

Overclocking options in config.txt - Raspberry Pi Documentation

$ sudo nano /boot/config.txt

末尾に追記
3B+のみ

temp_soft_limit=70

3Bの場合 ※操作確認中

arm_freq=1300
over_voltage=5

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo reboot

boinc-client

install

$ sudo apt install boinc-client boinctui

config

$ sudo nano /var/lib/boinc-client/cc_config.xml

設定

<cc_config>
  <log_flags>
    <task>1</task>
    <file_xfer>1</file_xfer>
    <sched_ops>1</sched_ops>
  </log_flags>
  <options>
    <alt_platform>aarch64-unknown-linux-gnu</alt_platform>
    <allow_remote_gui_rpc>1</allow_remote_gui_rpc>
  </options>
</cc_config>

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo nano /var/lib/boinc-client/global_prefs_override.xml

設定

<global_preferences>
    <run_if_user_active>1</run_if_user_active>
    <suspend_cpu_usage>100.000000</suspend_cpu_usage>
    <leave_apps_in_memory>0</leave_apps_in_memory>
    <confirm_before_connecting>0</confirm_before_connecting>
    <hangup_if_dialed>0</hangup_if_dialed>
    <dont_verify_images>0</dont_verify_images>
    <work_buf_min_days>0.700000</work_buf_min_days>
    <work_buf_additional_days>0.300000</work_buf_additional_days>
    <max_ncpus_pct>50.000000</max_ncpus_pct>
    <cpu_scheduling_period_minutes>60.000000</cpu_scheduling_period_minutes>
    <disk_interval>300.000000</disk_interval>
    <disk_max_used_gb>100.000000</disk_max_used_gb>
    <disk_max_used_pct>100.000000</disk_max_used_pct>
    <disk_min_free_gb>0.100000</disk_min_free_gb>
    <vm_max_used_pct>100.000000</vm_max_used_pct>
    <ram_max_used_busy_pct>300.000000</ram_max_used_busy_pct>
    <ram_max_used_idle_pct>300.000000</ram_max_used_idle_pct>
    <cpu_usage_limit>100.000000</cpu_usage_limit>
</global_preferences>

保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo nano /etc/boinc-client/gui_rpc_auth.cfg

適当なパスワードを平文で書く AAAAAAAAA
保存: Ctrl + o > リターン
終了: Ctrl + x

$ sudo reboot

account

http://boinc.bakerlab.org/rosetta/
Join Rosetta@home > Sign Up > アカウントを作成する
Eメール: BBB@BBB.BBB, パスワード: CCCCCCCCC

設定

$ boinccmd --passwd AAAAAAAAA --lookup_account https://boinc.bakerlab.org/rosetta/ BBB@BBB.BBB CCCCCCCCC
status: Success
poll status: operation in progress
poll status: operation in progress
account key: DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

$ boinccmd --passwd AAAAAAAAA --project_attach https://boinc.bakerlab.org/rosetta/ DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
$ boinccmd --passwd AAAAAAAAA --project https://boinc.bakerlab.org/rosetta/ update
$ boinccmd --passwd AAAAAAAAA --get_state
$ boinccmd --passwd AAAAAAAAA --get_tasks

確認

$ boinctui
host 127.0.0.1
port 31416
pwd AAAAAAAAA
$ htop

BOINC Manager

Windows使用

install

https://boinc.berkeley.edu/download.php
ファイル > コンピュータの選択
計算機名(ホスト名): covid-19
パスワード: AAAAAAAAA

プロパティ修正

BOINC Managerを終了
BOINC Managerのアイコンを右クリック > プロパティ
リンク先: "C:\Program Files\BOINC\boincmgr.exe" -n covid-19 -p AAAAAAAAA
BOINC Managerを起動

チームに参加

rosetta@raspberrypi.linux.5ch

log

プロジェクト・サーバからのメッセージ: Rosetta needs 1716.61 MB RAM but only 963.00 MB is available for use.
プロジェクト・サーバからのメッセージ: Rosetta needs 1907.35 MB RAM but only 963.00 MB is available for use.
プロジェクト・サーバからのメッセージ: Rosetta needs 3814.70 MB RAM but only 963.00 MB is available for use.

Netdata memo

Module BOINC

BOINC monitoring with Netdata | Learn

$ cd /etc/netdata
$ sudo ./edit-config python.d/boinc.conf

末尾に追記

remote:
  hostname: covid-19
  password: AAAAAAAAA

保存: Ctrl + o > リターン
終了: Ctrl + x

再起動

$ sudo service netdata restart

Alarms

Health quickstart | Learn
swap.confは役に立たないので停止
ram.confはしきい値を調整
boinc.confはWU0個で警告が出るので停止
Parent(親機)の設定が全てのChild(子機)で機能する様子

Parent(親機)

$ cd /etc/netdata/
$ sudo ./edit-config health.d/swap.conf

設定

# you can disable an alarm notification by setting the 'to' line to: silent

   alarm: 30min_ram_swapped_out
      on: system.swapio
      os: linux freebsd
   hosts: *
  lookup: sum -30m unaligned absolute of out
          # we have to convert KB to MB by dividing $this (i.e. the result of the lookup)$
    calc: $this / 1024 * 100 / ( $system.ram.used + $system.ram.cached + $system.ram.free$
   units: % of RAM
   every: 1m
#   warn: $this > (($status >= $WARNING)  ? (10) : (20))
#   crit: $this > (($status == $CRITICAL) ? (20) : (30))
    warn: $this > (($status >= $WARNING)  ? (99700000) : (99800000))
    crit: $this > (($status == $CRITICAL) ? (99800000) : (99900000))
   delay: up 0 down 15m multiplier 1.5 max 1h
    info: the amount of memory swapped in the last 30 minutes, as a percentage of the sys$
      to: sysadmin

   alarm: ram_in_swap
      on: system.swap
      os: linux
   hosts: *
    calc: $used * 100 / ( $system.ram.used + $system.ram.cached + $system.ram.free )
   units: % of RAM
   every: 10s
#   warn: $this > (($status >= $WARNING)  ? (15) : (20))
#   crit: $this > (($status == $CRITICAL) ? (40) : (50))
    warn: $this > (($status >= $WARNING)  ? (99700000) : (99800000))
    crit: $this > (($status == $CRITICAL) ? (99800000) : (99900000))
   delay: up 30s down 15m multiplier 1.5 max 1h
    info: the swap memory used, as a percentage of the system RAM
      to: sysadmin

   alarm: used_swap
      on: system.swap
      os: linux freebsd
   hosts: *
    calc: $used * 100 / ( $used + $free )
   units: %
   every: 10s
    warn: $this > (($status >= $WARNING)  ? (80) : (90))
    crit: $this > (($status == $CRITICAL) ? (90) : (98))
   delay: up 30s down 15m multiplier 1.5 max 1h
    info: the percentage of swap memory used
      to: sysadmin

保存: Ctrl + o > リターン
終了: Ctrl + x

リロード

$ sudo netdatacli reload-health

Parent(親機)

$ cd /etc/netdata/
$ sudo ./edit-config health.d/ram.conf

設定

# you can disable an alarm notification by setting the 'to' line to: silent

   alarm: used_ram_to_ignore
      on: system.ram
      os: linux freebsd
   hosts: *
    calc: ($zfs.arc_size.arcsz = nan)?(0):($zfs.arc_size.arcsz - $zfs.arc_size.min)
   every: 10s
    info: the amount of memory that is reported as used, but it is actually capable fo$

   alarm: ram_in_use
      on: system.ram
      os: linux
   hosts: *
#   calc: $used * 100 / ($used + $cached + $free)
    calc: ($used - $used_ram_to_ignore) * 100 / ($used  + $cached + $free)
   units: %
   every: 10s
    warn: $this > (($status >= $WARNING)  ? (80) : (90))
    crit: $this > (($status == $CRITICAL) ? (90) : (98))
   delay: down 15m multiplier 1.5 max 1h
    info: system RAM used
      to: sysadmin

   alarm: ram_available
      on: mem.available
      os: linux
   hosts: *
    calc: ($avail + $system.ram.used_ram_to_ignore) * 100 / ($system.ram.used + $syste$
   units: %
   every: 10s
#   warn: $this < (($status >= $WARNING)  ? (15) : (10))
#   crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
    warn: $this < (($status >= $WARNING)  ? (7.5) : (5))
    crit: $this < (($status == $CRITICAL) ? ( 5) :(2.5))
   delay: down 15m multiplier 1.5 max 1h
    info: estimated amount of RAM available for userspace processes, without causing s$
      to: sysadmin

## FreeBSD
   alarm: ram_in_use
      on: system.ram
      os: freebsd
   hosts: *
    calc: ($active + $wired + $laundry + $buffers - $used_ram_to_ignore) * 100 / ($act$
   units: %
   every: 10s
    warn: $this > (($status >= $WARNING)  ? (80) : (90))
    crit: $this > (($status == $CRITICAL) ? (90) : (98))
   delay: down 15m multiplier 1.5 max 1h
    info: system RAM usage
      to: sysadmin

   alarm: ram_available
      on: system.ram
      os: freebsd
   hosts: *
    calc: ($free + $inactive + $used_ram_to_ignore) * 100 / ($free + $active + $inacti$
   units: %
   every: 10s
    warn: $this < (($status >= $WARNING)  ? (15) : (10))
    crit: $this < (($status == $CRITICAL) ? (10) : ( 5))
   delay: down 15m multiplier 1.5 max 1h
    info: estimated amount of RAM available for userspace processes, without causing s$
      to: sysadmin

保存: Ctrl + o > リターン
終了: Ctrl + x

リロード

$ sudo netdatacli reload-health

Parent(親機)

$ cd /etc/netdata/
$ sudo ./edit-config health.d/boinc.conf

設定

# Alarms for various BOINC issues.

# Warn on any compute errors encountered.
template: boinc_compute_errors
      on: boinc.states
      os: *
   hosts: *
families: *
  lookup: average -10m unaligned of comperror
   units: tasks
   every: 1m
    warn: $this > 0
    crit: $this > 1
   delay: up 1m down 5m multiplier 1.5 max 1h
    info: the total number of compute errors over the past 10 minutes
      to: sysadmin

# Warn on lots of upload errors
template: boinc_upload_errors
      on: boinc.states
      os: *
   hosts: *
families: *
  lookup: average -10m unaligned of upload_failed
   units: tasks
   every: 1m
    warn: $this > 0
    crit: $this > 1
   delay: up 1m down 5m multiplier 1.5 max 1h
    info: the average number of failed uploads over the past 10 minutes
      to: sysadmin

# Warn on the task queue being empty
template: boinc_total_tasks
      on: boinc.tasks
      os: *
   hosts: *
families: *
  lookup: average -10m unaligned of total
   units: tasks
   every: 1m
   #warn: $this < 1
   #crit: $this < 0.1
   delay: up 5m down 10m multiplier 1.5 max 1h
    info: the total number of locally available tasks
      to: sysadmin

# Warn on no active tasks with a non-empty queue
template: boinc_active_tasks
      on: boinc.tasks
      os: *
   hosts: *
families: *
  lookup: average -10m unaligned of active
    calc: ($boinc_total_tasks >= 1) ? ($this) : (inf)
   units: tasks
   every: 1m
   #warn: $this < 1
   #crit: $this < 0.1
   delay: up 5m down 10m multiplier 1.5 max 1h
    info: the total number of active tasks
      to: sysadmin

保存: Ctrl + o > リターン
終了: Ctrl + x

リロード

$ sudo netdatacli reload-health

更新履歴

  • 2020.09.26 全体に設定見直し
  • 2020.05.19 cc_config.xml BOINC Manager 設定見直し
  • 2020.05.03 書き直し
  • 2020.04.06 公開