ラベル Mint の投稿を表示しています。 すべての投稿を表示
ラベル Mint の投稿を表示しています。 すべての投稿を表示

2023年2月16日木曜日

ホームサーバーの環境移行(3)

仮想化の検討

今後の可用性も考えて、サーバーに載せているサービスの仮想化やコンテナ化を考えてみる。
対象はなんだろう

  • samba
  • gogs
  • nextcloud
  • mydns/グローバルIP監視
  • ログインログアウト監視(Slack連携)
  • MariaDB
  • webmin

gogs

まずはgogs

現状

よかったメモしておいて
https://continue-to-challenge.blogspot.com/search?q=gogs

adeno@blackcube:/home/git$ systemctl status gogs
● gogs.service - Gogs (Go Git Service)
   Loaded: loaded (/etc/systemd/system/gogs.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2023-01-23 04:00:09 JST; 1h 47min ago
 Main PID: 2548 (gogs)
    Tasks: 8 (limit: 4915)
   CGroup: /system.slice/gogs.service
           └─2548 /home/git/gogs/gogs web

 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Started GET /admin/config for 192.168.1.37
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Completed GET /admin/config 200 OK in 21.32905ms
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Started GET /assets/font-awesome-4.6.3/fonts/fontawesome-webfont.woff2?
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] [Static] Serving /assets/font-awesome-4.6.3/fonts/fontawesome-webfont.woff2
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Started GET /img/favicon.png for 192.168.1.37
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] [Static] Serving /img/favicon.png
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Completed GET /img/favicon.png 200 OK in 2.466123ms
 1月 23 05:43:38 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:38: Completed GET /assets/font-awesome-4.6.3/fonts/fontawesome-webfont.woff
 1月 23 05:43:40 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:40: Started GET /admin/repos for 192.168.1.37
 1月 23 05:43:40 blackcube gogs[2548]: [Macaron] 2023-01-23 05:43:40: Completed GET /admin/repos 200 OK in 107.448955ms

たぶん、ここを参考にservice化したのだろう
https://github.com/gogs/gogs/blob/main/scripts/systemd/gogs.service

adeno@blackcube:/home/git$ cat /etc/systemd/system/gogs.service
[Unit]
Description=Gogs (Go Git Service)
After=syslog.target
After=network.target
After=mysqld.service

