参考文献

Systemdってなに

古き良き initd

Unit

Unit の依存関係

target などの固定的な依存関係

serivceのように ON/OFF を切り替えたい場合の依存関係

System による Unit 起動順序

Unit の書き方

systemctl コマンド

service の状態確認

core@coreos1 /usr/lib/systemd/system $ systemctl status ntpd.service
● ntpd.service - Network Time Service
   Loaded: loaded (/usr/lib64/systemd/system/ntpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2015-02-04 12:23:33 UTC; 1h 19min ago
 Main PID: 455 (ntpd)
   CGroup: /system.slice/ntpd.service
           └─455 /usr/sbin/ntpd -g -n -f /var/lib/ntp/ntp.drift -u ntp:ntp

Feb 04 12:23:33 coreos1 ntpd[455]: Listening on routing socket on fd #21 for interface updates
Feb 04 12:23:33 coreos1 ntpd[455]: 4 Feb 12:23:33 ntpd[455]: Listening on routing socket on fd #21 for i...dates
Feb 04 12:23:34 coreos1 ntpd[455]: bind(24) AF_INET6 fe80::20c:29ff:fe16:dd7e%2%2#123 flags 0x11 failed:...dress
Feb 04 12:23:34 coreos1 ntpd[455]: unable to create socket on ens192 (6) for fe80::20c:29ff:fe16:dd7e%2#123
Feb 04 12:23:34 coreos1 ntpd[455]: failed to init interface for address fe80::20c:29ff:fe16:dd7e%2
Feb 04 12:23:34 coreos1 ntpd[455]: 4 Feb 12:23:34 ntpd[455]: bind(24) AF_INET6 fe80::20c:29ff:fe16:dd7e%...dress
Feb 04 12:23:34 coreos1 ntpd[455]: 4 Feb 12:23:34 ntpd[455]: unable to create socket on ens192 (6) for f...2#123
Feb 04 12:23:34 coreos1 ntpd[455]: 4 Feb 12:23:34 ntpd[455]: failed to init interface for address fe80::...d7e%2
Feb 04 12:23:36 coreos1 ntpd[455]: Listen normally on 7 ens192 [fe80::20c:29ff:fe16:dd7e%2]:123
Feb 04 12:23:36 coreos1 ntpd[455]: 4 Feb 12:23:36 ntpd[455]: Listen normally on 7 ens192 [fe80::20c:29ff...]:123
Hint: Some lines were ellipsized, use -l to show in full.

基本的なステータスと、直近の syslog が表示される

service の 開始・停止・再起動

# systemctl start sshd.service
# systemctl stop sshd.service
# systemctl restart sshd.service
# systemctl reload sshd.service

service が OS 起動時に起動するかの 有効・無効

service の有効・無効の状態確認

core@coreos1 /usr/lib/systemd/system $ systemctl list-unit-files --type=service
UNIT FILE                              STATE
addon-config@.service                  static
addon-run@.service                     static
autovt@.service                        disabled
blk-availability.service               disabled
clean-ca-certificates.service          static
console-getty.service                  disabled
console-shell.service                  disabled
container-getty@.service               static
coreos-setup-environment.service       disabled
coreos-tmpfiles.service                static
dbus-org.freedesktop.hostname1.service static
dbus-org.freedesktop.locale1.service   static
dbus-org.freedesktop.login1.service    static
dbus-org.freedesktop.machine1.service  static
dbus-org.freedesktop.resolve1.service  disabled
dbus-org.freedesktop.timedate1.service static
dbus.service                           static
debug-shell.service                    disabled
dhcpcd.service                         disabled
dm-event.service                       disabled
docker.service                         disabled
early-docker.service                   disabled
emergency.service                      static
etcd.service                           static
extend-filesystems.service             static
flanneld.service                       static
fleet.service                          static
fstrim.service                         static
getty@.service                         disabled
git-daemon@.service                    static
initrd-cleanup.service                 static
initrd-parse-etc.service               static
initrd-switch-root.service             static
initrd-udevadm-cleanup-db.service      static
ip6tables-restore.service              disabled

default.service からの依存関係のある serivice の状態の確認

core@coreos1 /usr/lib/systemd/system $ systemctl list-units --type=service
UNIT                                     LOAD   ACTIVE     SUB          DESCRIPTION
dbus.service                             loaded active     running      D-Bus System Message Bus
etcd.service                             loaded active     running      etcd
fleet.service                            loaded active     running      fleet daemon
getty@tty1.service                       loaded active     running      Getty on tty1
kmod-static-nodes.service                loaded active     exited       Create list of required static device no
locksmithd.service                       loaded activating auto-restart Cluster reboot manager
ntpd.service                             loaded active     running      Network Time Service
polkit.service                           loaded active     running      Authorization Manager
serial-getty@ttyS0.service               loaded active     running      Serial Getty on ttyS0
sshd-keygen.service                      loaded active     exited       Generate sshd host keys
sshd@3-192.168.38.101:22-192.168.38.1:63155.service loaded active     running      OpenSSH per-connection server
system-cloudinit@usr-share-oem-cloud\x2dconfig.yml.service loaded active     exited       Load cloud-config from
systemd-journal-flush.service            loaded active     exited       Flush Journal to Persistent Storage
systemd-journald.service                 loaded active     running      Journal Service
systemd-logind.service                   loaded active     running      Login Service
systemd-networkd.service                 loaded active     running      Network Service
systemd-random-seed.service              loaded active     exited       Load/Save Random Seed
systemd-resolved.service                 loaded active     running      Network Name Resolution
systemd-sysctl.service                   loaded active     exited       Apply Kernel Variables
systemd-tmpfiles-setup-dev.service       loaded active     exited       Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service           loaded active     exited       Create Volatile Files and Directories
systemd-udev-settle.service              loaded active     exited       udev Wait for Complete Device Initializa
systemd-udev-trigger.service             loaded active     exited       udev Coldplug all Devices
systemd-udevd.service                    loaded active     running      udev Kernel Device Manager
systemd-update-utmp.service              loaded active     exited       Update UTMP about System Boot/Shutdown
systemd-user-sessions.service            loaded active     exited       Permit User Sessions
systemd-vconsole-setup.service           loaded active     exited       Setup Virtual Console
update-engine.service                    loaded active     running      Update Engine

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.

28 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.

default.service からの依存関係の調査

core@coreos1 /usr/lib/systemd/system $ systemctl list-dependencies
default.target
● ├─dbus.service
● ├─extend-filesystems.service
● ├─issuegen.service
● ├─locksmithd.service
● ├─motdgen.path
● ├─motdgen.service
● ├─motdgen.timer
● ├─ntpd.service
● ├─ssh-key-proc-cmdline.service
● ├─sshd-keygen.service
● ├─systemd-ask-password-wall.path
● ├─systemd-logind.service
● ├─systemd-networkd.service
● ├─systemd-resolved.service
● ├─systemd-user-sessions.service
● ├─update-engine-stub.timer
● ├─update-engine.service
● ├─basic.target
● │ ├─paths.target
● │ ├─slices.target
● │ │ ├─-.slice
● │ │ └─system.slice
● │ ├─sockets.target
● │ │ ├─dbus.socket
● │ │ ├─docker.socket
● │ │ ├─sshd.socket
● │ │ ├─systemd-initctl.socket
● │ │ ├─systemd-journald-audit.socket
● │ │ ├─systemd-journald-dev-log.socket
● │ │ ├─systemd-journald.socket
● │ │ ├─systemd-shutdownd.socket
● │ │ ├─systemd-udevd-control.socket
● │ │ └─systemd-udevd-kernel.socket
● │ ├─sysinit.target
● │ │ ├─clean-ca-certificates.service
● │ │ ├─coreos-tmpfiles.service
● │ │ ├─dev-hugepages.mount
● │ │ ├─dev-mqueue.mount
● │ │ ├─kmod-static-nodes.service
● │ │ ├─ldconfig.service
● │ │ ├─proc-sys-fs-binfmt_misc.automount
● │ │ ├─sys-fs-fuse-connections.mount
● │ │ ├─sys-kernel-config.mount
● │ │ ├─sys-kernel-debug.mount
● │ │ ├─systemd-ask-password-console.path
● │ │ ├─systemd-binfmt.service
● │ │ ├─systemd-journal-catalog-update.service
● │ │ ├─systemd-journal-flush.service
● │ │ ├─systemd-journald.service
● │ │ ├─systemd-machine-id-commit.service
● │ │ ├─systemd-modules-load.service
● │ │ ├─systemd-random-seed.service
● │ │ ├─systemd-sysctl.service
● │ │ ├─systemd-sysusers.service
● │ │ ├─systemd-tmpfiles-setup-dev.service
● │ │ ├─systemd-tmpfiles-setup.service
● │ │ ├─systemd-udev-hwdb-update.service
● │ │ ├─systemd-udev-trigger.service
● │ │ ├─systemd-udevd.service
● │ │ ├─systemd-update-done.service
● │ │ ├─systemd-update-utmp.service
● │ │ ├─systemd-vconsole-setup.service
● │ │ ├─update-ca-certificates.service
● │ │ ├─xenserver-pv-version.service
● │ │ ├─cryptsetup.target
● │ │ ├─local-fs.target
● │ │ │ ├─lvm2-activation-early.service
● │ │ │ ├─lvm2-activation.service
● │ │ │ ├─media.mount
● │ │ │ ├─proc-xen.mount
● │ │ │ ├─remount-root.service
● │ │ │ ├─systemd-remount-fs.service
● │ │ │ ├─tmp.mount
● │ │ │ └─usr-share-oem.mount
● │ │ └─swap.target
● │ └─timers.target
● │   └─systemd-tmpfiles-clean.timer
● ├─getty.target
● │ ├─getty@tty1.service
● │ └─serial-getty@ttyS0.service
● ├─remote-fs.target
● │ └─lvm2-activation-net.service
● ├─system-config.target
● │ ├─coreos-setup-environment.service
● │ └─system-cloudinit@usr-share-oem-cloud\x2dconfig.yml.service
● └─user-config.target
●   ├─user-cloudinit-proc-cmdline.service
●   ├─user-cloudinit@var-lib-coreos\x2dinstall-user_data.path
●   ├─user-configdrive.path
●   └─system-config.target
●     ├─coreos-setup-environment.service
●     └─system-cloudinit@usr-share-oem-cloud\x2dconfig.yml.service

Computer


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS   sitemap
Last-modified: 2015-04-05 (日) 22:28:49 (3531d)
Short-URL:
ISBN10
ISBN13
9784061426061