Jeremy Cohen:
Hey all! I was working on <https://kodekloud.com/topic/practice-test-backup-and-restore-methods-2-3/|Practice Test Backup and Restore Methods 2> test on the last question to restore the etcd
backup from the remote etcd server for cluster2, and I was having trouble reading through the logs when running systemctl start etcd.service
to reboot the etcd
service, which was having issues because the new data-dir didn’t have the right file permissions to be accessed by etcd.service
.
However, when running journalctl -xe
to view the error logs, the paging behavior wasn’t working properly when running when ssh
-ing into the etcd remote host. More specifically it was directing me to the beginning of the logs, not the end, and paging up / down wasn’t fully working. FWIW this wasn’t an issue when running the same commands while not ssh-ing.
Any ideas how to get around this issue?
Alistair Mackay:
You can use the following script to capture the portion of the log generated immediately after restarting the service to capture the errors more easily
{
SVC="etcd"
sudo systemctl stop $SVC
sudo systemctl daemon-reload
d=$(date +"%Y-%m-%d %H:%M:%S")
sudo systemctl start $SVC
sleep 1
sudo journalctl -u $SVC --since "$d"
}
Alistair Mackay:
Setting correct ownership of the new data directory is part of this exercise.
Jeremy Cohen:
> Setting correct ownership of the new data directory is part of this exercise.
Yeah I thought that was the case, just wasn’t able to see the error.
> sudo journalctl -u $SVC --since “$d”
That’s a good tip, will borrow that for the test if needed. Thanks!
Ramkumar Nagaraj:
• fetch data-dir path in etcd service manifest file, in this case its located at /etc/systemd/system/etcd.service
• check its permission -> ls -ld /var/lib/etcd (prior restore data-dir path)
• set same permission as such above for new data-dir-path (/var/lib/etcd-backup)
• then try systemctl daemon-reload and systemctl restart etcd.service
Alistair Mackay:
@Jeremy Cohen the script above can be used for any systemd service, e.g kubelet when misbehaving. Just edit the first line SVC=
to the name of the service under examination