9 | | = DHCP = |
| 9 | = lxc.service = |
| 10 | == A stop job is running == |
| 11 | * lxc.serviceを有効にしないと、ホストOSシャットダウン時にコンテナが自動シャットダウンされず90秒タイムアウト待ちが発生する |
| 12 | * [[Image(lxc-A_stop_job_is_running.png,33%)]] |
| 13 | |
| 14 | * mitty@lxc-host:~$ journalctl |
| 15 | {{{ |
| 16 | Apr 17 22:52:41 lxc-host sudo[1908]: mitty : TTY=pts/0 ; PWD=/home/mitty ; USER=root ; COMMAND=/usr/bin/sh -c poweroff |
| 17 | |
| 18 | (snip) |
| 19 | |
| 20 | Apr 17 22:52:41 lxc-host systemd[529]: Received SIGRTMIN+24 from PID 1913 (kill). |
| 21 | Apr 17 22:52:41 lxc-host systemd[1]: Stopped User Manager for UID 1000. |
| 22 | Apr 17 22:52:42 lxc-host systemd[1]: Started Generate shutdown-ramfs. |
| 23 | Apr 17 22:54:11 lxc-host systemd[1]: session-c1.scope: Stopping timed out. Killing. |
| 24 | Apr 17 22:54:11 lxc-host systemd[1]: Stopped Session c1 of user mitty. |
| 25 | }}} |
| 26 | mitty@test:~$ journalctl |
| 27 | {{{ |
| 28 | Apr 17 22:52:41 test systemd[1]: Received SIGHUP. |
| 29 | Apr 17 22:52:41 test systemd[1]: Received SIGTERM. |
| 30 | Apr 17 22:52:41 test systemd[1]: Reexecuting. |
| 31 | Apr 17 22:52:41 test systemd[1]: systemd 229 running in system mode. (+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN) |
| 32 | Apr 17 22:52:41 test systemd[1]: Detected virtualization lxc. |
| 33 | Apr 17 22:52:41 test systemd[1]: Detected architecture x86-64. |
| 34 | Apr 17 22:52:41 test systemd[1]: Failed to install release agent, ignoring: No such file or directory |
| 35 | }}} |
| 36 | |
| 37 | === コンテナのシャットダウンについて === |
| 38 | * man systemd |
| 39 | {{{ |
| 40 | SIGNALS |
| 41 | SIGTERM |
| 42 | Upon receiving this signal the systemd system manager serializes |
| 43 | its state, reexecutes itself and deserializes the saved state |
| 44 | again. This is mostly equivalent to systemctl daemon-reexec. |
| 45 | |
| 46 | systemd user managers will start the exit.target unit when this |
| 47 | signal is received. This is mostly equivalent to systemctl --user |
| 48 | start exit.target. |
| 49 | |
| 50 | (snip) |
| 51 | |
| 52 | SIGHUP |
| 53 | Reloads the complete daemon configuration. This is mostly |
| 54 | equivalent to systemctl daemon-reload. |
| 55 | |
| 56 | (snip) |
| 57 | |
| 58 | SIGRTMIN+4 |
| 59 | Powers off the machine, starts the poweroff.target unit. This is |
| 60 | mostly equivalent to systemctl start poweroff.target. |
| 61 | |
| 62 | (snip) |
| 63 | |
| 64 | SIGRTMIN+14 |
| 65 | Immediately powers off the machine. |
| 66 | }}} |
| 67 | |
| 68 | * /usr/share/lxc/config/archlinux.common.conf |
| 69 | {{{ |
| 70 | # Set the halt/stop signals |
| 71 | lxc.haltsignal=SIGRTMIN+4 |
| 72 | lxc.stopsignal=SIGRTMIN+14 |
| 73 | }}} |
| 74 | * [https://lists.linuxcontainers.org/pipermail/lxc-devel/2012-May/002468.html (lxc-devel) Shutting down containers properly] |
| 75 | * [https://bbs.archlinux.org/viewtopic.php?id=181032 (Solved) LXC shutdown of archlinux containers not working (lxc-stop) / System Administration / Arch Linux Forums] |
| 76 | |
| 77 | * lxc-stop |
| 78 | * Host |
| 79 | {{{ |
| 80 | Apr 19 22:15:54 lxc-host sudo[589]: mitty : TTY=pts/0 ; PWD=/home/mitty ; USER=root ; COMMAND=/usr/bin/lxc-stop -n test |
| 81 | }}} |
| 82 | * container |
| 83 | {{{ |
| 84 | Apr 19 22:15:54 test systemd[1]: Received SIGRTMIN+4. |
| 85 | Apr 19 22:15:54 test systemd[1]: Stopping User Manager for UID 1000... |
| 86 | Apr 19 22:15:54 test systemd[1]: Stopped target Multi-User System. |
| 87 | }}} |
| 88 | |
| 89 | == systemctl enable lxc.service == |
| 90 | * /usr/lib/systemd/system/lxc.service |
| 91 | {{{ |
| 92 | ExecStart=/usr/lib/lxc/lxc-containers start |
| 93 | ExecStop=/usr/lib/lxc/lxc-containers stop |
| 94 | }}} |
| 95 | * /usr/lib/lxc/lxc-containers |
| 96 | {{{ |
| 97 | # STOPOPTS are stop options. The can be used for anything else to stop. |
| 98 | # If you want to kill containers fast, use -k |
| 99 | STOPOPTS="-a -A -s" |
| 100 | |
| 101 | (snip) |
| 102 | |
| 103 | case "$1" in |
| 104 | |
| 105 | (snip) |
| 106 | |
| 107 | stop) |
| 108 | |
| 109 | (snip) |
| 110 | |
| 111 | "$bindir"/lxc-autostart $STOPOPTS $SHUTDOWNDELAY |
| 112 | }}} |
| 113 | * man lxc-autostart |
| 114 | {{{ |
| 115 | -s,--shutdown |
| 116 | Request a clean shutdown. If a [-t timeout] greater than 0 is |
| 117 | given and the container has not shut down within this period, it |
| 118 | will be killed as with the [-k kill] option. |
| 119 | |
| 120 | (snip) |
| 121 | |
| 122 | -a,--all |
| 123 | Ignore lxc.group and select all auto-started containers. |
| 124 | |
| 125 | -A,--ignore-auto |
| 126 | Ignore the lxc.start.auto flag. Combined with -a, will select |
| 127 | all containers on the system. |
| 128 | }}} |
| 129 | |
| 130 | * mitty@lxc-host:~$ sudo systemctl enable --now lxc.service |
| 131 | {{{ |
| 132 | Created symlink from /etc/systemd/system/multi-user.target.wants/lxc.service to /usr/lib/systemd/system/lxc.service. |
| 133 | }}} |
| 134 | * mitty@lxc-host:~$ journalctl |
| 135 | {{{ |
| 136 | Apr 19 23:22:34 lxc-host sudo[573]: mitty : TTY=pts/0 ; PWD=/home/mitty ; USER=root ; COMMAND=/usr/bin/sh -c poweroff |
| 137 | |
| 138 | (snip) |
| 139 | |
| 140 | Apr 19 23:22:34 lxc-host systemd[1]: Stopped LXC Container Initialization and Autoboot Code. |
| 141 | }}} |
| 142 | * mitty@test:~$ journalctl |
| 143 | {{{ |
| 144 | Apr 19 23:22:34 test systemd[1]: Received SIGTERM. |
| 145 | Apr 19 23:22:34 test systemd[1]: Reexecuting. |
| 146 | Apr 19 23:22:34 test systemd[1]: systemd 229 running in system mode. (+PAM -AUDIT -SELINUX -IMA -APPARMOR +SMACK -SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN) |
| 147 | Apr 19 23:22:34 test systemd[1]: Detected virtualization lxc. |
| 148 | Apr 19 23:22:34 test systemd[1]: Detected architecture x86-64. |
| 149 | Apr 19 23:22:34 test systemd[1]: Failed to install release agent, ignoring: No such file or directory |
| 150 | Apr 19 23:22:34 test systemd[1]: Received SIGHUP. |
| 151 | Apr 19 23:22:34 test systemd[1]: Received SIGRTMIN+4. |
| 152 | Apr 19 23:22:34 test systemd[1]: Reloading. |
| 153 | Apr 19 23:22:34 test systemd[1]: Stopped target Multi-User System. |
| 154 | |
| 155 | (snip) |
| 156 | |
| 157 | Apr 19 23:22:34 test systemd[1]: Shutting down. |
| 158 | Apr 19 23:22:34 test systemd-journald[13]: Journal stopped |
| 159 | }}} |
| 160 | |
| 161 | = dhcpcd.service = |