2021/05/31

今天打開librenms的時候發現無法進入

出現錯誤訊息






查了一下log 發現  5/30 03:00左右就出問題了

重開後正常

但跑了一下valid.php出現以下錯誤


./validate.php

====================================

Component | Version

--------- | -------

LibreNMS  | 21.5.1-16-g15da7fa

DB Schema | 2020_12_14_091314_create_port_group_port_table (205)

PHP       | 7.4.19

Python    | 3.6.8

MySQL     | 5.5.68-MariaDB

RRDTool   | 1.4.8

SNMP      | NET-SNMP 5.7.2

====================================


[OK]    Composer Version: 2.0.14

[OK]    Dependencies up-to-date.

[OK]    Database connection successful

[FAIL]  MariaDB version 10.2.2 is the minimum supported version as of March, 2021. Update MariaDB to a supported version 10.5 suggested).

[FAIL]  Your database is out of date!

        [FIX]:

        ./lnms migrate

[WARN]  Global lnms shortcut not installed. lnms command must be run with full path

        [FIX]:

        sudo ln -s /opt/librenms/lnms /usr/bin/lnms

[WARN]  Bash completion not installed. lnms command tab completion unavailable.

        [FIX]:

        sudo cp /opt/librenms/misc/lnms-completion.bash /etc/bash_completion.d/

[WARN]  Log rotation not enabled, could cause disk space issues

        [FIX]:

        sudo cp /opt/librenms/misc/librenms.logrotate /etc/logrotate.d/librenms

[WARN]  Your install is over 24 hours out of date, last update: Sat, 29 May 2021 14:08:28 +0000

        [FIX]:

        Make sure your daily.sh cron is running and run ./daily.sh by hand to see if there are any errors.

[FAIL]  We have found some files that are owned by a different user than 'librenms', this will stop you updating automatically and / or rrd files being updated causing graphs to fail.

        [FIX]:

        sudo chown -R librenms:librenms /opt/librenms

        sudo setfacl -d -m g::rwx /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

        sudo chmod -R ug=rwX /opt/librenms/rrd /opt/librenms/logs /opt/librenms/bootstrap/cache/ /opt/librenms/storage/

        Files:

         /opt/librenms/config.php_20201107

         /opt/librenms/html/plugins/Weathermap/nkhc.png

         /opt/librenms/html/plugins/Weathermap/nkhc.html



除了mariadb升級外
其他先手動做完沒問題

想說     ./lnms migrate 應該會跟db有關
所以先升db 好了

先備db

    $ mysqldump -u root -p --all-database > mysql-backup.sql

備config

# cp /etc/my.cnf /etc/my.cnf.bak

加入mariadb的repo

# vi /etc/yum.repos.d/MariaDB.repo

加入以下內容:
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

停止及移除目前的 MariaDB:


    # systemctl stop mariadb
    # yum remove mariadb mariadb-server

現在開始安裝 MariaDB 10.5,

    # yum install mariadb mariadb-server

啟動 MariaDB 及設定開機自動啟動:

    # systemctl enable  mariadb
    # systemctl start  mariadb


將原來的 MariaDB 資料升級:

    # mysql_upgrade -u root -p

升級過程沒出現什麼問題
再來跑一下

        ./lnms migrate

出現以下錯誤

Migrating: 2020_12_14_091314_create_port_groups_table

In Connection.php line 678:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists (SQL: create table port_groups (id int unsi
gned not null auto_increment primary key, name varchar(255) not null, desc varchar(255) null) default character set utf8mb4 collate ‘ut
f8mb4_unicode_ci’)

In Exception.php line 18:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists

In PDOStatement.php line 112:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘port_groups’ already exists


進DB先把 port_groups drop 掉

再跑一次

        ./lnms migrate

就正常了

最後再跑一次

./valid.php

沒有任何問題

後續觀察中


https://www.opencli.com/mysql/rhel-centos7-upgrade-mariadb-to-10-5 

https://community.librenms.org/t/validation-gives-failure-to-update-mariadb-will-eventually-cause-issues-lnms-migrate-gives-error/15391

2021/05/14

之前的直播都是直接上youtube

今天有個需求 希望能夠不要使用youtube

而且user要能直接用browser看 不需要 vlc

因為之前上看校的直播使用的是 rtmp

查了一下資料

如果要在browser用rtmp

使用的播放程式都必需轉成flash

問題是現在沒有browser支援flash了

所以想到另一個方式

先把串流轉成hls (m3u8)的格式

在srs.conf 裡進行如下的修改

vhost __defaultVhost__ {

   hls {

        enabled         on;

        hls_path        /usr/local/srs/objs/nginx/html/; (此行依現況調整)

        hls_fragment    10;

        hls_window      60;

    }

}

改完重啟 並進行串流後

會在html生成live目錄及相關的m3u8文件


在client端目前看來只有 safari 能直接在html5 使用 <video> 播放

其他browser都需要再呼叫播放器

參考以下範例


<html>

<head>

    <link href="https://vjs.zencdn.net/7.4.1/video-js.css" rel="stylesheet">

</head>

 

<body>

    <video id='my-video' class='video-js' controls preload='auto' width='800' height='600' poster='avatar-poster.jpg'

        data-setup='{ "html5" : { "nativeTextTracks" : true } }'>

        <source src='http://1.2.3.4:8080/live/livestream.m3u8' type="application/x-mpegURL">

        <p class='vjs-no-js'>

            To view this video please enable JavaScript, and consider upgrading to a web browser that

            <a href='https://videojs.com/html5-video-support/' target='_blank'>supports HTML5 video</a>

        </p>

    </video>

 

    <script src='https://vjs.zencdn.net/7.4.1/video.js'></script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.15.0/videojs-contrib-hls.min.js"></script>

 

    <script>

        var player = videojs('my-video');

        player.play();

    </script>

 

</body>

</html>


如果不使用直播而是想播放檔案

就要先把 mp4 轉成 hls

指令如下


ffmpeg -i video.mp4 -codec: copy -start_number 0 -hls_time 15 -hls_list_size 0 -f hls vido.m3u8


接下來再依照上述的html範例進行修改 


https://www.itbkz.com/9372.html


https://caniuse.com/http-live-streaming


https://blog.csdn.net/weixin_40592935/article/details/109361642