Dockerサービス用のsystemdスクリプトを生成しようとしています。
[Unit]
Description=ScyllaDB 1
After=network-online.target docker.target
Wants=network-online.target systemd-networkd-wait-online.service docker.target
[Service]
Type=notify
Restart=on-failure
RestartSec=10s
User=foo
Group=users
WorkingDirectory=/home/foo/scylladb
ExecStartPre=/usr/bin/docker pull scylladb/scylla
ExecStart=/usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 \
scylladb/scylla --developer-mode 1 --memory 1.5G --smp 3 \
--listen-address 127.0.0.1
# --overprovisioned 1 --seeds 127.0.0.1 --broadcast-address 127.0.1.1
ExecStop=/usr/bin/docker stop scylla1
LimitNOFILE=1048576
ProtectSystem=full
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
私はすでに以下を実行しています。
sudo usermod -aG docker foo
mkdir -p /home/foo/scylla1/commitlog /home/foo/scylla1/data
sudo chown foo:users /home/foo/scylla1
sudo systemctl daemon-reload
編集する:ユーザーを使用して手動でコマンドを実行しようとすると正常に機能しますfoo
が、次を使用するときは次のようにしますsudo systemctl restart scylladb
。
May 17 14:58:55 x systemd[1]: Stopped ScyllaDB 1.
May 17 14:58:55 x systemd[1]: Starting ScyllaDB 1...
May 17 14:58:55 x systemd[1]: scylladb.service: Control process exited, code=exited status=210
May 17 14:58:55 x systemd[1]: Failed to start ScyllaDB 1.
May 17 14:58:55 x systemd[1]: scylladb.service: Unit entered failed state.
May 17 14:58:55 x systemd[1]: scylladb.service: Failed with result 'exit-code'.
手動:
[foo@x ~]$ /usr/bin/docker pull scylladb/scylla
Using default tag: latest
latest: Pulling from scylladb/scylla
93857f76ae30: Already exists
fcf3425de92f: Already exists
a9768670d266: Already exists
eaccce6402ed: Already exists
a564f24ba7ea: Already exists
c1c511852d0b: Already exists
f9c8010402b4: Already exists
654f38ed538a: Already exists
64856b4587d3: Already exists
74fbc1822a2d: Already exists
fdeb9fe209e1: Already exists
243856d4fcb5: Already exists
0b59d050d95e: Already exists
e677bcc6c3d3: Already exists
ca2f175eb91a: Already exists
912e754404b4: Already exists
c80ea560f85c: Already exists
9f2fa2f93fae: Already exists
04cfbbeb59e2: Already exists
a9996b00766d: Already exists
1076dbbc8e7b: Already exists
c4eda4b22480: Already exists
Digest: sha256:9c9d23b9ab9bd392cf647d861edc1f48498f6c7ffd142ab9905c23cc3c463345
Status: Image is up to date for scylladb/scylla:latest
[foo@x ~]$ /usr/bin/docker pull scylladb/scylla^C
[foo@x ~]$ /usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 \
> -d scylladb/scylla --developer-mode 1 --memory 1.5G --smp 3 \
> --listen-address 127.0.0.1
4c6e7685e5297028e582e7c19c75424dbf3160a0e46adb69325993d333dbae7e
[foo@x ~]$ /usr/bin/docker stop scylla1
scylla1
その理由は何ですか?
答え1
明らかに問題は、作業ディレクトリが存在しないために存在しては/home/foo/scylla1
いけないということ/home/foo/scylladb
です。問題の2番目の部分は、1.5G
パラメータが無効または1G
正しく2G
機能していることです。
これは最終システムscylladb.service
ファイルです:
[Unit]
Description=ScyllaDB 1
After=network-online.target docker.target
Wants=network-online.target systemd-networkd-wait-online.service docker.target
[Service]
Type=simple
Restart=on-failure
RestartSec=10s
User=foo
Group=docker
WorkingDirectory=/home/foo/scylla1
ExecStartPre=/usr/bin/docker rm scylla1
ExecStart=/usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 scylladb/scylla --developer-mode 1 --memory 2G --smp 3 --listen-address 127.0.0.1
# --overprovisioned 1 --seeds 127.0.0.1 --broadcast-address 127.0.1.1
ExecStop=/usr/bin/docker stop scylla1
LimitNOFILE=1048576
ProtectSystem=full
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target