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
입니다. 문제의 두 번째 부분은 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