Ubuntu 18/20 相關設定整理

  • 先 /etc/cloud/cloud.cfg 內 preserve_hostname 為 true
    sudo vi /etc/cloud/cloud.cfg
    :
    preserve_hostname: true
    :
  • 執行 hostnamectl 設定 hostname Exp. 更改為 pve-devops1
    sudo hostnamectl set-hostname pve-devops1
  • 如果useradd 建立時沒提供 sudo 權限可以之後透過 usermod 來處理 Exp.

    sudo usermod -aG sudo localadmin

    • 查看目前已使用空間

      root@demo-77:/var/log/journal/4ad9885bb19142118fd758b3be95057e# journalctl --disk-usage
      Archived and active journals take up 4.0G in the file system.

    • 即時清除保留兩天

      root@demo-77:/var/log/journal/4ad9885bb19142118fd758b3be95057e# journalctl --rotate
      root@demo-77:/var/log/journal/4ad9885bb19142118fd758b3be95057e# journalctl --vacuum-time=2days
      :
      root@demo-77:/var/log/journal/4ad9885bb19142118fd758b3be95057e# journalctl --disk-usage
      Archived and active journals take up 16.0M in the file system.

    • 設定最多使用空間 Exp. 500M

      vi /etc/systemd/journald.conf

      :
      [Journal]
      :
      SystemMaxUse=500M
      :
      systemctl daemon-reload
  • 在 VMWare 內建立 Ubuntu 20.04 的 VM , 在 /var/log/syslog 會看到以下的異常訊息

    ~# tail -f /var/log/syslog
    Aug 31 10:43:07 iiidevops4 multipathd[747]: sda: add missing path
    Aug 31 10:43:09 iiidevops4 multipathd[747]: sda: failed to get udev uid: Invalid argument
    Aug 31 10:43:11 iiidevops4 multipathd[747]: sda: failed to get sysfs uid: Invalid argument
    Aug 31 10:43:12 iiidevops4 multipathd[747]: sda: failed to get sgio uid: No such file or directory
    Aug 31 10:43:17 iiidevops4 multipathd[747]: sda: add missing path

  • 解決方式 :

    vi /etc/multipath.conf
    defaults {
        user_friendly_names yes
    }
    blacklist {
        devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st|sda)[0-9]*"
    }
    systemctl restart multipath-tools

  • tech/ubuntu18.txt
  • 上一次變更: 2024/05/13 17:59
  • jonathan