crtmpserver 流媒體伺服器叢集安裝配置詳解

來源:互聯網
上載者:User

red5單機還是比較不錯的,但是官方網站沒有文檔,不知道叢集怎麼配置,網尋找了半天,只有red5 0.8版本有叢集配置。以後的版本看了一下,有叢集的外掛程式,但是不知道怎麼裝外掛程式,就算裝好了外掛程式,怎麼配置叢集,還是不知道啊。沒文檔坑爹。
crtmpserver 流媒體伺服器,研究學習,感覺還是不錯的,下面說一下,叢集配置。

一,crtmpserver下載

https://github.com/j0sh/crtmpserver

二,伺服器說明

192.168.10.208 主伺服器
192.168.10.202 從伺服器

三,主從伺服器安裝crtmpserver

1,安裝相關依賴包
# yum install cmake openssl openssl-devel gcc gcc-c++ make
 
2,安裝crtmpserver


# unzip centosinit.zip 
# cd crtmpserver-centosinit 
# chmod +x cleanup.sh 
# sh cleanup.sh 
# cd builders/cmake 
# cmake . 
# make 

3,主伺服器208配置


# vim ./crtmpserver/crtmpserver.lua 
 
{      //85行,acceptors加入,rtmp可以使用80連接埠。如果80有其他用處,就不要這樣設定了 
     ip="0.0.0.0", 
     port=80, 
     protocol="inboundRtmp" 
}, 
 
name="proxypublish",    //256行,配置叢集的地方 
    description="Application for forwarding streams to another RTMP server", 
    protocol="dynamiclinklibrary", 
    acceptors =     //相當於一個串連池 
    { 
        { 
            ip="0.0.0.0", 
            port=6665,                     //串連池的連接埠 
            protocol="inboundRtmp"         //添加 
            --protocol="inboundLiveFlv"    //--注釋原來的 
        }, 
    }, 
    abortOnConnectError=true, 
    targetServers = 
    { 
        { 
            targetUri="rtmp://192.168.10.208/live/",       //實際rtmp伺服器 
            targetStreamType="live", 
            localStreamName="test", 
            keepAlive=true, 
            emulateUserAgent="my master" 
        }, 
        { 
            targetUri="rtmp://192.168.10.202:1935/live/",  //實際的rtmp伺服器 
            targetStreamType="live", 
            emulateUserAgent="My user agent", 
            localStreamName="test", 
            keepAlive=true 
        } 
    } 


注意,crtmpserver預設佔用8080,8081,有的http會佔用這二個連接埠。連接埠衝突的話,crtmpserver是啟不來的。
4,從伺服器預設配置就行了,當然你想做一特殊配置也是可以的。


四,啟動主從伺服器

 

# ./crtmpserver/crtmpserver ./crtmpserver/crtmpserver.lua 
//出現以下內容說明啟動成功了 
+-----------------------------------------------------------------------------+ 
|                                                                     Services| 
+---+---------------+-----+-------------------------+-------------------------+ 
| c |      ip       | port|   protocol stack name   |     application name    | 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 1112|           inboundJsonCli|                    admin| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0|   80|              inboundRtmp|              appselector| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 1935|              inboundRtmp|              appselector| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 8081|             inboundRtmps|              appselector| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 8080|             inboundRtmpt|              appselector| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 6666|           inboundLiveFlv|              flvplayback| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 9999|             inboundTcpTs|              flvplayback| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0|  554|              inboundRtsp|              flvplayback| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 6665|              inboundRtmp|             proxypublish| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 8989|         httpEchoProtocol|            samplefactory| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 8988|             echoProtocol|            samplefactory| 
+---+---------------+-----+-------------------------+-------------------------+ 
|tcp|        0.0.0.0| 1111|    inboundHttpXmlVariant|                  vptests| 
+---+---------------+-----+-------------------------+-------------------------+ 
/root/crtmpserver-centosinit/sources/crtmpserver/src/crtmpserver.cpp:272 GO! GO! GO! (31278) 
注意,先啟動從伺服器,這一點很重要。

五,測試crtmpserver叢集配置,以下安裝在主伺服器208

1,安裝rpmforge


# rpm -ivh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 
根你的linux版本選擇
2,安裝ffmpeg
# yum install ffmpeg 

3,利用ffmpeg發布rtmp流


# ffmpeg -re -i "/root/test.flv" -vcodec copy -acodec copy -f flv rtmp://192.168.10.208:6665/live/test   //串連池連接埠 
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers 
 built on Apr 13 2014 13:00:18 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4) 
 configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --enable-runtime-cpudetect --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-pthreads --enable-x11grab --enable-vdpau --disable-avisynth --enable-frei0r --enable-libopencv --enable-libdc1394 --enable-libgsm --enable-libmp3lame --enable-libnut --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --disable-stripping 
 libavutil      52. 66.100 / 52. 66.100 
 libavcodec     55. 52.102 / 55. 52.102 
 libavformat    55. 33.100 / 55. 33.100 
 libavdevice    55. 10.100 / 55. 10.100 
 libavfilter     4.  2.100 /  4.  2.100 
 libswscale      2.  5.102 /  2.  5.102 
 libswresample   0. 18.100 /  0. 18.100 
 libpostproc    52.  3.100 / 52.  3.100 
Input #0, flv, from '/root/test.flv': 
 Metadata: 
 major_brand     : isom 
 minor_version   : 512 
 compatible_brands: isomiso2mp41 
 encoder         : Lavf55.33.100 
 Duration: 00:22:15.69, start: 0.000000, bitrate: 391 kb/s 
 Stream #0:0: Video: flv1, yuv420p, 320x240, 320 kb/s, 15 tbr, 1k tbn, 1k tbc 
 Stream #0:1: Audio: mp3, 22050 Hz, stereo, s16p, 0 kb/s 
rtmp server sent error 
rtmp server sent error 
Output #0, flv, to 'rtmp://192.168.10.208:6665/live/test': 
 Metadata: 
 major_brand     : isom 
 minor_version   : 512 
 compatible_brands: isomiso2mp41 
 encoder         : Lavf55.33.100 
 Stream #0:0: Video: flv1 ([2][0][0][0] / 0x0002), yuv420p, 320x240, q=2-31, 320 kb/s, 1k tbn, 1k tbc 
 Stream #0:1: Audio: mp3 ([2][0][0][0] / 0x0002), 22050 Hz, stereo, 0 kb/s 
Stream mapping: 
 Stream #0:0 -> #0:0 (copy) 
 Stream #0:1 -> #0:1 (copy) 
Press [q] to stop, [?] for help
 
frame=   23 fps= 15 q=-1.0 size=     131kB time=00:00:01.54 bitrate= 694.1kbits/s    //往rtmp通道傳輸資料,會不停的變化直接,直到視頻結束 

4,接收rtmp流,網上工具好多,就不多說了


rtmp://192.168.10.208:6665/live/test 
rtmp://192.168.10.208/live/test 
rtmp://192.168.10.202:1935/live/test 
以上三個rtmp通道,都可以看ffmpeg發布的視頻流

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.