[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=simple
User=git
Group=git
WorkingDirectory=/home/git/gogs
ExecStart=/home/git/gogs/gogs web
Restart=always
Environment=USER=git HOME=/home/git

[Install]
WantedBy=multi-user.target

dockerでやってみる

https://github.com/gogs/gogs/tree/main/docker

sudo docker pull gogs/gogs
mkdir -p /mnt/workarea/gogs
sudo docker run --name=gogs -p 10022:22 -p 3000:3000 -v /mnt/workarea/gogs:/data gogs/gogs

久しぶりのdockerで使い方忘れてる
あと、gogsのデータの引っ越しはどうやるんだっけ?

adeno@blackcore:~$ sudo docker ps -a
[sudo] adeno のパスワード:          
CONTAINER ID   IMAGE       COMMAND                  CREATED      STATUS                  PORTS     NAMES
5c8dba490d7e   gogs/gogs   "/app/gogs/docker/st…"   9 days ago   Exited (0) 8 days ago             gogs

データの移行

https://github.com/gogs/gogs/discussions/6876

./gogs backup

で、書き出す。gogs-backup-20230123060827.zipが生成された。
/mnt/workarea/gogsに保存すると、docker内では/dataからアクセスできる。

adeno@blackcore:~$ sudo docker exec -it gogs /bin/bash
bash-5.1# ls
data    docker  gogs    log
bash-5.1# ./gogs -v
Gogs version 0.13.0+dev
bash-5.1# ls data/
gogs-backup-20230123060827.zip  gogs.db                         sessions
bash-5.1# 
bash-5.1# ./gogs restore --from="data/gogs-backup-20230123060827.zip" 
2023/01/31 16:28:35 [ INFO] Restoring backup from: data/gogs-backup-20230123060827.zip
2023/01/31 16:28:38 [FATAL] [gogs.io/gogs/gogs.go:40 main()] Failed to start application: init configuration: user configured to run Gogs is "git", but the current user is "root"
bash-5.1# 

カレントユーザーがrootになっているので、ユーザーgitで実行する

docker-compose

なんか難しそうなので、docker-composeを使ってみる

sudo apt install docker-compose

version: '3'
services:
  gogs:
    image: gogs/gogs:latest
    container_name: gogs
    restart: always
    ports:
      - 3000:3000
    volumes:
      - ./data:/data
    links:
      - mariadb:db

  mariadb:
    image: mariadb:latest
    restart: always
    ports:
      - 13306:3306
    environment:
      - MARIADB_ROOT_PASSWORD=************
      - MARIADB_DATABASE=gogs
      - MARIADB_USER=gogs
      - MARIADB_PASSWORD=************

    volumes:
      - ./mariadb/data:/var/lib/mysql
      - ./mariadb/my.cnf:/etc/mysql/conf.d/my.cnf
      - ./mariadb/sql:/docker-entrypoint-initdb.d

sudo docker-compose up -d
sudo docker-compose ps
sudo docker-compose stop

https://qiita.com/wasanx25/items/d47caf37b79e855af95f
https://mebee.info/2020/08/05/post-15924/

データの引っ越し

  • データベース
  • gogs-repositories
  • config
データベース
mysqldump -u git -p gogs_git > gogs.sql.bak
mysql -u gogs -p gogs --port=13306 < /home/adeno/gogs.sql.bak 
gogs-repositories

data/gogs/data/gogs-repositoriesにコピー

config
[repository]
ROOT = /app/gogs/data/gogs-repositories

結局

gogs backup

を使わなかった。

初期設定でのデーターベース設定は以下を参考にした。
https://mebee.info/2020/08/05/post-15924/

ホスト名をgogs_mariadb_1にする

adeno@blackcore:/mnt/backuparea/gogs$ sudo  docker-compose ps
     Name                   Command                  State                      Ports               
----------------------------------------------------------------------------------------------------
gogs             /app/gogs/docker/start.sh  ...   Up (healthy)   22/tcp, 0.0.0.0:3000-              
                                                                 >3000/tcp,:::3000->3000/tcp        
gogs_mariadb_1   docker-entrypoint.sh mariadbd    Up             0.0.0.0:13306->3306/tcp,:::13306-  
                                                                 >3306/tcp                          

rootで実行される

気になる。
rootで実行するし、作成されるファイルも所有者はroot
でもコンテナ内はgitになっている。

adeno@blackcore:/mnt/backuparea/gogs$ ls -l data/gogs/data/
合計 12
drwxr-xr-x 6 root root 4096  2月  6 12:34 gogs
drwxr-xr-x 7 root root 4096  2月  6 12:34 gogs-repositories
drwx------ 3 root root 4096  2月  6 12:34 sessions
sudo docker exec -it gogs /bin/bash
0f3d4c05ae00:/app/gogs# ls -l data/
total 12
drwxrwxr-x    6 git      git           4096 Feb  5 15:59 gogs
drwxr-xr-x    7 git      git           4096 Feb  5 15:59 gogs-repositories
drwx------    4 git      git           4096 Feb  6 03:35 sessions

https://qiita.com/yitakura731/items/36a2ba117ccbc8792aa7

気になる。

なにか方法があるのか

  • rootless
  • rootless + SELinux
  • Podman

https://e-penguiner.com/rootless-docker-for-nonroot/
https://matsuand.github.io/docs.docker.jp.onthefly/engine/security/rootless/
https://matsuand.github.io/docs.docker.jp.onthefly/engine/security/userns-remap/
https://docs.docker.jp/desktop/install/linux-install.html#linux-install-file-sharing

docker rootlessを試してみる

いろいろ試行錯誤したのを一旦整理

まずは普通のインストール

https://docs.docker.com/engine/install/ubuntu/

以下の手順のみLinux Mintでは異なるので注意

3.Use the following command to set up the repository:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$ lsb_release -cs
vanessa

UbuntuのOSバージョンを表示させるにはUBUNTU_CODENAMEが必要

$ cat /etc/os-release 
NAME="Linux Mint"
VERSION="21 (Vanessa)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21"
VERSION_ID="21"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=vanessa
UBUNTU_CODENAME=jammy

なので

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

としちゃう。

動作確認

これで、普通モードの動作確認ができる

sudo docker run hello-world

rootlessモード

ユーザーを作る

  • ユーザー:gogs_docker 1003
  • グループ:gogs-rtls-docker 10099

サブ UID/サブ GIDの設定

$ cat /etc/subuid
gogs_docker:100000:65536

$ cat /etc/subgid
gogs_docker:100000:65536

インストール

https://matsuand.github.io/docs.docker.jp.onthefly/engine/security/rootless/

gogs_docker@blackcore:~$ dockerd-rootless-setuptool.sh install
[INFO] systemd not detected, dockerd-rootless.sh needs to be started manually:

PATH=/home/gogs_docker/bin:/sbin:/usr/sbin:$PATH dockerd-rootless.sh 

[INFO] Creating CLI context "rootless"
Successfully created context "rootless"
[INFO] Use CLI context "rootless"
Current context is now "rootless"
Warning: DOCKER_HOST environment variable overrides the active context. To use "rootless", either set the global --context flag, or unset DOCKER_HOST environment variable.

[INFO] Make sure the following environment variables are set (or add them to ~/.bashrc):

# WARNING: systemd not found. You have to remove XDG_RUNTIME_DIR manually on every logout.
export XDG_RUNTIME_DIR=/home/gogs_docker/.docker/run
export PATH=/home/gogs_docker/bin:$PATH
Some applications may require the following environment variable too:
export DOCKER_HOST=unix:///home/gogs_docker/.docker/run/docker.sock

.bashrcに書くのを忘れない

export XDG_RUNTIME_DIR=/home/gogs_docker/.docker/run
export PATH=/home/gogs_docker/bin:$PATH

動作確認

gogs_docker@blackcore:~$ systemctl --user start docker
Failed to connect to bus: そのようなファイルやディレクトリはありません

gogs_docker@blackcore:~$ systemctl --user status
Failed to connect to bus: そのようなファイルやディレクトリはありません

あれ?

XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user status
● blackcore
    State: degraded
     Jobs: 0 queued
   Failed: 2 units
    Since: Sun 2023-02-12 01:52:28 JST; 9h ago
   CGroup: /user.slice/user-1003.slice/user@1003.service
<<略>>

XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user start docker
Failed to start docker.service: Unit docker.service not found.

ほう。docker.serviceがないのか・・・。

docker.serviceを手動で作る

仕方がないので
.config/systemd/user/docker.service
を手動で作成した。

[Unit]
Description=Docker Application Container Engine (Rootless)
Documentation=https://docs.docker.com/go/rootless/

[Service]
Environment=PATH=/home/gogs_docker/bin:/sbin:/usr/sbin:/home/gogs_docker/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
ExecStart=/home/gogs_docker/bin/dockerd-rootless.sh 
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
StartLimitBurst=3
StartLimitInterval=60s
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TasksMax=infinity
Delegate=yes
Type=notify
NotifyAccess=all
KillMode=mixed

[Install]
WantedBy=default.target

今度こそ
まずはsudoできるユーザーで確認

adeno@blackcore:~$ sudo -u gogs_docker XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user status
[sudo] adeno のパスワード:          
● blackcore
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sun 2023-02-12 12:56:38 JST; 8h ago
   CGroup: /user.slice/user-1003.slice/user@1003.service
           ├─session.slice 
           │ └─pipewire.service 
           │   └─1188 /usr/bin/pipewire
           ├─app.slice 
           │ ├─docker.service 
           │ │ ├─16301 rootlesskit --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin>
           │ │ ├─16310 /proc/self/exe --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=buil>
           │ │ ├─16328 slirp4netns --mtu 65520 -r 3 --disable-host-loopback --enable-sandbox --enable-seccomp 16310 tap0
           │ │ ├─16336 dockerd
           │ │ └─16363 containerd --config /run/user/1003/docker/containerd/containerd.toml --log-level info
           │ └─dbus.service 
           │   └─1234 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
           └─init.scope 
             ├─1140 /lib/systemd/systemd --user
             └─1149 (sd-pam)

sudo -u gogs_docker XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user start docker

よし。
次に、dockerを実行したい一般ユーザーで確認

XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user status
● blackcore
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sun 2023-02-12 12:56:38 JST; 8h ago
   CGroup: /user.slice/user-1003.slice/user@1003.service
           ├─session.slice 
           │ └─pipewire.service 
           │   └─1188 /usr/bin/pipewire
           ├─app.slice 
           │ ├─docker.service 
           │ │ ├─16301 rootlesskit --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin>
           │ │ ├─16310 /proc/self/exe --net=slirp4netns --mtu=65520 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=buil>
           │ │ ├─16328 slirp4netns --mtu 65520 -r 3 --disable-host-loopback --enable-sandbox --enable-seccomp 16310 tap0
           │ │ ├─16336 dockerd
           │ │ └─16363 containerd --config /run/user/1003/docker/containerd/containerd.toml --log-level info
           │ └─dbus.service 
           │   └─1234 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
           └─init.scope 
             ├─1140 /lib/systemd/systemd --user
             └─1149 (sd-pam)

良いね。状態取れた。
サンプルを実行してみる

$ docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

よし。

gogs_docker@blackcore:/mnt/backuparea/gogs_rootless$ docker-compose up
gogs_rootless_mariadb_1 is up-to-date
Starting gogs ... done
Attaching to gogs_rootless_mariadb_1, gogs
<<略>>

OK gogs動いた!

自動起動

 systemctl --user enable docker
 sudo loginctl enable-linger $(whoami)
  • メモ
XDG_RUNTIME_DIR=/run/user/$(id -u gogs_docker) systemctl --user enable docker
Created symlink /home/gogs_docker/.config/systemd/user/default.target.wants/docker.service → /home/gogs_docker/.config/systemd/user/docker.service.

が、再起動後にPSで実行中のコンテナが見れなくなってしまった。

gogs_docker@blackcore:/mnt/backuparea/gogs_rootless$ docker ps -a
Cannot connect to the Docker daemon at unix:///home/gogs_docker/.docker/run/docker.sock. Is the docker daemon running?

sockの場所を明示すると動いた

docker -H unix:///run/user/1003/docker.sock ps
CONTAINER ID   IMAGE              COMMAND                   CREATED       STATUS                 PORTS                                               NAMES
c6a2687906f9   gogs/gogs:latest   "/app/gogs/docker/st…"   3 hours ago   Up 3 hours (healthy)   22/tcp, 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp   gogs
2b74ddf55d44   mariadb:latest     "docker-entrypoint.s…"   3 hours ago   Up 3 hours             0.0.0.0:13306->3306/tcp, :::13306->3306/tcp         gogs_rootless_mariadb_1
$ docker-compose ps
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 153, in apport_excepthook
    with os.fdopen(os.open(pr_filename,
FileNotFoundError: [Errno 2] No such file or directory: '/var/crash/_usr_bin_docker-compose.1003.crash'

Original exception was:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
FileNotFoundError: [Errno 2] No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 755, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 532, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3/dist-packages/six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 394, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3/dist-packages/docker/transport/unixconn.py", line 30, in connect
    sock.connect(self.unix_socket)
urllib3.exceptions.ProtocolError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 214, in _retrieve_server_version
    return self.version(api_version=False)["ApiVersion"]
  File "/usr/lib/python3/dist-packages/docker/api/daemon.py", line 181, in version
    return self._result(self._get(url), json=True)
  File "/usr/lib/python3/dist-packages/docker/utils/decorators.py", line 46, in inner
    return f(self, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 237, in _get
    return self.get(url, **self._set_request_timeout(kwargs))
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 555, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 542, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 655, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 33, in <module>
    sys.exit(load_entry_point('docker-compose==1.29.2', 'console_scripts', 'docker-compose')())
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 81, in main
    command_func()
  File "/usr/lib/python3/dist-packages/compose/cli/main.py", line 200, in perform_command
    project = project_from_options('.', options)
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 60, in project_from_options
    return get_project(
  File "/usr/lib/python3/dist-packages/compose/cli/command.py", line 152, in get_project
    client = get_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 41, in get_client
    client = docker_client(
  File "/usr/lib/python3/dist-packages/compose/cli/docker_client.py", line 170, in docker_client
    client = APIClient(use_ssh_client=not use_paramiko_ssh, **kwargs)
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 197, in __init__
    self._version = self._retrieve_server_version()
  File "/usr/lib/python3/dist-packages/docker/api/client.py", line 221, in _retrieve_server_version
    raise DockerException(
docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', FileNotFoundError(2, 'No such file or directory'))

こちらも同様

docker-compose -H unix:///run/user/1003/docker.sock ps
         Name                        Command                  State                            Ports                      
--------------------------------------------------------------------------------------------------------------------------
gogs                      /app/gogs/docker/start.sh  ...   Up (healthy)   22/tcp, 0.0.0.0:3000->3000/tcp,:::3000->3000/tcp
gogs_rootless_mariadb_1   docker-entrypoint.sh mariadbd    Up             0.0.0.0:13306->3306/tcp,:::13306->3306/tcp      

.bashrcに書いた

export XDG_RUNTIME_DIR=/home/gogs_docker/.docker/run
が余計だったのかな・・・。

これをコメントアウトして試してみる

これで

export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
docker-compose ps
         Name                        Command                  State                            Ports                      
--------------------------------------------------------------------------------------------------------------------------
gogs                      /app/gogs/docker/start.sh  ...   Up (healthy)   22/tcp, 0.0.0.0:3000->3000/tcp,:::3000->3000/tcp
gogs_rootless_mariadb_1   docker-entrypoint.sh mariadbd    Up             0.0.0.0:13306->3306/tcp,:::13306->3306/tcp      

今度こそ大丈夫そう。

改めてデータの引っ越しをする。

データの引っ越し

  • データベース
  • gogs-repositories
  • config
データベース
mysqldump -u git -p gogs_git > gogs.sql.bak
mysql -u gogs -p gogs --port=13306 < /home/adeno/gogs.sql.bak 
gogs-repositories

data/gogs/data/gogs-repositoriesにコピー
データの所有者を100999(コンテナ内のgit(10000)相当)にしておく

config
[repository]
ROOT = /app/gogs/data/gogs-repositories

ホスト名をgogs_mariadb_1にする

これでOKOK

更新ができない

なぜか、もともとの/home/git/gogs-repositoriesを参照しようとする。
困ったので、最終手段でシンボリックリンクを張った。

gogs_docker@blackcore:/mnt/backuparea/gogs$ docker exec -it gogs /bin/bash

c6a2687906f9:/home/git/gogs-repositories# mkdir -p /home/git/gogs/gogs
6a2687906f9:/home/git/gogs-repositories# cd /home/git/gogs/gogs/
c6a2687906f9:/home/git/gogs/gogs# ln -s /app/gogs/data/gogs-repositories/gogs-repositories gogs-repositories
c6a2687906f9:/home/git/gogs/gogs# ls -l
total 0
lrwxrwxrwx    1 root     root            50 Feb 15 16:18 gogs-repositories -> /app/gogs/data/gogs-repositories/gogs-repositories

2023年1月22日日曜日

ホームサーバーの環境移行(2) (GPE-2500T/RTL8125Bが切断される)

有線LANにする

結局、データの転送に思いの外、時間がかかるので、有線LANに変更することにした。
せっかくなので、2.5Gにしたいと思う。

あまり予算もないので、PlanexのGPE-2500TとFX2G-05EMを選んだ。
RTL8125Bというチップを使っており、Linuxでの実績もありそうだ。


 

有線LANが切れる

メインPCの方は安定して動いているけど、ホームサーバーの方はしばらくすると通信ができない状態になってしまう。
その時のシステムログはこんな感じ。

[  940.182815] ------------[ cut here ]------------
[  940.182826] NETDEV WATCHDOG: enp1s0 (r8169): transmit queue 0 timed out
[  940.182875] WARNING: CPU: 6 PID: 0 at net/sched/sch_generic.c:477 dev_watchdog+0x277/0x280
[  940.182890] Modules linked in: ccm rfcomm cmac algif_hash algif_skcipher af_alg ip6t_REJECT nf_reject_ipv6 xt_hl ip6_tables ip6t_rt ipt_REJECT nf_reject_ipv4 xt_LOG nf_log_syslog xt_multiport nft_limit bnep xt_limit xt_addrtype xt_tcpudp xt_conntrack nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nft_counter nf_tables nfnetlink zfs(PO) zunicode(PO) zzstd(O) zlua(O) zavl(PO) icp(PO) zcommon(PO) znvpair(PO) spl(O) intel_rapl_msr intel_rapl_common snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio snd_hda_codec_hdmi snd_hda_intel snd_intel_dspcfg edac_mce_amd snd_intel_sdw_acpi kvm_amd snd_hda_codec snd_hda_core snd_hwdep kvm snd_pcm iwlmvm snd_seq_midi snd_seq_midi_event btusb nls_iso8859_1 mac80211 rapl input_leds joydev snd_rawmidi btrtl libarc4 btbcm snd_seq btintel bluetooth iwlwifi snd_seq_device wmi_bmof k10temp snd_timer ecdh_generic cfg80211 snd ecc ccp soundcore mac_hid sch_fq_codel nct6775 hwmon_vid msr parport_pc ppdev lp parport ramoops pstore_blk reed_solomon
[  940.183202]  pstore_zone efi_pstore ip_tables x_tables autofs4 btrfs blake2b_generic zstd_compress raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c raid0 multipath linear dm_mirror dm_region_hash dm_log raid1 amdgpu hid_generic iommu_v2 gpu_sched i2c_algo_bit drm_ttm_helper ttm drm_kms_helper syscopyarea sysfillrect sysimgblt usbhid fb_sys_fops hid crct10dif_pclmul crc32_pclmul ghash_clmulni_intel cec aesni_intel r8169 gpio_amdpt xhci_pci crypto_simd ahci rc_core i2c_piix4 nvme cryptd drm nvme_core libahci xhci_pci_renesas realtek wmi video gpio_generic
[  940.183390] CPU: 6 PID: 0 Comm: swapper/6 Tainted: P           O      5.15.0-58-generic #64-Ubuntu
[  940.183395] Hardware name: To Be Filled By O.E.M. A520M-ITX/ac/A520M-ITX/ac, BIOS P2.20 12/27/2022
[  940.183399] RIP: 0010:dev_watchdog+0x277/0x280
[  940.183405] Code: eb 97 48 8b 5d d0 c6 05 67 17 69 01 01 48 89 df e8 ce 64 f9 ff 44 89 e1 48 89 de 48 c7 c7 50 62 ed b8 48 89 c2 e8 ef d3 19 00 <0f> 0b eb 80 e9 de 3d 23 00 0f 1f 44 00 00 55 48 89 e5 41 57 41 56
[  940.183410] RSP: 0018:ffffa1a0c0314e70 EFLAGS: 00010282
[  940.183417] RAX: 0000000000000000 RBX: ffff8d1ddbd18000 RCX: 0000000000000000
[  940.183421] RDX: ffff8d24de3ac240 RSI: ffff8d24de3a0580 RDI: 0000000000000300
[  940.183425] RBP: ffffa1a0c0314ea8 R08: 0000000000000003 R09: fffffffffffd7cd0
[  940.183429] R10: 0000000000ffff0a R11: 0000000000000001 R12: 0000000000000000
[  940.183433] R13: ffff8d1ddb1f1e80 R14: 0000000000000001 R15: ffff8d1ddbd184c0
[  940.183436] FS:  0000000000000000(0000) GS:ffff8d24de380000(0000) knlGS:0000000000000000
[  940.183441] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  940.183446] CR2: 000055733bccb020 CR3: 0000000110410000 CR4: 0000000000750ee0
[  940.183450] PKRU: 55555554
[  940.183453] Call Trace:
[  940.183457]  <IRQ>
[  940.183462]  ? pfifo_fast_enqueue+0x160/0x160
[  940.183471]  call_timer_fn+0x2c/0x120
[  940.183479]  __run_timers.part.0+0x1e3/0x270
[  940.183485]  ? ktime_get+0x46/0xc0
[  940.183493]  ? native_x2apic_icr_read+0x20/0x20
[  940.183501]  ? lapic_next_event+0x20/0x30
[  940.183508]  ? clockevents_program_event+0xad/0x130
[  940.183517]  run_timer_softirq+0x2a/0x60
[  940.183522]  __do_softirq+0xd9/0x2e7
[  940.183530]  irq_exit_rcu+0x94/0xc0
[  940.183539]  sysvec_apic_timer_interrupt+0x80/0x90
[  940.183547]  </IRQ>
[  940.183549]  <TASK>
[  940.183552]  asm_sysvec_apic_timer_interrupt+0x1b/0x20
[  940.183558] RIP: 0010:native_safe_halt+0xb/0x10
[  940.183566] Code: 2c ff 5b 41 5c 41 5d 5d c3 cc cc cc cc 4c 89 ee 48 c7 c7 80 43 65 b9 e8 23 91 8d ff eb ca cc eb 07 0f 00 2d d9 e0 45 00 fb f4 <c3> cc cc cc cc eb 07 0f 00 2d c9 e0 45 00 f4 c3 cc cc cc cc cc 0f
[  940.183570] RSP: 0018:ffffa1a0c010be78 EFLAGS: 00000202
[  940.183577] RAX: ffffffffb85afc40 RBX: ffff8d1dc0373280 RCX: 7fffff251d8fda07
[  940.183582] RDX: 00000000000235a1 RSI: 0000000000000006 RDI: 00000000000235a2
[  940.183586] RBP: ffffa1a0c010be80 R08: 000000cd42eda501 R09: 0000000000000000
[  940.183590] R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000000
[  940.183593] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[  940.183598]  ? __cpuidle_text_start+0x8/0x8
[  940.183606]  ? default_idle+0xe/0x20
[  940.183611]  arch_cpu_idle+0x15/0x20
[  940.183620]  default_idle_call+0x3e/0xd0
[  940.183625]  cpuidle_idle_call+0x179/0x1e0
[  940.183633]  do_idle+0x83/0xf0
[  940.183640]  cpu_startup_entry+0x20/0x30
[  940.183644]  start_secondary+0x12a/0x180
[  940.183649]  secondary_startup_64_no_verify+0xc2/0xcb
[  940.183658]  </TASK>
[  940.183661] ---[ end trace 32949fbdb853d046 ]---
[ 1106.094315] r8169 0000:01:00.0 enp1s0: rtl_chipcmd_cond == 1 (loop: 100, delay: 100).
[ 1106.095552] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.096672] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.097791] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.098915] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.100034] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.101153] r8169 0000:01:00.0 enp1s0: rtl_ephyar_cond == 1 (loop: 100, delay: 10).
[ 1106.121214] r8169 0000:01:00.0 enp1s0: rtl_mac_ocp_e00e_cond == 1 (loop: 10, delay: 1000).

以降、[rtl_chipcmd_cond][rtl_ephyar_cond][rtl_mac_ocp_e00e_cond]の繰り返し。

  • インターフェースのLANコネクタのACTは点滅を繰り返している
  • 再起動(reboot)では復旧しない
  • シャットダウンで復旧する
  • BIOSは最新
  • Xログインしていても、していなくても発生する
  • ping打ち続けても発生する

メインPCとの比較

項目 メインPC サーバー
uname -a 5.15.0-57-generic #63-Ubuntu 5.15.0-58-generic #64-Ubuntu
lsb_release Linux Mint 21 (vanessa) Linux Mint 21.1 (vera)
ドライバ r8169 ※ r8169 ※

※マザーボードに搭載されているLANと同じドライバを使用しているみたい。

[    0.896998] r8169 0000:01:00.0 eth0: RTL8125B, **:**:**:**:**:**, XID 641, IRQ 39
[    0.897002] r8169 0000:01:00.0 eth0: jumbo features [frames: 9194 bytes, tx checksumming: ko]

[    0.912515] r8169 0000:04:00.0 eth1: RTL8168h/8111h, **:**:**:**:**:**, XID 541, IRQ 48
[    0.912518] r8169 0000:04:00.0 eth1: jumbo features [frames: 9194 bytes, tx checksumming: ko]|

OSバージョンの違いがあるくらいか・・・。

ドライバを最新にしてみる

https://www.realtek.com/ja/component/zoo/category/network-interface-controllers-10-100-1000m-gigabit-ethernet-pci-express-software

r8169からr8125に変わった。

[    0.882838] r8125: loading out-of-tree module taints kernel.
[    0.882928] r8125: module verification failed: signature and/or required key missing - tainting kernel
[    0.883378] r8125 2.5Gigabit Ethernet driver 9.011.00-NAPI loaded
[    0.902733] r8125: This product is covered by one or more of the following patents: US6,570,884, US6,115,776, and US6,327,625.
[    0.904748] r8125  Copyright (C) 2022 Realtek NIC software team <nicfae@realtek.com> 
[    2.653915] r8125 0000:01:00.0 enp1s0: renamed from eth0
[   10.077752] r8125: enp1s0: link up

しばらく様子見
使っていたら

enp1s0: cmd = 0xff, should be 0x07

となって通信断してしまった。
たぶんapt upgradeで大きの通信をしたタイミングのようだ。

Linux Mint 21 (vanessa)

メインPCと同じ Mint 21をライブUSBにて起動して試してみる。
スピードテストやapt upgradeでは切れないようだ。
1時間様子見でも切れない。

Linux Mint 21.1 (vera)

この状態でまた21.1を起動してみる
スピードテストやapt upgradeでは切れないようだ。
1時間様子見でも切れない。

iperf(ライブUSB)

サーバー <ー メインPC
adeno@drakorange:~$ iperf -c 192.168.1.34 -t 30 
------------------------------------------------------------
Client connecting to 192.168.1.34, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.29 port 53526 connected with 192.168.1.34 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-30.0242 sec  8.22 GBytes  2.35 Gbits/sec
サーバー ー> メインPC
iperf -c 192.168.1.34 -R -t 30 
------------------------------------------------------------
Client connecting to 192.168.1.34, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.29 port 34464 connected with 192.168.1.34 port 5001 (reverse)
[ ID] Interval       Transfer     Bandwidth
[ *1] 0.0000-45.7757 sec   108 MBytes  19.8 Mbits/sec

サーバーPCがリブートしたOrz

iperf(通常起動)

サーバー <ー メインPC
adeno@drakorange:~$ iperf -c 192.168.1.34 -t 30 
------------------------------------------------------------
Client connecting to 192.168.1.34, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.29 port 32992 connected with 192.168.1.34 port 5001
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-30.0178 sec  8.22 GBytes  2.35 Gbits/sec

サーバー ー> メインPC

adeno@drakorange:~$ iperf -c 192.168.1.34 -R -t 30 
------------------------------------------------------------
Client connecting to 192.168.1.34, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.29 port 51360 connected with 192.168.1.34 port 5001 (reverse)
[ ID] Interval       Transfer     Bandwidth
[ *1] 0.0000-30.0122 sec  8.22 GBytes  2.35 Gbits/sec

が、上記10回くらい繰り返したり、パラメータを変えたりしていると

iperf -c 192.168.1.34 -R -t 60 -b 200M
enp1s0: cmd = 0xff, should be 0x07

が発生した。
メインPCの方は大丈夫。

Linux Mint 21 (vanessa)

再度、21で試してみる

iperf -c 192.168.1.34 -t 30
iperf -c 192.168.1.34 -R -t 30 

を10セット

iperf -c 192.168.1.34 -R -t 60 -b 200M

大丈夫だ。
いやだめだ。

NETDEV WATCHDOG: enp1s0 (r8169): transmit queue 0 timed out

でもその後も通信できている
いやだめだ。

もしかして、個体差?

個体を入れ替えてみる

メインPCとサーバーのGPE-2500Tを入れ替えてみた
するとすぐに切断された状態になってしまった。
もしかして、個体差?

まとめると

今までの検証内容をまとめると

ハード GPE-2500T OS ドライバ 長期ping スピードテスト apt upgrade iperf 総合
メインPC A Linux Mint 21 (vanessa) r8169
サーバー B Linux Mint 21.1 (vera) r8169 × ×
サーバー B Linux Mint 21.1 (vera) r8125 × ×
サーバー B Linux Mint 21.1 (vera) r8169 × ×
サーバー B Linux Mint 21 (vanessa) r8169 ×
メインPC B Linux Mint 21 (vanessa) r8169 ? ? × × ×
サーバー A Linux Mint 21 (vanessa) r8169

交換

仕方がないのでもう1つGPE-2500Tを入手した。
これで収束すると良いのだけど。
あと、サポセンに連絡したら返品とか交換とかしてもらえるのかな・・・。

sambaの転送速度

晴れて、有線LANになったことで、転送速度は
14MB/s(112Mbps)→190MB/s(1,520Mbps)となった。
HDDでソフトウェアRAIDということもあり、ワイヤースピートに迫ることはなかったけど、満足感のある結果となった。

2023年1月15日日曜日

ホームサーバーの環境移行(1)

今使っているホームサーバーPCは、2018年から使っており確か急遽交換したものだったからそろそろ計画的なリプレースを考えないとと思っていた。

スペック

現在のホームサーバーPC

No カテゴリ メーカー 名称 備考
1 CPU AMD AMD E-350 1.6GHz 2コア 64bit オンボード
2 M/B Gigabyte GA-E350N-USB3
3 メモリ 8GB
4 グラボ - オンボード
5 SSD シリコンパワー SPCC Solid State 120GB
6-1 HDD WD WDC WD40EZRZ-00G 4TB
6-2 HDD WD WDC WD40EZRZ-00G 4TB
7 ケース シルバーストーン SG05 シンプルで気に入っている
8 電源 - ケースに付属 300W
10 ODD ? LDR PMD8U2
11 NW ELECOM EDC-GUA3-B

300WでHDD2台よく動いたいたな・・・

新しい環境

何かに使うかもしれないので一覧にしておこう

No カテゴリ メーカー 名称 備考
1 CPU AMD AMD Ryzen 5 5600G
1’ CPUファン noctua NH-L9a-AM4
2 M/B ASRock A520 M-ITX/ac wifi内蔵している
3 メモリ CFD W4U3200CS-16G 32GB
4 グラボ - オンボード
5-1 NVMe シリコンパワー SP512GBP34A60M28 512GB
5-2 SSD Crucial MX500 CT1000MX500SSD1JP 1TB
6-1 HDD WD WD60EZAZ-EC 6TB WD Blue
6-2 HDD WD WD60EZAZ-EC 6TB WD Blue
7 ケース Thermaltake Core V1
8 電源 ANTEC NE750 GOLD 750W

750Wは大きすぎたか・・・。



そして、メインPCよりも高スペックになってしまったか。

環境構築

OS

使い慣れている Linux Mintにした
https://linuxmint.com/edition.php?id=304

ストレージ

No カテゴリ サイズ 用途
5-1 NVMe 512GB OS
5-2 SSD 1TB データ
6-1 HDD 6TB バックアップ RAID1
6-2 HDD 6TB バックアップ RAID1

RAID1を組む

RAID1のミラーリングが欲しい
https://e-penguiner.com/software-raid-using-mdadm-on-linux/
https://wiki.archlinux.jp/index.php/RAID
https://qiita.com/hotta_hideyuki/items/696672c5cf48ed6ea686

adeno@BlackCore:~$ cat /proc/mdstat 
Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid1 sda1[0] sdb1[1]
      5860388864 blocks super 1.2 [2/2] [UU]
      bitmap: 0/44 pages [0KB], 65536KB chunk

unused devices: <none>

adeno@BlackCore:~$ sudo mdadm --detail /dev/md0     
/dev/md0:
           Version : 1.2
     Creation Time : Fri Dec 30 19:46:31 2022
        Raid Level : raid1
        Array Size : 5860388864 (5.46 TiB 6.00 TB)
     Used Dev Size : 5860388864 (5.46 TiB 6.00 TB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Tue Jan  3 00:00:17 2023
             State : clean 
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

              Name : BlackCore:0  (local to host BlackCore)
              UUID : *************************************
            Events : 14972

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1

データのコピー

とりあえず、現行サーバーから動画とかを持ってくる

mount media@192.168.1.25:/mnt/4Traid1/media /mnt/blackcube
sudo nohup rsync -av --progress -r /mnt/blackcube/ /mnt/dataarea/backup/media &

バックグラウンドでやってもらうから、「-v --progress」はいらんか

管理用にwebminを

他にもあるのかもしれないが、慣れているので
https://www.webmin.com/deb.html

改めて見てみると、気になるサービスがある
今まで知らなかった・・・。

名称 機能
Bacula バックアップ・プログラム
Fail2Ban 不正攻撃のログ痕跡からアクセスを自動遮断する

Webminstats

サーバーのロードアベレージなどの稼働状態をグラフで表示するもの

https://perl.no-tubo.net/2012/09/26/サーバの状態をグラフ表示。webminで便利なモジュー/

https://i-mscp.net/thread/16882-can-t-locate-rrds-pm-in-inc-you-may-need-to-install-the-rrds-module/

bpytop

webminのプラグインではないけど

ssh

公開鍵認証

公開鍵暗号認証方式にして、パスワード認証を切っておく
https://wiki.archlinux.jp/index.php/SSH_鍵
https://blog.htkyama.org/ssh_ed25519

アクセス制限や不正アクセス検出は別途検討
それまでは、外部からのアクセスは現行サーバー経由にする。

samba

とりあえずメディアNASとして
データ移行をしているが、14MB/s(112Mbps)くらいしか出ない。なぜだろう。
うーん。

iPerf

とりあえず、sambaやraidの影響なのかを切り分けるためにiPerfをやってみた。

送信方向(PCがクライアント)


adeno@BlackCore:~$ iperf -c 192.168.1.24 -p 8888
------------------------------------------------------------
Client connecting to 192.168.1.24, TCP port 8888
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.22 port 44822 connected with 192.168.1.24 port 8888
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0945 sec   348 MBytes   289 Mbits/sec
adeno@BlackCore:~$ iperf -c 192.168.1.24 -p 8888 -l 300M
------------------------------------------------------------
Client connecting to 192.168.1.24, TCP port 8888
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.22 port 41132 connected with 192.168.1.24 port 8888
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.1741 sec   346 MBytes   286 Mbits/sec

280 Mbpsくらいは出ている

受信方向(PCがサーバー)

adeno@BlackCore:~$ iperf -s -p 8888
------------------------------------------------------------
Server listening on TCP port 8888
TCP window size:  128 KByte (default)
------------------------------------------------------------
[  1] local 192.168.1.22 port 8888 connected with 192.168.1.24 port 42254
[ ID] Interval       Transfer     Bandwidth
[  1] 0.0000-10.0785 sec   315 MBytes   262 Mbits/sec
[  2] local 192.168.1.22 port 8888 connected with 192.168.1.24 port 57680
[ ID] Interval       Transfer     Bandwidth
[  2] 0.0000-10.2020 sec   280 MBytes   230 Mbits/sec
[  3] local 192.168.1.22 port 8888 connected with 192.168.1.24 port 42116
[ ID] Interval       Transfer     Bandwidth
[  3] 0.0000-10.1702 sec   319 MBytes   263 Mbits/sec
[  4] local 192.168.1.22 port 8888 connected with 192.168.1.24 port 60410
[ ID] Interval       Transfer     Bandwidth
[  4] 0.0000-10.0746 sec   316 MBytes   264 Mbits/sec

260 Mbpsくらいは出ている

wifiのリンク速度

wifi区間は325Mbps〜433Mbpsでリンクしている。
5GHzのWifi6(AX)までいけるはずなんだけどなぁ。

adeno@BlackCore:~$ sudo iwconfig
[sudo] adeno のパスワード:          
lo        no wireless extensions.

enp3s0    no wireless extensions.

wlp4s0    IEEE 802.11  ESSID:"********"  
          Mode:Managed  Frequency:5.26 GHz  Access Point: ********   
          Bit Rate=433.3 Mb/s   Tx-Power=22 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=68/70  Signal level=-42 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:231   Missed beacon:0

adeno@BlackCore:~$ sudo iw wlp4s0 station dump
Station ******** (on wlp4s0)
	inactive time:	4 ms
	rx bytes:	1961468273
	rx packets:	878388
	tx bytes:	1570600169
	tx packets:	1114913
	tx retries:	115
	tx failed:	0
	beacon loss:	0
	beacon rx:	194343
	rx drop misc:	232
	signal:  	-42 [-42] dBm
	signal avg:	-42 [-42] dBm
	beacon signal avg:	-44 dBm
	tx bitrate:	433.3 MBit/s VHT-MCS 9 80MHz short GI VHT-NSS 1
	tx duration:	0 us
	rx bitrate:	325.0 MBit/s VHT-MCS 7 80MHz short GI VHT-NSS 1
	rx duration:	0 us
	authorized:	yes
	authenticated:	yes
	associated:	yes
	preamble:	long
	WMM/WME:	yes
	MFP:		no
	TDLS peer:	no
	DTIM period:	1
	beacon interval:100
	short slot time:yes
	connected time:	20128 seconds
	associated at [boottime]:	10.529s
	associated at:	1672933142837 ms
	current time:	1672953271071 ms

仕様は?

改めてマザボのスペックを見てみた
https://www.asrock.com/mb/AMD/A520M-ITXac/index.jp.asp#Specification

無線 LAN
- Intel® 802.11ac WiFi モジュール
- IEEE 802.11a/b/g/n/ac
- デュアルバンド (2.4/5 GHz) に対応
- 最大 433Mbps の高速無線接続に対応
- Bluetooth 4.2 + ハイスピードクラス II に対応

最大 433Mbpsか・・・。
有線にしようかな。

2022年12月30日金曜日

メディアサーバー構築2

メディアサーバー構築2

書こう書こうと思っていたら、9ヶ月近く経過していた。
時間が経つのはおそろしい。

メディアサーバーとして、ミニPCを入手した。もろもろ準備を行う。

wifi有効化

システム > ドライバーマネージャー


インストール

  • kodi
  • nextcloud clinet
  • ssh server

nextcloud クライアント

kodiのソース設定でwebdavを選ぶことが出来たが、webdavはちょっと遅かったので、nextcloud clientで同期した。
nextcloudのクライアントアプリで、同期するフォルダやファイルサイズの制限ができる。

これで、勝手に同期してくれる。

kodi

kodi自動起動

[設定マネージャー]→[セッションと起動]→kodiとnextcloudを指定する

ソース設定

nextcloudのディレクトリを指定する

ssh server

ホスト名でアクセスしたい

mDNSでホスト名でアクセスしたい。
avahiを使用しない方法があるのか
https://wiki.archlinux.jp/index.php/Systemd-resolved#mDNS
https://qiita.com/slug/items/4c7121af229b9a6c92c4
https://0e39bf7b.blog/posts/mdns-on-ubuntu-server/

が、ホスト名.localでアクセスすることが出来なかった。

仕方がないので、avahiをインストール
https://wiki.archlinux.jp/index.php/Avahi

sudo apt-get install avahi-daemon libnss-mdns
adeno@nipogi:~$ sudo systemctl status avahi-daemon.service 
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
     Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-12-30 10:50:04 JST; 10min ago
TriggeredBy: ● avahi-daemon.socket
   Main PID: 7685 (avahi-daemon)
     Status: "avahi-daemon 0.7 starting up."
      Tasks: 2 (limit: 14065)
     Memory: 1.4M
     CGroup: /system.slice/avahi-daemon.service
             ├─7685 avahi-daemon: running [nipogi.local]
             └─7687 avahi-daemon: chroot helper

sshサーバー

一応、公開鍵暗号認証方式にして、パスワード認証を切っておく
https://wiki.archlinux.jp/index.php/SSH_鍵
https://blog.htkyama.org/ssh_ed25519

リモコンが欲しい

wiiリモコンを中古でゲット
https://wiki.archlinux.jp/index.php/XWiimote
https://github.com/xwiimote/xwiimote
https://manpages.ubuntu.com/manpages/jammy/en/man4/xorg-xwiimote.4.html

キーのマッピングは以下を参考
https://ja.gadget-info.com/46371-20-kodi-keyboard-shortcuts-every-kodi-user-should-know
http://hide817.blog.fc2.com/blog-entry-6.html?sp
https://kodi.wiki/view/Keymap#Keyboards

変更無しで動いたもの

- +:音量アップ
- -:音量ダウン
- A:決定(リターン)
- B:なし
- HOME:なし
- 1:なし
- 2:なし
- 十字キー:操作

変更する

- B:BackSpace(戻る)
- HOME:ESC(取消)
- 1:スペース(スライドショー)
- 2:なし

sudo apt-get install xwiimote libxwiimote xserver-xorg-input-xwiimote
sudo usermod -aG input kodi

sudo xwiishow 1
xwiikeymap
/usr/share/X11/xorg.conf.d/50-xorg-fix-xwiimote.conf

adeno@nipogi:~$ cat /usr/share/X11/xorg.conf.d/50-xorg-fix-xwiimote.conf 
# X11 xorg Wii Remote raw input config
# XWiimote reports accelerometer and IR data as absolute axes. Disable them to
# avoid weird mouse behaviour. To use IR data as mouse input, use the xwiimote
# tools or xf86-input-xwiimote which overwrites this.
# This only disables the raw input from the kernel devices. If you use the
# xwiimote tools to emulate mouses/keyboards, then they are not affected by
# this.

Section "InputClass"
	Identifier "Nintendo Wii Remote Raw Input Blacklist"
	MatchProduct "Nintendo Wii Remote"
	Option "Ignore" "on"
	Option "MapB" "KEY_BACKSPACE"
    Option "MapHome" "KEY_Escape"
    Option "MapOne" "KEY_Space"
    Option "MapTwo" "KEY_I"
EndSection

これでとりあえずはいいか?

2022年3月21日月曜日

タブレットPCをフォトフレームにする

ASUS TransBook T90chiがある
Windowsが入った、機動力のあるPCだったが、最近は使っていない。
子供用のPCにしようかと思ったけど、まだ早いしスペックもこそまでなので、何か使い道がないかと悩んでいた。
お家の情報共有機器としてなにか使えないか

  • 予定の表示
  • 天気
  • 電車・バスの運行状況
  • フォトフレーム

この中で、すぐに出来そうな「フォトフレーム」をやってみたいと思う。

Linux Mintをインストール

たまたまLinuxインストールを紹介しているサイトを見つけて刺激を受けた
やってみよう
https://nomux2.net/asus-transbook-t90chi-xubuntu/
http://www.drvlabo.jp/wp/archives/1749
http://kapper1224.sblo.jp/article/186209546.html
https://nomux2.net/t09chi-linux-mint/

基本的には一番最後のサイトのままかも
ハマりポイントや変更点は以下の通り。

使用するディストリビューション

adeno@T90CHI:~$ lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.2
Release:	20.2
Codename:	uma

adeno@T90CHI:~$ uname -a
Linux T90CHI 5.1.0-050100-generic #201905052130 SMP Mon May 6 01:32:59 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

bootia32.efi

ブータブルUSBメモリを作成するときに、Etcherを使ったら、空き容量が無くてbootia32.efiの書き込みが出来なかった。
なので、上の方と同じようにrufasを使って対応した。

画面の回転

lotate.shとして以下を作成した。
横向き固定。自動回転はいらなかったので。

xrandr -o right
xinput set-prop 'pointer:SYNA****:** ****:****' 'Coordinate Transformation Matrix' 0 1 0 -1 0 1 0 0 1

サウンド出力

特に何もせずとも対応されていた。

Bluetooth

カーネル5.1で確認した。

カーネル5.1の自動起動

cat /boot/grub/grub.conf

menuentry 'Linux Mint 20.2 Xfce, with Linux 5.1.0-050100-generic' --class linuxmint --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.1.0-050100-generic-advanced-823a8bf2-b59f-4214-ad18-69bd640496f8' {

上記をgrubに設定する。

#GRUB_DEFAULT=0
GRUB_DEFAULT='Advanced options for Linux Mint 20.2 Xfce>Linux Mint 20.2 Xfce, with Linux 5.1.0-050100-generic'

最初書き方がわからなくて、試行錯誤した。

NextCloudクライアント導入

特にハマるところはなし

簡易フォトフレーム

まずはfehで確認

cat ~pf/ph.sh 
#!/bin/bash
feh -F -Z --recursive --randomize /home/pf/Nextcloud/ -D 5

これで5秒毎にランダムに表示される

マウスカーソルを消す

cat ~pf/hide_pointer.sh 
#!/bin/bash
unclutter -idle 1 -root &

https://qiita.com/naohikowatanabe/items/73b093399deb0ebf496e
https://wiki.archlinux.jp/index.php/Unclutter

自動起動・自動終了

/sys/class/rtc/rtc0/wakealarm
が無いから出来ないー
さて困ったものだ。

画面のバックライトOFF/ONで代用するか?
https://wiki.archlinux.jp/index.php/バックライト

adeno@T90CHI:~$ cat /sys/class/backlight/intel_backlight/brightness 
20
adeno@T90CHI:~$ cat /sys/class/backlight/intel_backlight/brightness 
59
adeno@T90CHI:~$ cat /sys/class/backlight/intel_backlight/max_brightness 
100
chmod 777 /sys/class/backlight/intel_backlight/brightness
echo 50 > /sys/class/backlight/intel_backlight/brightness
sleep 1 && xset dpms force off

時間で消灯・時間で点灯

xset dpms force off
xset q
Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  XKB indicators:
    00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
    03: Compose:     off    04: Kana:        off    05: Sleep:       off
    06: Suspend:     off    07: Mute:        off    08: Misc:        off
    09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
    12: Group 2:     off    13: Mouse Keys:  off
  auto repeat delay:  500    repeat rate:  20
  auto repeating keys:  00ffffffdffffbbf
                        fedfffefffedffff
                        9fffffffffffffff
                        fff7ffffffffffff
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  600    cycle:  600
Colors:
  default colormap:  0x20    BlackPixel:  0x0    WhitePixel:  0xffffff
Font Path:
  /usr/share/fonts/X11/misc,/usr/share/fonts/X11/Type1,built-ins
DPMS (Energy Star):
  Standby: 300    Suspend: 0    Off: 600
  DPMS is Enabled
  Monitor is Off

5分周期でチェックスクリプトを実行する
これをcronとかで呼び出す

#!/bin/bash

# display on time
on_time="7:00"

# display off time
off_time="23:50"

# feh option
feh_dir="/home/pf/Nextcloud/"
feh_timer=10

###########################################################
function chk_feh() {
    # PIDを取得する
    feh_exist=`ps aux | grep "feh" | grep "$feh_dir" | awk '{print $2}'`
    echo $feh_exist
}
function display_off () {
    echo 消灯
    feh_pid=`chk_feh`
    echo $feh_pid
    if [[ -n $feh_pid ]]; then
        # プロセス実行中→終了する
        echo プロセス実行中→終了する
        kill $feh_pid
        sleep 1
    fi
    DISPLAY=:0.0 xset dpms force off
}

function display_on () {
    echo 点灯
    feh_pid=`chk_feh`
    echo $feh_pid
    if [[ -z $feh_pid ]]; then
        # プロセスが無い→起動する
        echo プロセスが無い→起動する
        # feh_run=`feh $feh_option`
        # DISPLAY=:0.0 feh -F -Z --recursive --randomize /home/pf/Nextcloud/ -D 5 &
        feh_run=`DISPLAY=:0.0 feh -F -Z --recursive --randomize $feh_dir -D $feh_timer &`
    fi
    DISPLAY=:0.0 xset dpms force on
}


nowdate=`date "+%Y/%m/%d %H:%M:%S"`
chk_base_date=`date +%Y/%m/%d`

echo $nowdate
echo "ON Time= "$chk_base_date" "$on_time
echo "OFF Time= "$chk_base_date" "$off_time

now_time_unix=`date --date "$nowdate" +%s`
on_time_unix=`date --date "$chk_base_date $on_time" +%s`
off_time_unix=`date --date "$chk_base_date $off_time" +%s`
echo $now_time_unix
echo $on_time_unix
echo $off_time_unix

if [ $now_time_unix -lt $on_time_unix ]; then
    display_off
else
    if [ $now_time_unix -lt $off_time_unix ]; then
        display_on
    else
        display_off
    fi
fi

crontabにて

/5 * * * * /home/pf/chk_date.sh > /tmp/chk_date.log

なんだか欲が出てきた。
人感センサーで、動きが無いときは消灯とか・・・。

2022年3月5日土曜日

メディアサーバー構築1

NextCloudに写真とか動画とかを保存している。
ちょっとした共有に便利、スマホで気軽にできるのが良い。
ちょっと欲が出てきて、TVで見てみたいと思い、どのような方法があるのか考えた。
スマホだど画面小さいし、TVの4Kで見てみたいじゃんというのが動機だ。

欲しいスペック

  • DLNAとかwebdav、NextCloudアプリ
  • 4Kで見たい
  • できるだけ安価
  • いろいろな使い方ができる

で、探してみた

No 1 2 3 4
品名 Amazon Fire TV Stick 4K Max Chromecast with Google TV Apple TV 4K ミニPC
価格 @6,980 @7,600 @21,800 @20,000〜@30,000
CPU クアッドコア 1.8GHz 64ビットアーキテクチャ搭載A12 Bionicチップ Celeron
メモリ 2GB 8〜32GB
ストレージ 8GB 32GB 64〜128GB
リモコン あり あり あり なし
DLNA VLC for Fire、kodi 多分○ 多分○?
webdav kodi 多分○ 多分○?
NextCloudアプリ たぶん× 多分○ たぶん×

なんとかTV系の3種は、安いし、それぞれのプラットフォームのサービスをもっているので、心惹かれるものがある。
でもそれらのサービスを使うと沼なので、今はあえて使いたくない。
それと自宅なんちゃってサーバーのリプレースを行う時期なので、今回は茨の道でミニPCを導入してみることにした。

ミニPC

Bmax、CHIWI、NiPoGi、MINISFORUMなどいろいろな種類がある。
自作・BTOも含めるともっとある。

価格や拡張性から、この3機種を候補にした。

No 1 2 3
品名 NiPoGi Bmax E3950 CHIWI HeroBox
CPU Celeron J4125 2GHz 4core Celeron E3950 2GHz 2core Celeron N4100 1.1GHz 4core
メモリ 12GB 8GB 8GB
ストレージ 128GB 128GB 256GB
その他 ファンあり 2.5inchSSD拡張可能 ファンあり 2.5inchSSD拡張可能 ファンレス 拡張は不可
価格 @24,225 @18,691 @21,500

ということで、少々高いが、No1のNiPoGiにすることにした。

NiPoGiとご対面

NiPoGiってなんて読むのかな?にぽぎ?


内臓ストレージにはwin10がインストールされているみたい
今回は、お試しで2.5inchSSDを別で用意して、そっちにLinuxMintをインストールしてみた

以下もろもろのメモ

BIOSは?

DEL長押し

USBブートは?

BIOSでブート順序変更が必要だけど出来た
USB2.0のほうのポートを使った

LinuxMintのインストール

USBブートからのSSDへインストール

TVにつながる?

もちOKだった

TVからリモコン操作できる?

HDMI-CECは出来ないと思う
TVにつないでリモコン操作したくらいでは反応なし
どうやって操作しようか
Bluetoothのリモコン探すか

やりたいことのメモ

入れたいもの

  • kodi
  • nextcloud clinet
  • sshserver

2020年4月15日水曜日

YouPHPTube(avideo)を試してみる

動画管理・・・気になってやってみたかった。
https://www.moongift.jp/2017/06/youphptube-php製のyoutubeクローン/
試すだけ、、、なのできっとDockerがいいんじゃないかなと思った。


↑はフリー素材の犬 かわいい
https://pixabay.com/ja/videos/犬-飲酒-ペット-食品-5631/

Dockerでやってみる

久しぶりです。
Docker自体のインストールもやらないとね

Docker自体のインストール

・docker-ce
https://docs.docker.com/engine/install/ubuntu/
LinuxMintの場合は、Ubuntuじゃないので、注意。
「$(lsb_release -cs)」の部分を「bionic」書き換える。
https://continue-to-challenge.blogspot.com/2019/07/redmine.html
・docker-composer
https://docs.docker.com/compose/install/

ubuntuイメージの取得

$ sudo docker pull ubuntu:18.04
18.04: Pulling from library/ubuntu
5bed26d33875: Pull complete
f11b29a9c730: Pull complete
930bda195c84: Pull complete
78bf9a5ad49e: Pull complete
Digest: sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d
Status: Downloaded newer image for ubuntu:18.04
docker.io/library/ubuntu:18.04

$ sudo docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              18.04               4e5021d210f6        2 weeks ago         64.2MB
起動
$ sudo docker run -it -d --name YouPHPTube -p 127.0.0.1:10080:80 ubuntu:18.04
1e9996bda6d080f5c7697bacdefd5f0f817dc6303b15003726c2bc2cbb10178c
$ sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                     NAMES
1e9996bda6d0        ubuntu:18.04        "/bin/bash"         18 seconds ago      Up 17 seconds       127.0.0.1:10080->80/tcp   YouPHPTube

環境の準備

起動したコンテナにアタッチする
$ sudo docker attach 1e9996bda6d0
<コンテナ側>
apt upate
apt upgrade
これで準備OKのはず

apacheのインストール

作成したコンテナにapacheをインストールしてみる
<コンテナ側>
apt install -y apache2 apache2-utils
service apache2 start
母艦側のでlocalhost:10080にアクセスしてみる


まずはOK

MariaDBのインストール

本当は、1コンテナ(イメージ)に複数のサービスを入れるのは推奨されないみたいだけど、今回はお試しということで、詰め込んじゃう。
公式の手順では、MySQLになっているけど、なんとなくMariaDBにしてみた。
apt install mariadb-server mariadb-client
service mysql start
mysql_secure_installation
アクセスできるかな?
mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 51
Server version: 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
OKそう

AVideo用のユーザー・データベース作成

データベース:AVideo
ユーザー:AVideo
mysql -u root
create database AVideo;
create user AVideo@localhost identified by '**********';
grant all privileges on AVideo.* to AVideo@localhost;
もうひとつEncoder用
データベース:AVideoEncoder
mysql -u root
create database AVideoEncoder;
grant all privileges on AVideoEncoder.* to AVideo@localhost;

その他必要なもの

apt install php libapache2-mod-php php-mysql php-curl php-gd php-intl ffmpeg git libimage-exiftool-perl php-mbstring php-gettext python curl
これで、下準備完了

YouPHPTube(AVideo)のインストール

手順書どおりにやってみる
cd /var/www/html
git clone https://github.com/WWBN/AVideo.git
git clone https://github.com/WWBN/AVideo-Encoder.git
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
a2enmod rewrite
phpenmod mbstring
service apache2 restart

apacheの設定

/etc/apache2/apache2.confで AllowOverride All に変更する
<Directory /var/www/>
          Options Indexes FollowSymLinks
          AllowOverride All
          Require all granted
</Directory>
そのあと更新
a2enmod rewrite
service apache2 restart

アクセスしてみよう

母艦から
http://localhost:10080/AVideo
にアクセスしてみる


ほう。
指示に従って解決していこう

Your videos directory must be writable

「>Details」を開くとやり方が出てきた
mkdir /var/www/html/AVideo/videos
chown www-data:www-data /var/www/html/AVideo/videos && chmod 755 /var/www/html/AVideo/videos

Your post_max_size is 8M, it must be at least 100M

POSTのサイズ
nano /etc/php/7.2/apache2/php.ini
; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
; http://php.net/post-max-size
post_max_size = 8M
とりあえず2Gにしてみた。

Your upload_max_filesize is 2M, it must be at least 100M

アップロードサイズ的なやつか
nano /etc/php/7.2/apache2/php.ini
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 2M
こちらも2Gにしてみた
変更後は、apacheの再起動を行う

セットアップを続けてみよう

あれー


もう一度やろうとすると、、起動しちゃったYO


こっちはこれでいいのかな

YouPHPTube(AVideo)-Encoder にアクセスしてみよう

セットアップウィザード

母艦から
http://localhost:10080/AVideo-Encoder
にアクセスしてみる


ほう。
指示に従って解決していこう
  • Your videos directory must be writable
  • Your max_execution_time is 30, it must be at least 7200
     とりあえず、7200にしてみた
  • Your memory_limit is 128M, it must be at least 512M
    とりあえず2Gにしてみた
これでよし


ここでのSteramerURLはDockerの中なので、**localhost:80/AVideo/**になるので注意

各種設定

基本設定

管理者でログインして
[設定]-[サイトの構成]から各種設定を行っていく

サインイン/アップ

[設定]-[一般的な設定]から
名称 説明 設定値
userMustBeLoggedIn Hide the website to non logged users 有効
doNotIndentifyByEmail Do not show user’s email on the site 有効
doNotIndentifyByUserName Do not show user’s username on the site 有効

プラグイン

[設定]-[その他]-[プラグイン]
名前 要約
Hotkeys Enable hotkeys for videos, like F for fullscreen, space for play/pause, etc…
SeekButton Add seek buttons to the control bar
VideoTags User interface for managing tags
これでしばらく使ってみようかね

コンテナの開始と終了など

忘れてたけど、まだアタッチで起動していただけだった。
アタッチで起動したものはコマンドプロンプトからCtrl+P → Ctrl+Qで抜ける
sudo docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                     NAMES
1e9996bda6d0        ubuntu:18.04        "/bin/bash"         3 days ago          Up 3 days           127.0.0.1:10080->80/tcp   YouPHPTube

#終了
sudo docker stop 1e9996bda6d0

#開始
sudo docker start 1e9996bda6d0

#各種サービス起動
sudo docker exec -it 1e9996bda6d0 service apache2 start
sudo docker exec -it 1e9996bda6d0 service mysql start

#アタッチ
sudo docker attach 1e9996bda6d0

参考

https://github.com/WWBN/AVideo/wiki/How-to-install-LAMP,-FFMPEG-and-Git-on-a-fresh-Ubuntu-18.x-for-AVideo-Platform-version-4.x-or-newer
https://qiita.com/tsumtsumyuma/items/de7678d7f118793ea3e0
http://enakai00.hatenablog.com/entry/20140628/1403933390

2020年3月19日木曜日

メインPCの環境移行-1

夜中、朦朧としながらアップデートやらなんやらをやっていたらXWindow?が起動できなくなった。
さらに、無線LANルーターも調子が悪く、IPv6で繋がらなかったり、通信ができない状態になってしまった。
ルーターの方は再起動でだましだまし使っていたけど、毎日再起動しないといけない状況になったので、諦めて新調することにした。
ノートパソコンも誤って落としちゃうし、最近ついてない?不注意が続いている。

スペック

今まで使っていたPC

No カテゴリ メーカー 名称 備考
1 CPU Intel i7-4770 3.40GHz 第4世代(Haswell)2013年ごろ
2 M/B ASUS B85M-G 2013年ごろ
3 メモリ 16GB
4 グラボ - オンボード
5-1 SSD TOSHIBA THNSNH256 256GB
5-2 SSD KingSpec P3-256 256GB
6 HDD WD WD10EADS 1TB
7 ケース IN WIN IW-CE685/300H シンプルで気に入っている
8 電源 - ケースに付属 300W
9-1 モニタ MITSUBISHI RDT223WM WSXGA 2008年ごろ
9-2 モニタ iiyama ProLite XB2783HSU FullHD
10 ODD Pioneer BDR-209
最近立ち上げたような気がしたけど、実は7年くらい前なんだね。
液晶に関しては12年前・・・よく持ってるわ。
そりゃ愛着も湧くわ。
ハードスペックの確認
https://qiita.com/DaisukeMiyamoto/items/98ef077ddf44b5727c29

新しい環境

何かに使うかもしれないので一覧にしておこう
No カテゴリ メーカー 名称 備考
1 CPU AMD Ryzen 5 3600
2 M/B ASUS TUF B450M-PLUS GAMING MicroATX
3 メモリ Corsair CMK32GX4M2B3000C15 32GB
4 グラボ MSI Radeon RX 570 ARMOR 8G J
5 SSD Crucial CT500MX500SSD1 500GB x2個
6 HDD WD WD4005FZBX WD Black!
7 ケース COOLER MASTER MasterBox NR400 MCB-NR400-KG5N-S00
8 電源 玄人志向 KRPW-N600W/85+ 600W
9-1 モニタ IODATA GigaCrysta EX-LDGCQ271DB WQHD
9-2 モニタ iiyama ProLite XB2783HSU FullHD
10 ODD Pioneer BDR-209
久しぶりのAMDで嬉しい。
これで5年くらい戦えないかな・・・。

CPUこれで良かった?

最初は、グラフィック内蔵の3400Gで、グラボなしと思っていたけど、いろいろ構成を調べていたら気になるページを見つけた。
3400G + TUF B450M-PLUSで、USBが使えない!?
https://picico.net/computer/b450m-ryzen3400g/
えーやだなー。
M/B変えるか?と思ったけど、身の回りのものがASUS化が進行しているので、ASUSにしたかった。なので、3600にして、グラボもつことになった。

ゲーミングPCなの?

PCケースとかM/BとかLEDピカピカ系が多いけど、ちょっと馴染めなかったので、できるだけ落ち着いたものにした。
M/Bにはゲーミングって書いてあるけど
基板も黒で統一されてかっこいいね。
ケースの側面がガラスなのもわかるわ。
マザボのRGBLEDは、初期設定では電源OFF時にもゆっくり点滅するようになっていたけど
BIOSの詳細設定で、電源ON時のみにできたので満足!もちろん点滅しないようにもできる。いいね。

メモリ

相性とかで悩むのも面倒なので、動作確認ずみのやつにした。
https://www.asus.com/jp/Motherboards/TUF-B450M-PLUS-GAMING/HelpDesk_QVL/

モニタ

最初、ViewSonicやJapannextの安いやつで、4Kとかありかなーと思ったけど、自分に合わなかったときのショックが大きいような気がしたので、(自分的に)ワンランク上のGigaCrysta EX-LDGCQ271DBにした。その代わりWQHDだけどね。

良かった点

  • ドット抜けなさそう
  • 設定を特に変えなくても大丈夫そうな色味
  • Displayportケーブル付属がありがたい
  • シンプルなデザイン
  • 高さ調整できる!マルチディスプレイではありがたい

悪かった点

  • 隣のモニタもこれにしたくなる
今の自分には、このサイズが一番しっくり来た。とてもいい感じ。

SDDとHDD

OSとデータを分けたかったから500GBを2個。
それに加えて、バックアップ用に4TBのHDD。WD Black。
これは何かに使ってたやつ。なんだっけ?
コリコリうるさいから、外すかも。

環境の移行(OSのインストール)

もともとMint18系を使っていて、気軽に19にしようとしていたことを思いだした。
今回は19.3 Cinnamonにした、GPU積んでるし。

インストール

昔と違って、CDやDVDでインストールディスク作らなくて良いんだね。USBメモリをブータブルメディアとして使う。
isoをもってきて
sudo mintstick -m iso
イメージ: /linuxmint-19.3-cinnamon-64bit.iso
USB メモリ: /dev/sda
/linuxmint-19.3-cinnamon-64bit.iso から /dev/sda にコピーを開始しています
イメージの書き込みに成功しました。
でOK

設定

今のところ、マルチディスプレイの設定くらい。

GPUのベンチマーク

せっかくGPU積んだので、ベンチマーク取ってみた。
https://benchmark.unigine.com/heaven?lang=en
すると、、、

これって、低いよね多分。。。GPU modelがUnknownになっているし

AMDのグラフィックドライバ

AMDのグラフィックドライバを入れてみる
https://www.amd.com/ja/support/previous-drivers/graphics/radeon-500-series/radeon-rx-500-series/radeon-rx-570
https://amdgpu-install.readthedocs.io/en/latest/install-installing.html
https://gihyo.jp/admin/serial/01/ubuntu-recipe/0471
手順どおりやって
sudo ./amdgpu-pro-install
deb [ trusted=yes ] file:/var/opt/amdgpu-pro-local/ ./
((中略))
vulkan-amdgpu-pro:i386 はすでに最新バージョン (19.30-934563) です。
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
WARNING: amdgpu dkms failed for running kernel
あれ、なんか失敗している。
https://askubuntu.com/questions/1040474/warning-amdgpu-dkms-failed-for-running-kernel-on-both-16-04-18-04
https://unix.stackexchange.com/questions/501267/how-to-fix-amdgpu-dkms-failed-for-running-kernel-when-installing-amd-gpu-drive
linux-headersがいるの?
uname -a
Linux drakorange 5.3.0-40-generic #32~18.04.1-Ubuntu SMP Mon Feb 3 14:05:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Linux 5.3.0-40で、Ubuntuの18.04.1ベースなのね。
sudo apt-get install linux-image-5.3.0-40-generic linux-modules-extra-5.3.0-40-generic linux-headers-5.3.0-40-generic
状況変わらないねー。
3/16時点で、最新は
Radeon™ Software for Linux® Driver for Ubuntu 18.04.3
Revision Number 19.50
はこちらのバージョンよりも新しい
少し前で試してみる。
Radeon™ Software for Linux® Driver for Ubuntu 18.04.1
Revision Number 18.50
これも試したけど変わらず。
さらに探してたら
https://askubuntu.com/questions/1212256/warning-amdgpu-dkms-failed-for-running-kernel-solved
Linux 5.x系では対応してないの?
うーん。今そんなに困っていないから、しばらく様子見しようかな。

ソフト

今、無いと困るものを書き出してみた
No 名称 用途 状況
1 git バージョン管理、いろいろなものを管理してもらっている
2 VScode エディタ、プログラムからブロクまで
3 VirtualBox 開発環境やWindows
4 FreeCAD 次回
5 3Dプリンタ用ソフト 次回
6 Dropbox, Nextcloud バックアップ・データ共有 今はブラウザでいいや
7 Openwrt開発環境 趣味 次回
8 kdenlive 動画編集、子供の成長記録的な、他に使いやすいものがあればそれでもいい

git、gitk

これが無いと始まらないってわけじゃないけど
sudo apt install git gitk
試しに、ブログのリポジトリをもってくる
git clone http://192.168.1.25:3000/C2Cblog.git

VScode

何かと使うからね。
オフィシャルサイトからdebパッケージを持ってきてインストール
エクステンション何入れていたっけか?
markdownのやつか
http://continue-to-challenge.blogspot.com/2018/11/vscodemarkdown_28.html
とりあえずはこれで、OKとする。

VirtualBox

インストール

公式の手順どおり
/etc/apt/sources.list
deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian bionic contrib
それから
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt install virtualbox-6.1
あとは、エクステンションを導入する

環境の引っ越し-export

さて、問題はどうやってデータを引っ越すか
もとのPCにはXwindowで入れないからGUIのvboxマネージャー使えない
だったらCUIがあるじゃないか
$ vboxmanage list vms
"Win10" {7fcc3555-xxxx-xxxx-xxxx-6613f22ff28d}
"Win7" {a0758424-xxx-xxxx-xxxx-d075ecb8daa5}
"Win10 のクローン" {8fb419a2-xxx-xxxx-xxxx-98e0392d2209}
試しにexportしてみる
$ vboxmanage export "Win10" -o win10.ova
0%...
すべて終わるのに1時間くらいかかった。約60GB

環境の引っ越し-import

ovaファイルを新しいPCに持ってきて、テストを行ってみる
$ vboxmanage import --dry-run win10.ova
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Interpreting /media/****/52c3dc1a-****-****-****-759c749d1e19/win10.ova...
OK.
Disks:
  vmdisk2 42949672960 -1 http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized win10-disk002.vmdk -1 -1 

Virtual system 0:
 0: Suggested OS type: "Windows10_64"
    (change with "--vsys 0 --ostype <type>"; use "list ostypes" to list all possible values)
 1: Suggested VM name "Win10"
    (change with "--vsys 0 --vmname <name>")
 2: Suggested VM group "/"
    (change with "--vsys 0 --group <group>")
 3: Suggested VM settings file name "/home/****/VirtualBox VMs/Win10/Win10.vbox"
    (change with "--vsys 0 --settingsfile <filename>")
 4: Suggested VM base folder "/home/****/VirtualBox VMs"
    (change with "--vsys 0 --basefolder <path>")
 5: Number of CPUs: 4
    (change with "--vsys 0 --cpus <n>")
 6: Guest memory: 2048 MB
    (change with "--vsys 0 --memory <MB>")
 7: Sound card (appliance expects "", can change on import)
    (disable with "--vsys 0 --unit 7 --ignore")
 8: USB controller
    (disable with "--vsys 0 --unit 8 --ignore")
 9: Network adapter: orig NAT, config 3, extra slot=0;type=NAT
10: CD-ROM
    (disable with "--vsys 0 --unit 10 --ignore")
11: SATA controller, type AHCI
    (disable with "--vsys 0 --unit 11 --ignore")
12: Hard disk image: source image=win10-disk002.vmdk, target path=win10-disk002.vmdk, controller=11;channel=0
    (change target path with "--vsys 0 --unit 12 --disk path";
    disable with "--vsys 0 --unit 12 --ignore")
[(3)VM settings file name]と[(4)VM base folder]を変更したい
--vsys 0 --settingsfile "/home/****/work/VirtualBox VMs/Win10/Win10.vbox"
--vsys 0 --basefolder "/home/****/work/VirtualBox VMs"
実行結果は省略
大丈夫そうなので、–dry-runを外して実行する。

環境の引っ越し-Virtualboxマネージャー

Virtualboxを起動してみると


あれ、起動できない。
原因は
  • グラフィックスコントローラーがVBoxSVGAになっていない
  • ハードウエア仮想化が有効にできない
    らしい「ハードウエア仮想化」ってBIOSの設定か・・・。

ようやく起動したら、windowsさんがハードウエアが大幅に変わったからライセンス認証ができないと・・・。
インストールメディアひっぱり出してきて、再度プロダクトキー入力したら認証してくれた。
参考
https://bablovia.hatenablog.com/entry/2019/10/01/223852

kdenlive

切り貼りしかしないから、他のソフトでもいいような気がしているけど、環境以降ということで
 apt install kdenlive
で実行すると


となにやら無いよ的なエラーが・・・。
apt install frei0r-plugins dvdauthor
これで起動できた。
GPUアクセラレーションとかはこれから。
今日はここまで