差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版 前次修改
下次修改
前次修改
tech:k3s:librenms [2025/11/27 19:06] – 還原成舊版 (2025/11/27 18:42) jonathantech:k3s:librenms [2025/12/13 17:38] (目前版本) – 3. 列出目前所有的 librenms helm chart 版本 jonathan
行 1: 行 1:
 ====== 在 K3s 環境透過 Rancher 建立 LibreNMS ====== ====== 在 K3s 環境透過 Rancher 建立 LibreNMS ======
   * 採用 K3s 環境已經定義好的   * 採用 K3s 環境已經定義好的
-    * ingress + tls -> librenms.k3s.ichiayi.com +    * ingress + tls Exp. [[https://www.ichiayi.com/tech/k3s#%E5%A6%82%E4%BD%95%E5%BB%BA%E7%AB%8B%E7%B5%A6%E5%85%B6%E4%BB%96%E6%9C%8D%E5%8B%99%E9%80%9A%E7%94%A8%E7%9A%84_ssl_%E6%86%91%E8%AD%89|nms.k3s.ichiayi.com]] 
-    * nfs storage +    * nfs storage Exp. [[https://www.ichiayi.com/tech/k3s#storage_%E8%A8%AD%E5%AE%9A|nfs-client]] 
-  * 使用官方提供的 helm chart 進行安裝配置+  * 使用[[https://github.com/librenms/helm-charts|官方提供的 helm chart]] 進行安裝配置
  
 ===== 安裝程序 ===== ===== 安裝程序 =====
行 10: 行 10:
 helm repo update helm repo update
 </cli> </cli>
-  - 產生 appkey Exp. <cli> +  - 產生 namespace 與所需要帳號密碼, 可下載這 script 執行後自動產生 {{repo>https://raw.githubusercontent.com/tryweb/k3s/refs/heads/main/charts/librenms/scripts/create-secrets.sh}} 
-$ echo "base64:$(head -c 32 /dev/urandom | base64)" +  設定配置檔, 可下載這 values-custom.yaml 來修改成自己需要的內容 {{repo>https://raw.githubusercontent.com/tryweb/k3s/refs/heads/main/charts/librenms/values-custom.yaml}}
-base64:SkGsCIF2TZtQZx8swneh80I1sHQ3AYRD8UCkeze70Bs= +
-</cli> +
-  - 設定配置檔 librenms-values.yaml <code yaml> +
-# ======================================== +
-# 完整、可直接使用的 librenms-values.yaml +
-# ======================================== +
-global: +
-  storageClass: "nfs-client"      # 你的 NFS provisioner 名稱 +
- +
-# ---------- 主要 LibreNMS ---------- +
-librenms: +
-  appkey: "base64:SkGsCIF2TZtQZx8swneh80I1sHQ3AYRD8UCkeze70Bs="  # 你已經有了,保留 +
-  timezone: "Asia/Taipei" +
- +
-  # 分散式 poller 必要設定 +
-  configuration: |- +
-    $config['distributed_poller'] = true; +
-    $config['distributed_poller_group'] = 0; +
-    $config['poller_id'] = php_uname('n'); +
- +
-  image: +
-    repository: librenms/librenms +
-    tag: "24.5.0" +
-    pullPolicy: IfNotPresent +
- +
-  # 讓所有 pod 都從 secret 讀資料庫密碼與 APP_KEY(安全) +
-  extraEnv: +
-    - name: APP_KEY +
-      valueFrom: +
-        secretKeyRef: +
-          name: librenms-secret +
-          key: app-key +
-    - name: DB_HOST +
-      value: "librenms-mysql" +
-    - name: DB_DATABASE +
-      value: "librenms" +
-    - name: DB_USERNAME +
-      value: "librenms" +
-    - name: DB_PASSWORD +
-      valueFrom: +
-        secretKeyRef: +
-          name: librenms-secret +
-          key: db-password +
- +
-  # 關鍵:讓 /opt/librenms 完整掛到 NFS(包含所有 rrd) +
-  persistence: +
-    enabled: true +
-    storageClass: "nfs-client" +
-    accessModes: +
-      - ReadWriteMany +
-    size: 50Gi                     # 建議一次給大,rrd 很吃空間 +
-    mountPath: /opt/librenms       # 必須掛在裡 +
- +
-  # 自動建立 admin 帳號 + 第一次安裝 +
-  extraInitContainers: +
-    - name: librenms-setup +
-      image: librenms/librenms:24.5.+
-      command: ["/bin/bash", "-c"+
-      args: +
-        - | +
-          # 第一次安裝 +
-          if [ ! -f /opt/librenms/.env ] || ! grep -q "APP_KEY=" /opt/librenms/.env; then +
-            echo "Running librenms:install..." +
-            php /opt/librenms/artisan librenms:install --no-interaction +
-          fi +
- +
-          # 建立 admin 帳號(不會重複建立) +
-          if ! php /opt/librenms/artisan user:list --no-ansi | grep -q "admin.*Administrator"; then +
-            echo "Creating default admin user..." +
-            php /opt/librenms/artisan user:add admin \ +
-              --password=librenms \ +
-              --email=admin@example.com +
-              --role=admin \ +
-              --name="Administrator"+
-              --no-interaction +
-          fi +
- +
-          chown -R librenms:librenms /opt/librenms +
-      volumeMounts: +
-        - name: data +
-          mountPath: /opt/librenms +
- +
-  frontend: +
-    replicas: 1 +
-    resources: +
-      requests: +
-        cpu: 250m +
-        memory: 512Mi +
-      limits: +
-        cpu: 1000m +
-        memory: 1Gi +
- +
-  poller: +
-    replicas: 3 +
-    resources: +
-      requests: +
-        cpu: 500m +
-        memory: 1Gi +
-      limits: +
-        cpu: 2000m +
-        memory: 2Gi +
- +
-# ---------- RRDcached(獨立大容量 NFS) ---------- +
-rrdcached: +
-  enabled: true +
-  persistence: +
-    enabled: true +
-    journal: +
-      enabled: true +
-      size: 2Gi +
-      storageClass: "nfs-client" +
-      accessMode: ReadWriteMany +
-    rrdcached: +
-      enabled: true +
-      size: 100Gi                 # 真正吃空間的地方,建議 50~200Gi +
-      storageClass: "nfs-client" +
-      accessMode: ReadWriteMany +
-  envs: +
-    - name: TZ +
-      value: "Asia/Taipei" +
- +
-# ---------- MySQL ---------- +
-mysql: +
-  enabled: true +
-  architecture: standalone +
-  auth: +
-    database: librenms +
-    username: librenms +
-    existingSecret: librenms-secret +
-    existingSecretPasswordKey: db-password +
-    rootPassword: "change_me_root_please" +
-  primary: +
-    persistence: +
-      enabled: true +
-      size: 20Gi +
-      storageClass: "nfs-client" +
-      accessModes: +
-        - ReadWriteOnce +
-    resources: +
-      requests: +
-        cpu: 250m +
-        memory: 1Gi +
- +
-# ---------- Redis ---------- +
-redis: +
-  enabled: true +
-  architecture: standalone +
-  auth: +
-    enabled: false +
-  master: +
-    persistence: +
-      enabled: true +
-      size: 2Gi +
-      storageClass: "nfs-client" +
-      accessModes: +
-        - ReadWriteOnce +
- +
-# ---------- Ingress ---------- +
-ingress: +
-  enabled: true +
-  className: nginx +
-  annotations: +
-    nginx.ingress.kubernetes.io/proxy-body-size: "64m" +
-    nginx.ingress.kubernetes.io/ssl-redirect: "true" +
-  hosts: +
-    - host: librenms.k3s.ichiayi.com +
-      paths: +
-        - path: / +
-          pathType: Prefix +
-  tls: +
-    secretName: wildcard-k3s-ichiayi-com-tls +
-      hosts: +
-        - librenms.k3s.ichiayi.com +
-</code>+
   - 執行安裝 <cli>   - 執行安裝 <cli>
-helm install librenms -f librenms-values.yaml librenms/librenms+helm install librenms -f values-custom.yaml librenms/librenms -n librenms
 </cli> </cli>
-    * 如果安裝後要調整參數(修改 librenms-values.yaml), 需要修改後執行 helm upgrade<cli> +    * 如果安裝後要調整參數(修改 values-custom.yaml), 需要修改後執行 helm upgrade<cli> 
-helm upgrade librenms -f librenms-values.yaml librenms/librenms+helm upgrade librenms -f values-custom.yaml librenms/librenms -n librenms
 </cli> </cli>
-  - 進入 Librenms 網頁 Exp. https://librenms.k3s.ichiayi.com  +  - 進入 Librenms 網頁 Exp. https://nms.k3s.ichiayi.com  
-    * 設帳號密碼 admin / librenms  +    * 第一次進入網頁會轉到 install 定頁面, 建立管理者帳號密碼
  
 ===== FAQ ===== ===== FAQ =====
行 206: 行 31:
 </cli> </cli>
   * {{:tech:k3s:螢幕擷取畫面_2025-11-27_182245.png|}}   * {{:tech:k3s:螢幕擷取畫面_2025-11-27_182245.png|}}
 +
 +==== 2. 啟用 Auto Discovery 功能出現 Error: lnms must not run as root. 狀況 ====
 +<note>已經在 [[https://github.com/librenms/helm-charts/releases/tag/librenms-6.1.0|heml chart librenms-6.1.0 版]]解決這問題</note>
 +  * 透過修改 librenms-values.yaml 內加入 <code yaml>
 +librenms:
 +:
 +  snmp_scanner:
 +    enabled: true              # 啟用此項
 +    cron: "*/15 * * * *"      # 每 15 分鐘執行
 +    resources:
 +      requests:
 +        cpu: 200m
 +        memory: 256Mi
 +    securityContext:
 +      runAsUser: 1000
 +      runAsGroup: 1000
 +      fsGroup: 1000
 +:
 +</code>執行 helm upgrade 讓修改生效<cli>
 +helm upgrade librenms -f values-custom.yaml librenms/librenms -n librenms
 +</cli>
 +
 +==== 3. 列出目前所有的 librenms helm chart 版本 ====
 +  * <cli>helm search repo librenms/librenms -l</cli>
 +  * ++看目前列出結果|<cli>
 +jonathan@k3s-master-171:~$ helm search repo librenms/librenms -l
 +NAME                    CHART VERSION   APP VERSION     DESCRIPTION
 +librenms/librenms       7.0.1           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       7.0.0           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       6.1.0           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       6.0.1           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       6.0.0           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.2.0           25.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.1.1           25.9.1          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.1.0           25.9.1          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.13          25.9.1          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.12          25.9.1          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.11          25.8.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.10          25.8.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.9           25.7.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.8           25.7.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.7           25.7.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.6           25.7.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.5           25.6.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.4           25.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.3           25.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.2           25.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.1           25.4.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       5.0.0           25.4.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       4.0.3           25.4.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       4.0.2           25.3.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       4.0.1           25.3.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       4.0.0           25.3.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.19.0          25.2.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.18.0          24.12.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.17.0          24.11.0         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.16.0          24.10.1         LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.15.0          24.8.1          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.14.0          24.6.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.13.1          24.6.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.12.0          24.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.11.1          24.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.10.0          24.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.9.0           24.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +librenms/librenms       3.8.0           24.5.0          LibreNMS is an autodiscovering PHP/MySQL-based ...
 +</cli>++
 +
 +===== 參考網址 =====
 +  * https://github.com/tryweb/k3s/blob/main/charts/librenms/README.md
 +
 {{tag>librenms k3s}} {{tag>librenms k3s}}
  
  
  • tech/k3s/librenms.1764241607.txt.gz
  • 上一次變更: 2025/11/27 19:06
  • jonathan