cn:ccr:formazione:centos7:2018-11:systemd-ctl-soluzioni
Table of Contents
systemd (esercitazione)
Esercitazioni sul modulo systemd.
Parte 1: Visualizzazione dello stato del sistema e proprieta' delle units
- Visualizzazione dello stato del sistema.
[root@localhost ~]# systemctl status ● localhost.localdomain State: degraded Jobs: 0 queued Failed: 1 units Since: Mon 2018-11-26 07:22:35 EST; 22min ago ... │ └─1281 /sbin/agetty --noclear tty1 linux └─systemd-journald.service └─459 /usr/lib/systemd/systemd-journald [root@localhost ~]#
- Identificazione della unit che ha fallito (a dopo la soluzione del problema)
root@localhost ~]# systemctl list-units --failed UNIT LOAD ACTIVE SUB DESCRIPTION ● rngd.service loaded failed failed Hardware RNG Entropy Gatherer Daemon 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. 1 loaded units listed. Pass --all to see loaded but inactive units, too. To show all installed unit files use 'systemctl list-unit-files'. [root@localhost ~]# systemctl status rngd ● rngd.service - Hardware RNG Entropy Gatherer Daemon Loaded: loaded (/usr/lib/systemd/system/rngd.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Mon 2018-11-26 07:22:55 EST; 23min ago Process: 760 ExecStart=/sbin/rngd -f (code=exited, status=1/FAILURE) Main PID: 760 (code=exited, status=1/FAILURE) Nov 26 07:22:51 localhost.localdomain systemd[1]: Started Hardware RNG Entropy Gatherer Daemon. Nov 26 07:22:51 localhost.localdomain systemd[1]: Starting Hardware RNG Entropy Gatherer Daemon... Nov 26 07:22:51 localhost.localdomain rngd[760]: Failed to init entropy source 0: Hardware RNG Device Nov 26 07:22:51 localhost.localdomain rngd[760]: Failed to init entropy source 1: TPM RNG Device Nov 26 07:22:51 localhost.localdomain rngd[760]: Failed to init entropy source 2: Intel RDRAND Instruction RNG Nov 26 07:22:51 localhost.localdomain rngd[760]: can't open any entropy source Nov 26 07:22:51 localhost.localdomain rngd[760]: Maybe RNG device modules are not loaded Nov 26 07:22:55 localhost.localdomain systemd[1]: rngd.service: main process exited, code=exited, status=1/FAILURE Nov 26 07:22:55 localhost.localdomain systemd[1]: Unit rngd.service entered failed state. Nov 26 07:22:55 localhost.localdomain systemd[1]: rngd.service failed. [root@localhost ~]#
- Visualizzazione di tutte le unit ed identificazione di eventuali problemi (units not found).
Le unit not found sono unit non installate (no unit file) ma presenti in dipendenze di altre unit[root@localhost ~]# systemctl list-units -a UNIT LOAD ACTIVE SUB DESCRIPTION proc-sys-fs-binfmt_misc.automount loaded active waiting Arbitrary Executable File Formats File System Automount Point dev-block-8:2.device loaded active plugged LVM PV AAHlBZ-3dLf-gVNY-C5eK-ksMU-dAvH-0L6awx on /dev/sda2 2 ... vmtoolsd.service loaded inactive dead Service for virtual machines hosted on VMware ● ypbind.service not-found inactive dead ypbind.service ● yppasswdd.service not-found inactive dead yppasswdd.service ● ypserv.service not-found inactive dead ypserv.service ● ypxfrd.service not-found inactive dead ypxfrd.service ...
- Verificare che la unit ypbind.service non e' installata (visualizzare stato e unit file)
[root@localhost ~]# systemctl status ypbind.service Unit ypbind.service could not be found. [root@localhost ~]#
- Cercare la unit che riporta ypbind.service tra le sue dipendenze
[root@localhost ~]# systemctl list-dependencies --after ypbind.service ypbind.service ● └─rhel-domainname.service [root@localhost ~]#
Parte 2: Stato dei servizi: start/stop/ena/disa
- Visualizzare lo stato di httpd
[root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:httpd(8) man:apachectl(8) [root@localhost ~]#
- Far partire httpd, e visualizzare il suo stato
[root@localhost ~]# systemctl start httpd [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 07:52:25 EST; 1s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2248 (httpd) Status: "Processing requests..." Tasks: 6 CGroup: /system.slice/httpd.service ├─2248 /usr/sbin/httpd -DFOREGROUND ├─2249 /usr/sbin/httpd -DFOREGROUND ├─2250 /usr/sbin/httpd -DFOREGROUND ├─2251 /usr/sbin/httpd -DFOREGROUND ├─2252 /usr/sbin/httpd -DFOREGROUND └─2253 /usr/sbin/httpd -DFOREGROUND Nov 26 07:52:25 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 07:52:25 localhost.localdomain httpd[2248]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 07:52:25 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
- Abilitare httpd e visualizzare il suo stato
[root@localhost ~]# systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 07:52:25 EST; 37s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2248 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─2248 /usr/sbin/httpd -DFOREGROUND ├─2249 /usr/sbin/httpd -DFOREGROUND ├─2250 /usr/sbin/httpd -DFOREGROUND ├─2251 /usr/sbin/httpd -DFOREGROUND ├─2252 /usr/sbin/httpd -DFOREGROUND └─2253 /usr/sbin/httpd -DFOREGROUND Nov 26 07:52:25 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 07:52:25 localhost.localdomain httpd[2248]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 07:52:25 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
- Riconfigurare lo stato di abilitazione di httpd al preset
[root@localhost ~]# systemctl preset httpd Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service. [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 07:52:25 EST; 1min 37s ago Docs: man:httpd(8) man:apachectl(8) Main PID: 2248 (httpd) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" CGroup: /system.slice/httpd.service ├─2248 /usr/sbin/httpd -DFOREGROUND ├─2249 /usr/sbin/httpd -DFOREGROUND ├─2250 /usr/sbin/httpd -DFOREGROUND ├─2251 /usr/sbin/httpd -DFOREGROUND ├─2252 /usr/sbin/httpd -DFOREGROUND └─2253 /usr/sbin/httpd -DFOREGROUND Nov 26 07:52:25 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 07:52:25 localhost.localdomain httpd[2248]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 07:52:25 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]# systemctl stop httpd [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) Docs: man:httpd(8) man:apachectl(8) Nov 26 07:52:25 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 07:52:25 localhost.localdomain httpd[2248]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 07:52:25 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Nov 26 07:54:10 localhost.localdomain systemd[1]: Stopping The Apache HTTP Server... Nov 26 07:54:11 localhost.localdomain systemd[1]: Stopped The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
Parte 3: target units
- Visualizzare la default target unit
[root@localhost ~]# systemctl get-default multi-user.target [root@localhost ~]#
- Visualizzare le dipendenze di multi-target dirette e inverse
[root@localhost ~]# systemctl list-dependencies multi-user.target multi-user.target ● ├─abrt-ccpp.service ● ├─abrt-oops.service ● ├─abrt-vmcore.service ... [root@localhost ~]# systemctl list-dependencies multi-user.target --reverse multi-user.target ● └─graphical.target [root@localhost ~]#
- Visualizzare la lista di link delle unit wanted da multi-user.target
[root@localhost ~]# ls -l -1 /etc/systemd/system/multi-user.target.wants/ total 0 lrwxrwxrwx. 1 root root 41 Nov 13 08:00 abrt-ccpp.service -> /usr/lib/systemd/system/abrt-ccpp.service lrwxrwxrwx. 1 root root 37 Nov 13 08:00 abrtd.service -> /usr/lib/systemd/system/abrtd.service lrwxrwxrwx. 1 root root 41 Nov 13 08:00 abrt-oops.service -> /usr/lib/systemd/system/abrt-oops.service ... [root@localhost ~]# ls -l -1 /lib/systemd/system/multi-user.target.wants/ total 0 lrwxrwxrwx. 1 root root 15 Nov 13 05:55 dbus.service -> ../dbus.service lrwxrwxrwx. 1 root root 15 Nov 13 07:54 getty.target -> ../getty.target lrwxrwxrwx. 1 root root 24 Nov 13 05:55 plymouth-quit.service -> ../plymouth-quit.service lrwxrwxrwx. 1 root root 29 Nov 13 05:55 plymouth-quit-wait.service -> ../plymouth-quit-wait.service lrwxrwxrwx. 1 root root 33 Nov 13 07:54 systemd-ask-password-wall.path -> ../systemd-ask-password-wall.path
- Andare in graphical target
[root@localhost ~]# systemctl isolate graphical.target [root@localhost ~]#
- Creare una snapshot con httpd e mysqld attivi
[root@localhost ~]# systemctl start httpd [root@localhost ~]# systemctl start mariadb.service [root@localhost ~]# systemctl snapshot snap1 snap1.snapshot [root@localhost ~]#
- Spostarsi tra multi-user target e snapshot e verificare che i servizi si attivano e disattivano
[root@localhost ~]# systemctl isolate multi-user [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: inactive (dead) since Mon 2018-11-26 14:00:02 CET; 5s ago Docs: man:httpd(8) man:apachectl(8) Process: 3446 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS) Process: 2903 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS) Main PID: 2903 (code=exited, status=0/SUCCESS) Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec" Nov 26 13:58:14 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 13:58:14 localhost.localdomain httpd[2903]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 13:58:14 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Nov 26 14:00:01 localhost.localdomain systemd[1]: Stopping The Apache HTTP Server... Nov 26 14:00:02 localhost.localdomain systemd[1]: Stopped The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]# systemctl status mariadb ● mariadb.service - MariaDB database server Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled) Active: inactive (dead) since Mon 2018-11-26 14:00:05 CET; 9s ago Process: 3199 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS) Process: 3198 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS) Process: 3119 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS) Main PID: 3198 (code=exited, status=0/SUCCESS) Nov 26 13:58:54 localhost.localdomain mariadb-prepare-db-dir[3119]: The latest information about MariaDB is available at http://mariadb.org/. Nov 26 13:58:54 localhost.localdomain mariadb-prepare-db-dir[3119]: You can find additional information about the MySQL part at: Nov 26 13:58:54 localhost.localdomain mariadb-prepare-db-dir[3119]: http://dev.mysql.com Nov 26 13:58:54 localhost.localdomain mariadb-prepare-db-dir[3119]: Consider joining MariaDB's strong and vibrant community: Nov 26 13:58:54 localhost.localdomain mariadb-prepare-db-dir[3119]: https://mariadb.org/get-involved/ Nov 26 13:58:54 localhost.localdomain mysqld_safe[3198]: 181126 13:58:54 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'. Nov 26 13:58:54 localhost.localdomain mysqld_safe[3198]: 181126 13:58:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql Nov 26 13:58:56 localhost.localdomain systemd[1]: Started MariaDB database server. Nov 26 14:00:01 localhost.localdomain systemd[1]: Stopping MariaDB database server... Nov 26 14:00:05 localhost.localdomain systemd[1]: Stopped MariaDB database server. [root@localhost ~]# systemctl isolate snap1.snapshot [root@localhost ~]# systemctl status httpd ● httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 14:03:21 CET; 8s ago Docs: man:httpd(8) man:apachectl(8) Process: 3446 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS) Main PID: 3583 (httpd) Status: "Processing requests..." Tasks: 6 CGroup: /system.slice/httpd.service ├─3583 /usr/sbin/httpd -DFOREGROUND ├─3644 /usr/sbin/httpd -DFOREGROUND ├─3645 /usr/sbin/httpd -DFOREGROUND ├─3646 /usr/sbin/httpd -DFOREGROUND ├─3647 /usr/sbin/httpd -DFOREGROUND └─3648 /usr/sbin/httpd -DFOREGROUND Nov 26 14:03:21 localhost.localdomain systemd[1]: Starting The Apache HTTP Server... Nov 26 14:03:21 localhost.localdomain httpd[3583]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.l...s message Nov 26 14:03:21 localhost.localdomain systemd[1]: Started The Apache HTTP Server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]#
- Andare in default target e rimuovere la snapshot
[root@localhost ~]# systemctl default [root@localhost ~]# systemctl delete snap1.snapshot [root@localhost ~]#
Parte 4: unit files
In /root/ses c'e' una applicazione che implementa un servizio (Simple Echo Service) che si mette in ascolto
sulla porta TCP 0.0.0.0:5555.
Provate ad eseguirlo interattivamente:
su una finestra eseguite: # /root/ses/ses
su una seconda finestra eseguite # telnet 127.0.0.1 5555
L'esercitazione consiste nei seguenti punti:
- Creare uno unit file per far eseguire ses tramite systemd (includere configuraizone per fare restart in 30 secondi)
[root@localhost ses]# cat ses.service [Unit] Description=SES Simple Echo Service # needed? #Wants=ses.socket #After=ses.socket [Service] Type=simple ExecStart=/root/ses/ses Restart=always RestartSec=30s #[Install] #WantedBy=multi-user.target [root@localhost ses]# cp ses.service /etc/systemd/system/ [root@localhost ses]# systemctl status ses ● ses.service - SES Simple Echo Service Loaded: loaded (/etc/systemd/system/ses.service; static; vendor preset: disabled) Active: inactive (dead) Nov 26 14:14:32 localhost.localdomain systemd[1]: [/etc/systemd/system/ses.service:1] Assignment outside of section. Ignoring. Nov 26 14:14:32 localhost.localdomain systemd[1]: [/etc/systemd/system/ses.service:18] Missing '='. Nov 26 14:16:23 localhost.localdomain systemd[1]: [/etc/systemd/system/ses.service:1] Assignment outside of section. Ignoring. [root@localhost ses]# netstat -nap | grep 5555 [root@localhost ses]# systemctl start ses [root@localhost ses]# netstat -nap | grep 5555 tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN 4603/ses [root@localhost ses]#
[root@localhost ~]# telnet 127.0.0.1 5555 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Welcome to the Simple Echo Service. Type "quit" to close connection, "bigquit" to quit the service. ciao ciao bigquit Connection closed by foreign host.
- Creare unit files per far eseguire ses da systemd tramite socket-based activation
[root@localhost ~]# cat ses.socket [Unit] Description=Simple Echo Server Activation Socket [Socket] ListenStream=0.0.0.0:5555 [Install] WantedBy=sockets.target [root@localhost ~]# cat ses.service [Unit] Description=SES Simple Echo Service # needed? Wants=ses.socket After=ses.socket [Service] Type=simple ExecStart=/root/ses/ses #[Install] #WantedBy=multi-user.target [root@localhost ~]# cp -f ses.socket ses.service /etc/systemd/system/ cp: overwrite ‘/etc/systemd/system/ses.service’? y [root@localhost ~]# systemctl status ses.socket ● ses.socket - Simple Echo Server Activation Socket Loaded: loaded (/etc/systemd/system/ses.socket; disabled; vendor preset: disabled) Active: inactive (dead) Listen: 0.0.0.0:5555 (Stream) [root@localhost ~]# systemctl enable ses.socket Created symlink from /etc/systemd/system/sockets.target.wants/ses.socket to /etc/systemd/system/ses.socket. [root@localhost ~]# systemctl start ses.socket [root@localhost ~]# systemctl status ses.socket ● ses.socket - Simple Echo Server Activation Socket Loaded: loaded (/etc/systemd/system/ses.socket; enabled; vendor preset: disabled) Active: active (listening) since Mon 2018-11-26 16:50:55 CET; 4s ago Listen: 0.0.0.0:5555 (Stream) Nov 26 16:50:55 localhost.localdomain systemd[1]: Listening on Simple Echo Server Activation Socket. Nov 26 16:50:55 localhost.localdomain systemd[1]: Starting Simple Echo Server Activation Socket. [root@localhost ~]# netstat -napt | grep 5555 tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN 1/systemd [root@localhost ~]#
[root@localhost ~]# telnet 127.0.0.1 5555 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. Welcome to the Simple Echo Service. Type "quit" to close connection, "bigquit" to quit the service.
[root@localhost ~]# netstat -napt | grep 5555 tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN 1/systemd tcp 0 0 127.0.0.1:5555 127.0.0.1:41130 ESTABLISHED 15197/ses tcp 0 0 127.0.0.1:41130 127.0.0.1:5555 ESTABLISHED 15196/telnet [root@localhost ~]# systemctl status ses ● ses.service - SES Simple Echo Service Loaded: loaded (/etc/systemd/system/ses.service; static; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 16:53:56 CET; 2min 34s ago Main PID: 15197 (ses) Tasks: 1 CGroup: /system.slice/ses.service └─15197 /root/ses/ses Nov 26 16:53:56 localhost.localdomain systemd[1]: Started SES Simple Echo Service. Nov 26 16:53:56 localhost.localdomain systemd[1]: Starting SES Simple Echo Service... [root@localhost ~]#
- Creare uno unit file per far eseguire ses da systemd tramite path-based activation
[root@localhost ses]# cat ses.service [Unit] Description=SES Simple Echo Service [Service] Type=simple ExecStart=/root/ses/ses [root@localhost ses]# cat ses.path [Unit] Description=Simple Echo Server Activation Path [Path] PathExists=/root/ses/activate [root@localhost ses]# cp ses.service ses.path /etc/systemd/system/ [root@localhost ses]# systemctl status ses.path ● ses.path - Simple Echo Server Activation Path Loaded: loaded (/etc/systemd/system/ses.path; static; vendor preset: disabled) Active: inactive (dead) [root@localhost ses]# systemctl start ses.path [root@localhost ses]# systemctl status ses.path ● ses.path - Simple Echo Server Activation Path Loaded: loaded (/etc/systemd/system/ses.path; static; vendor preset: disabled) Active: active (waiting) since Mon 2018-11-26 17:07:41 CET; 2s ago Nov 26 17:07:41 localhost.localdomain systemd[1]: Started Simple Echo Server Activation Path. Nov 26 17:07:41 localhost.localdomain systemd[1]: Starting Simple Echo Server Activation Path. [root@localhost ses]# systemctl status ses.service ● ses.service - SES Simple Echo Service Loaded: loaded (/etc/systemd/system/ses.service; static; vendor preset: disabled) Active: inactive (dead) since Mon 2018-11-26 16:57:06 CET; 11min ago ... [root@localhost ses]# netstat -napt | grep 5555 [root@localhost ses]# touch /root/ses/activate [root@localhost ses]# netstat -napt | grep 5555 tcp 0 0 0.0.0.0:5555 0.0.0.0:* LISTEN 15562/ses [root@localhost ses]# systemctl status ses.service ● ses.service - SES Simple Echo Service Loaded: loaded (/etc/systemd/system/ses.service; static; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 17:09:40 CET; 6s ago Main PID: 15562 (ses) Tasks: 1 CGroup: /system.slice/ses.service └─15562 /root/ses/ses Nov 26 17:09:40 localhost.localdomain systemd[1]: Started SES Simple Echo Service. Nov 26 17:09:40 localhost.localdomain systemd[1]: Starting SES Simple Echo Service... [root@localhost ses]# rm /root/ses/activate rm: remove regular empty file ‘/root/ses/activate’? y [root@localhost ses]# systemctl status ses ● ses.service - SES Simple Echo Service Loaded: loaded (/etc/systemd/system/ses.service; static; vendor preset: disabled) Active: active (running) since Mon 2018-11-26 17:09:40 CET; 1min 20s ago Main PID: 15562 (ses) Tasks: 1 CGroup: /system.slice/ses.service └─15562 /root/ses/ses Nov 26 17:09:40 localhost.localdomain systemd[1]: Started SES Simple Echo Service. Nov 26 17:09:40 localhost.localdomain systemd[1]: Starting SES Simple Echo Service...
Parte 5: journald
- Visualizzare i log di journald, tutti o quelli di una particolare unit
[root@localhost ~]# journalctl -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 17:11:26 CET. -- Nov 26 13:22:30 localhost.localdomain systemd-journal[87]: Runtime journal is using 8.0M (max allowed 91.9M, trying to leave 137.9M free of 911.3M available → current Nov 26 13:22:30 localhost.localdomain kernel: Initializing cgroup subsys cpuset ... Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server started Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server has been started out of systemd. Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server is quitting [root@localhost ~]# journalctl -u <tab><tab> abrtd.service netcf-transaction.service session-15.scope session-4.scope accounts-daemon.service NetworkManager-dispatcher.service session-16.scope session-5.scope alsa-state.service NetworkManager.service session-17.scope session-6.scope auditd.service network.service session-18.scope session-7.scope avahi-daemon.service packagekit.service session-19.scope session-8.scope chronyd.service polkit.service session-1.scope session-9.scope crond.service postfix.service session-20.scope session-c1.scope dbus.service realmd.service session-21.scope session-c2.scope fprintd.service rngd.service session-22.scope smartd.service gdm.service rpc-statd-notify.service session-23.scope sshd.service httpd.service rsyslog.service session-24.scope systemd-fsck-root.service irqbalance.service rtkit-daemon.service session-25.scope systemd-journald.service kdump.service ses.service session-26.scope systemd-logind.service libvirtd.service session-10.scope session-27.scope systemd-timedated.service lvm2-monitor.service session-11.scope session-28.scope systemd-udevd.service lvm2-pvscan@8:2.service session-12.scope session-29.scope udisks2.service mariadb.service session-13.scope session-2.scope ModemManager.service session-14.scope session-3.scope [root@localhost ~]# journalctl -u chronyd -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 17:11:26 CET. -- Nov 26 13:22:55 localhost.localdomain systemd[1]: Starting NTP client/server... Nov 26 13:22:56 localhost.localdomain chronyd[815]: chronyd version 3.2 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SECHASH +SIGND +ASYNCDNS +IPV6 +DEBU Nov 26 13:22:57 localhost.localdomain chronyd[815]: Frequency 24.009 +/- 2.704 ppm read from /var/lib/chrony/drift Nov 26 13:22:57 localhost.localdomain systemd[1]: Started NTP client/server. Nov 26 13:23:16 localhost.localdomain chronyd[815]: Selected source 193.204.114.233 ... Nov 26 16:46:11 localhost.localdomain chronyd[815]: Selected source 31.14.131.188 Nov 26 16:46:11 localhost.localdomain chronyd[815]: System clock wrong by 9959.861550 seconds, adjustment started
- Visualizzare solo i messaggi con priority compresa tra notice ed err
[root@localhost ~]# man journalctl | grep notice "alert" (1), "crit" (2), "err" (3), "warning" (4), "notice" (5), "info" (6), "debug" (7). If a single log level is specified, all messages with this [root@localhost ~]# journalctl -p 3..5 -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 17:11:26 CET. -- Nov 26 13:22:30 localhost.localdomain kernel: Linux version 3.10.0-862.14.4.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5- Nov 26 13:22:30 localhost.localdomain kernel: ACPI: RSDP 00000000000e0000 00024 (v02 VBOX ) Nov 26 13:22:30 localhost.localdomain kernel: ACPI: XSDT 000000007fff0030 0003C (v01 VBOX VBOXXSDT 00000001 ASL 00000061) ... Nov 26 17:10:34 localhost.localdomain dbus[762]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher Nov 26 17:10:34 localhost.localdomain dbus[762]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher' [root@localhost ~]#
- Visualizzare con filtro sul transport stdout; utilizzare la completion
[root@localhost ~]# journalctl <tab><tab> _AUDIT_LOGINUID= COREDUMP_EXE= _MACHINE_ID= _SOURCE_REALTIME_TIMESTAMP= _TRANSPORT= _AUDIT_SESSION= __CURSOR= MESSAGE= SYSLOG_FACILITY= _UDEV_DEVLINK= _BOOT_ID= ERRNO= MESSAGE_ID= SYSLOG_IDENTIFIER= _UDEV_DEVNODE= _CMDLINE= _EXE= __MONOTONIC_TIMESTAMP= SYSLOG_PID= _UDEV_SYSNAME= CODE_FILE= _GID= _PID= _SYSTEMD_CGROUP= _UID= CODE_FUNC= _HOSTNAME= PRIORITY= _SYSTEMD_OWNER_UID= CODE_LINE= _KERNEL_DEVICE= __REALTIME_TIMESTAMP= _SYSTEMD_SESSION= _COMM= _KERNEL_SUBSYSTEM= _SELINUX_CONTEXT= _SYSTEMD_UNIT= [root@localhost ~]# journalctl _TRANSPORT= <tab><tab> driver journal kernel stdout syslog [root@localhost ~]# journalctl _TRANSPORT=stdout -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 17:11:26 CET. -- Nov 26 13:22:32 localhost.localdomain systemd-fsck[361]: /sbin/fsck.xfs: XFS file system. Nov 26 13:22:46 localhost.localdomain lvm[644]: WARNING: lvmetad is being updated, retrying (setup) for 10 more seconds. Nov 26 13:22:47 localhost.localdomain lvm[467]: 2 logical volume(s) in volume group "centos" monitored Nov 26 13:22:48 localhost.localdomain lvm[644]: 2 logical volume(s) in volume group "centos" now active ... Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server started Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server has been started out of systemd. Nov 26 17:11:26 localhost.localdomain ses[15562]: SES - Simple Echo Server is quitting
- Visualizzare con filtro su SYSLOG_IDENTIFIER
[root@localhost ~]# journalctl SYSLOG_IDENTIFIER=sshd -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 17:20:01 CET. -- Nov 26 13:23:14 localhost.localdomain sshd[1262]: Server listening on 0.0.0.0 port 22. Nov 26 13:23:14 localhost.localdomain sshd[1262]: Server listening on :: port 22. Nov 26 13:43:34 localhost.localdomain sshd[2060]: Accepted password for root from 192.168.56.1 port 49217 ssh2 Nov 26 13:43:34 localhost.localdomain sshd[2060]: pam_unix(sshd:session): session opened for user root by (uid=0) Nov 26 14:11:41 localhost.localdomain sshd[4282]: Accepted password for root from 192.168.56.1 port 49309 ssh2 Nov 26 14:11:41 localhost.localdomain sshd[4282]: pam_unix(sshd:session): session opened for user root by (uid=0) [root@localhost ~]#
- Abilitare la persistenza (verificare la collocazione dei journal files)
[root@localhost ~]# ls -R /run/log/journal/ /run/log/journal/: 81c211dd7e6f428995dec2e9d999c878 /run/log/journal/81c211dd7e6f428995dec2e9d999c878: system.journal [root@localhost ~]# ls -R /var/log/journal ls: cannot access /var/log/journal: No such file or directory [root@localhost ~]# mkdir /var/log/journal [root@localhost ~]# systemctl restart systemd-journald [root@localhost ~]# ls -R /run/log/journal/ ls: cannot access /run/log/journal/: No such file or directory [root@localhost ~]# ls -R /var/log/journal /var/log/journal: 81c211dd7e6f428995dec2e9d999c878 /var/log/journal/81c211dd7e6f428995dec2e9d999c878: system.journal [root@localhost ~]#
- Visualizzazione della lista di boot. Verifica della persistenza al reboot.
[root@localhost ~]# journalctl --list-boots -1 2f4fbe37d34d42bb94a9042eba2d3f89 Mon 2018-11-26 13:22:30 CET—Mon 2018-11-26 17:25:04 CET 0 233a251b2d3d4831b63d9ebfac6b6fb2 Mon 2018-11-26 17:12:57 CET—Mon 2018-11-26 23:01:51 CET [root@localhost ~]# journalctl -b -1 -u postfix -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:01:51 CET. -- Nov 26 13:23:12 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... Nov 26 13:23:18 localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system Nov 26 13:23:18 localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix Nov 26 13:23:18 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent. Nov 26 17:24:59 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent... Nov 26 17:24:59 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent. [root@localhost ~]# journalctl -b 0 -u postfix -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:01:51 CET. -- Nov 26 17:13:40 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... Nov 26 23:01:26 localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system Nov 26 23:01:27 localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix Nov 26 23:01:27 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent. [root@localhost ~]#
- Visualizzazione dei kernel log del boot precedente
[root@localhost ~]# journalctl -k -b -1 -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:01:51 CET. -- Nov 26 13:22:30 localhost.localdomain kernel: Initializing cgroup subsys cpuset Nov 26 13:22:30 localhost.localdomain kernel: Initializing cgroup subsys cpu ... Nov 26 17:23:25 localhost.localdomain systemd-journald[459]: Received SIGTERM from PID 1 (systemd). Nov 26 17:25:03 localhost.localdomain kernel: Ebtables v2.0 unregistered Nov 26 17:25:03 localhost.localdomain kernel: type=1305 audit(1543249503.313:853): audit_pid=0 old=731 auid=4294967295 ses=4294967295 res=1 ... Nov 26 17:25:03 localhost.localdomain systemd-shutdown[1]: Syncing filesystems and block devices. Nov 26 17:25:04 localhost.localdomain systemd-shutdown[1]: Sending SIGTERM to remaining processes... [root@localhost ~]#
- Visualizzazione della unit postfix in configurazione di persistenza (verificare la visualizzazione dei boot)
[root@localhost ~]# journalctl -u postfix -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:06:50 CET. -- Nov 26 13:23:12 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... Nov 26 13:23:18 localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system Nov 26 13:23:18 localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix Nov 26 13:23:18 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent. Nov 26 17:24:59 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent... Nov 26 17:24:59 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent. -- Reboot -- Nov 26 17:13:40 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... Nov 26 23:01:26 localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system Nov 26 23:01:27 localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix Nov 26 23:01:27 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
- Visualizzazione in follow mode
Per generare un messaggio di log utilizzare logger[root@localhost ~]# journalctl -n 5 -f -- Logs begin at Mon 2018-11-26 13:22:30 CET. -- Nov 26 23:08:16 localhost.localdomain systemd-logind[755]: New session 3 of user root. Nov 26 23:08:16 localhost.localdomain systemd[1]: Starting Session 3 of user root. Nov 26 23:08:16 localhost.localdomain sshd[2028]: pam_unix(sshd:session): session opened for user root by (uid=0) Nov 26 23:08:16 localhost.localdomain dbus[757]: [system] Activating service name='org.freedesktop.problems' (using servicehelper) Nov 26 23:08:16 localhost.localdomain dbus[757]: [system] Successfully activated service 'org.freedesktop.problems'
[root@localhost ~]# logger -p user.err "logger message prio err" [root@localhost ~]#
Nov 26 23:09:13 localhost.localdomain root[2112]: logger message prio err ^C [root@localhost ~]#
- Visualizzare un evento in modalita' verbose, json-pretty
[root@localhost ~]# journalctl -u postfix -o verbose -n 1 -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:10:01 CET. -- Mon 2018-11-26 23:01:27.226838 CET [s=0ffb05c238394c6bb39660bc2c0b08fb;i=f90;b=233a251b2d3d4831b63d9ebfac6b6fb2;m=2f3c47b;t=57b98797ff589;x=4ed15931e599c3cf] PRIORITY=6 _UID=0 _GID=0 _MACHINE_ID=81c211dd7e6f428995dec2e9d999c878 _HOSTNAME=localhost.localdomain SYSLOG_FACILITY=3 SYSLOG_IDENTIFIER=systemd CODE_FILE=src/core/job.c CODE_LINE=776 CODE_FUNCTION=job_log_status_message MESSAGE_ID=39f53479d3a045ac8e11786248231fbf RESULT=done _TRANSPORT=journal _PID=1 _COMM=systemd _EXE=/usr/lib/systemd/systemd _CAP_EFFECTIVE=1fffffffff _SYSTEMD_CGROUP=/ _CMDLINE=/usr/lib/systemd/systemd --switched-root --system --deserialize 22 UNIT=postfix.service MESSAGE=Started Postfix Mail Transport Agent. _BOOT_ID=233a251b2d3d4831b63d9ebfac6b6fb2 _SOURCE_REALTIME_TIMESTAMP=1543269687226838 [root@localhost ~]#
[root@localhost ~]# journalctl -u postfix -o json-pretty -n 1 { "__CURSOR" : "s=0ffb05c238394c6bb39660bc2c0b08fb;i=f90;b=233a251b2d3d4831b63d9ebfac6b6fb2;m=2f3c47b;t=57b98797ff589;x=4ed15931e599c3cf", "__REALTIME_TIMESTAMP" : "1543269687227785", "__MONOTONIC_TIMESTAMP" : "49529979", "_BOOT_ID" : "233a251b2d3d4831b63d9ebfac6b6fb2", "PRIORITY" : "6", "_UID" : "0", "_GID" : "0", "_MACHINE_ID" : "81c211dd7e6f428995dec2e9d999c878", "_HOSTNAME" : "localhost.localdomain", "SYSLOG_FACILITY" : "3", "SYSLOG_IDENTIFIER" : "systemd", "CODE_FILE" : "src/core/job.c", "CODE_LINE" : "776", "CODE_FUNCTION" : "job_log_status_message", "MESSAGE_ID" : "39f53479d3a045ac8e11786248231fbf", "RESULT" : "done", "_TRANSPORT" : "journal", "_PID" : "1", "_COMM" : "systemd", "_EXE" : "/usr/lib/systemd/systemd", "_CAP_EFFECTIVE" : "1fffffffff", "_SYSTEMD_CGROUP" : "/", "_CMDLINE" : "/usr/lib/systemd/systemd --switched-root --system --deserialize 22", "UNIT" : "postfix.service", "MESSAGE" : "Started Postfix Mail Transport Agent.", "_SOURCE_REALTIME_TIMESTAMP" : "1543269687226838" } [root@localhost ~]#
[root@localhost ~]# journalctl -u postfix -o short-monotonic -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:11:11 CET. -- [ 42.829163] localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... [ 47.332654] localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system [ 47.727793] localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix [ 47.731300] localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent. [14548.219364] localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent... [14548.477386] localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent. -- Reboot -- [ 43.798957] localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent... [ 49.245069] localhost.localdomain postfix/postfix-script[1464]: starting the Postfix mail system [ 49.527571] localhost.localdomain postfix/master[1466]: daemon started -- version 2.10.1, configuration /etc/postfix [ 49.529979] localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent. [root@localhost ~]#
- Modifica della configurazione
Disabilitare lo storage per i log, e verificare che rsyslogd non logga piu'[root@localhost ~]# logger -p user.info "logger message prio info" [root@localhost ~]# tail -n 2 /var/log/messages Nov 26 23:13:11 localhost nm-dispatcher: req:1 'dhcp4-change' [enp0s8]: start running ordered scripts... Nov 26 23:14:20 localhost root: logger message prio info [root@localhost ~]#
[root@localhost ~]# vi /etc/systemd/journald.conf [root@localhost ~]# grep ^Storage /etc/systemd/journald.conf Storage=none [root@localhost ~]# systemctl restart systemd-journald
[root@localhost ~]# journalctl -n 5 --no-pager -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:15:53 CET. -- Nov 26 23:15:50 localhost.localdomain systemd[1]: Started Cleanup of Temporary Directories. Nov 26 23:15:50 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/firstboot-graphical.service:14] Support for option SysVStartPriority= has been removed and it is ignored Nov 26 23:15:53 localhost.localdomain polkitd[782]: Registered Authentication Agent for unix-process:2280:91607 (system bus name :1.37 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) Nov 26 23:15:53 localhost.localdomain systemd[1]: Stopping Flush Journal to Persistent Storage... Nov 26 23:15:53 localhost.localdomain systemd-journal[458]: Journal stopped [root@localhost ~]# logger -p user.err "logger message prio err again" [root@localhost ~]# journalctl -n 5 --no-pager -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:15:53 CET. -- Nov 26 23:15:50 localhost.localdomain systemd[1]: Started Cleanup of Temporary Directories. Nov 26 23:15:50 localhost.localdomain systemd[1]: [/usr/lib/systemd/system/firstboot-graphical.service:14] Support for option SysVStartPriority= has been removed and it is ignored Nov 26 23:15:53 localhost.localdomain polkitd[782]: Registered Authentication Agent for unix-process:2280:91607 (system bus name :1.37 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) Nov 26 23:15:53 localhost.localdomain systemd[1]: Stopping Flush Journal to Persistent Storage... Nov 26 23:15:53 localhost.localdomain systemd-journal[458]: Journal stopped [root@localhost ~]# grep "prio err again" /var/log/messages [root@localhost ~]#
[root@localhost ~]# vi /etc/systemd/journald.conf [root@localhost ~]# grep ^Storage /etc/systemd/journald.conf [root@localhost ~]# systemctl restart systemd-journald [root@localhost ~]# logger -p user.err "logger message prio err again again" [root@localhost ~]# journalctl -n 5 --no-pager -- Logs begin at Mon 2018-11-26 13:22:30 CET, end at Mon 2018-11-26 23:19:09 CET. -- Nov 26 23:19:05 localhost.localdomain systemd-journal[2341]: Journal started Nov 26 23:19:05 localhost.localdomain polkitd[782]: Unregistered Authentication Agent for unix-process:2334:110793 (system bus name :1.38, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus) Nov 26 23:19:05 localhost.localdomain systemd[1]: Starting Flush Journal to Persistent Storage... Nov 26 23:19:05 localhost.localdomain systemd[1]: Started Flush Journal to Persistent Storage. Nov 26 23:19:09 localhost.localdomain root[2352]: logger message prio err again again [root@localhost ~]# grep "prio err again" /var/log/messages Nov 26 23:19:09 localhost root: logger message prio err again again [root@localhost ~]#
Parte 6: systemd utilities
- Visualizzare e modificare i diversi valori di host name tramite hostnamectl
[root@localhost ~]# hostnamectl --static localhost.localdomain [root@localhost ~]# cat /etc/hostname localhost.localdomain [root@localhost ~]# hostnamectl --transient localhost.localdomain [root@localhost ~]# hostnamectl --pretty [root@localhost ~]# cat /etc/machine.info cat: /etc/machine.info: No such file or directory [root@localhost ~]#
[root@localhost ~]# hostnamectl --static set-hostname statichostname [root@localhost ~]# hostnamectl --transient set-hostname transienthostname [root@localhost ~]# hostnamectl --pretty set-hostname prettyhostname [root@localhost ~]# [root@localhost ~]# hostnamectl --static statichostname [root@localhost ~]# cat /etc/hostname statichostname [root@localhost ~]# hostnamectl --transient transienthostname [root@localhost ~]# hostnamectl --pretty prettyhostname [root@localhost ~]# cat /etc/machine-info PRETTY_HOSTNAME=prettyhostname [root@localhost ~]#
- Modificare la timezone del sistema (verificare che i journal log cambiano la data)
[root@localhost ~]# timedatectl Local time: Mon 2018-11-26 23:26:23 CET Universal time: Mon 2018-11-26 22:26:23 UTC RTC time: Mon 2018-11-26 16:38:43 Time zone: Europe/Rome (CET, +0100) NTP enabled: yes NTP synchronized: yes RTC in local TZ: no DST active: no Last DST change: DST ended at Sun 2018-10-28 02:59:59 CEST Sun 2018-10-28 02:00:00 CET Next DST change: DST begins (the clock jumps one hour forward) at Sun 2019-03-31 01:59:59 CET Sun 2019-03-31 03:00:00 CEST [root@localhost ~]# timedatectl list-timezones | grep -i new America/New_York America/North_Dakota/New_Salem [root@localhost ~]# timedatectl set-timezone America/New_York [root@localhost ~]# date Mon Nov 26 17:27:05 EST 2018 [root@localhost ~]# journalctl -n 4 -- Logs begin at Mon 2018-11-26 07:22:30 EST, end at Mon 2018-11-26 17:26:59 EST. -- Nov 26 17:26:59 statichostname dbus[757]: [system] Successfully activated service 'org.freedesktop.timedate1' Nov 26 17:26:59 statichostname systemd[1]: Started Time & Date Service. Nov 26 17:26:59 statichostname systemd-timedated[2564]: Changed time zone to 'America/New_York'. Nov 26 17:26:59 statichostname polkitd[782]: Unregistered Authentication Agent for unix-process:2559:158162 (system bus name :1.64, object path /org/freedesktop/Policy [root@localhost ~]#
- Modificare l'ora del sistema (si deve disabilitare NTP: verificare che chronyd viene fermato)
[root@localhost ~]# date Mon Nov 26 17:28:29 EST 2018 [root@localhost ~]# timedatectl set-time "17:35" Failed to set time: Automatic time synchronization is enabled [root@localhost ~]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2018-11-26 11:13:25 EST; 6h ago ... [root@localhost ~]# timedatectl set-ntp false [root@localhost ~]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled) Active: inactive (dead) ... Nov 26 17:06:50 localhost.localdomain chronyd[814]: Source 85.10.240.253 replaced with 185.19.184.35 Nov 26 17:29:29 statichostname systemd[1]: Stopping NTP client/server... Nov 26 17:29:29 statichostname systemd[1]: Stopped NTP client/server. Hint: Some lines were ellipsized, use -l to show in full. [root@localhost ~]# timedatectl set-time "17:00" [root@localhost ~]# date Mon Nov 26 17:00:02 EST 2018 [root@localhost ~]# timedatectl set-ntp true [root@localhost ~]# systemctl status chronyd ● chronyd.service - NTP client/server Loaded: loaded (/usr/lib/systemd/system/chronyd.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2018-11-26 17:00:09 EST; 4s ago ... [root@localhost ~]# timedatectl set-timezone Europe/Rome [root@localhost ~]# date Mon Nov 26 23:00:32 CET 2018 [root@localhost ~]#
cn/ccr/formazione/centos7/2018-11/systemd-ctl-soluzioni.txt · Last modified: 2018/11/26 22:31 by brunengo@infn.it