您好,登錄后才能下訂單哦!
1 介紹部分
1.1 前言
弟弟店鋪要安裝監(jiān)控,故向其推薦企業(yè)級(jí)別的監(jiān)控UBNT的產(chǎn)品Unifi-Video(筆者推薦UBNT的原因是其一直堅(jiān)持軟件免費(fèi),相比某些廠商軟件按點(diǎn)數(shù)收取授權(quán)費(fèi)的劣舉UBNT算是非常有良心)。
由于官方的監(jiān)控主機(jī)Unifi NVR配置比較低(其實(shí)是硬盤太?。﹥r(jià)格相對(duì)貴,故自己定制6端口的工控機(jī)作為監(jiān)控主機(jī)(可同時(shí)當(dāng)路由和交換機(jī)用^_^,省錢),以下是硬件的截圖。
1.2 功能簡(jiǎn)介
1)具有數(shù)字監(jiān)控主機(jī)功能
2)充當(dāng)路由功能(1口自動(dòng)獲取IP地址,2口待定)
3)充當(dāng)交換機(jī)功能(3至6口可接攝像頭)
1.3 系統(tǒng)架構(gòu)圖
注:以下實(shí)踐部分就是定制軟路由(工控主機(jī))的配置過(guò)程。
2 實(shí)踐部分
2.1 環(huán)境配置
2.1.1 系統(tǒng)環(huán)境
hostnanme=ubnt.cmdschool.org
eth0=dhcp
br0=10.168.1.1
eth[2-5]=10.168.1.x/24
OperatingSystem=Debian8.6
如果讀者跟我一樣是Debian的初學(xué)者,可參考以下系統(tǒng)層的配置教程:
http://cmdschool.blog.51cto.com/2420395/1877915
2.1.2 下載安裝包
網(wǎng)頁(yè)下載安裝包
https://www.ubnt.com/download/unifi-video
命令行下載
wget http://dl.ubnt.com/firmwares/unifi-video/3.5.2/unifi-video_3.5.2~Debian7_amd64.deb
2.1.3 配置apt源
vi /etc/apt/sources.list
注解掉以下行
#deb cdrom:[Debian GNU/Linux 8.6.0 _Jessie_ - Official amd64 DVD Binary-1 20160917-14:25]/ jessie contrib main
保存退出后運(yùn)行以下命令:
echo "deb http://ftp.cn.debian.org/debian Debian8.6 main" | tee /etc/apt/sources.list.d/debian.list echo "deb http://downloads-distro.mongodb.org/repo/debian-sysvinit dist 10gen" | tee /etc/apt/sources.list.d/mongodb-10gen.list echo "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" | tee /etc/apt/sources.list.d/unifi.list apt-key adv --keyserver keyserver.ubuntu.com --recv C0A52C50; apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
更新源倉(cāng)庫(kù):
apt-get update
2.1.4 安裝包管理工具并更新庫(kù)
apt-get install aptitude; apt-get install -f; apt-get clean aptitude update
2.1.5 配置時(shí)區(qū)
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
2.1.6 時(shí)間同步
1)安裝時(shí)間同步相關(guān)包
aptitude install chrony
2)同步時(shí)間
chronyc sources
2.2 安裝unifi-video程序
2.2.1 安裝unifi-video并解決依賴關(guān)系兼清理包緩存
dpkg -i unifi-video_3.5.2~Debian7_amd64.deb; apt-get install -f; apt-get clean
2.2.2 命令行檢查服務(wù)啟動(dòng)
netstat -antp | grep unifi-video
顯示如下:
tcp6 0 0 :::7080 :::* LISTEN 7381/unifi-video tcp6 0 0 127.0.0.1:7081 :::* LISTEN 7381/unifi-video tcp6 0 0 :::7443 :::* LISTEN 7381/unifi-video [...]
2.2.3 瀏覽器確認(rèn)服務(wù)正常
2.3 修改數(shù)據(jù)存儲(chǔ)位置
2.3.1 確定視頻存儲(chǔ)位置
find / -name \*.mp4\*
注:需要先配置槍錄制視頻(界面部分不詳述)
顯示如下:
[...] /var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480745255035_1480745257035_1480737512125_9603951.mp4 /var/lib/unifi-video/videos/e7219371-8d34-3744-a4b5-89acba09907c/2016/12/03/1480743257037_1480743259037_1480737512125_7605951.mp4 [...]
基于以上,可確定存儲(chǔ)目錄為(2TB的硬盤應(yīng)掛在到這目錄下):
/var/lib/unifi-video
2.3.2 確認(rèn)系統(tǒng)檢測(cè)到安裝的硬盤
fdisk -l
顯示如下:
[...] Disk /dev/sdb doesn't contain a valid partition table [...]
2.3.3 硬盤分區(qū)
fdisk /dev/sdb
顯示如下:
[...] Command (m for help): n [...] Select (default p): p Partition number (1-4, default 1): [...] Command (m for help): w [...]
發(fā)現(xiàn)新分區(qū):
partx /dev/sdb
2.3.4 創(chuàng)建PV
pvcreate /dev/sdb1
2.3.5 創(chuàng)建VG
vgcreate dataStore /dev/sdb1
2.3.6 創(chuàng)建LV
lvcreate -L 1999g -n data dataStore
2.3.7 格式化分區(qū)
mkfs.ext4 /dev/mapper/dataStore-data
2.3.8 取得格式化過(guò)分區(qū)的UUID
blkid /dev/mapper/dataStore-data
顯示如下:
/dev/mapper/dataStore-data: UUID="0d1dc121-7bd0-46bd-8d85-5577ab322efc" TYPE="ext4"
2.3.9 停止unifi-video服務(wù)
/etc/init.d/unifi-video stop /etc/init.d/mongodb stop
2.3.10 數(shù)據(jù)遷移
mount /dev/mapper/dataStore-data /mnt/ mv /var/lib/unifi-video/* /mnt umount /mnt
2.3.11 掛載卷
echo 'UUID="0d1dc121-7bd0-46bd-8d85-5577ab322efc" /var/lib/unifi-video ext4 defaults 1 2' >> /etc/fstab mount -a
2.3.12 啟動(dòng)unifi-video服務(wù)
/etc/init.d/mongodb start /etc/init.d/unifi-video start
2.4 安裝桌面環(huán)境
2.4.1 lxde的最小安裝
1)安裝相關(guān)包
aptitude install xinit slim lightdm aptitude install --without-recommends lxde-core
2)配置啟動(dòng)方式
echo 'exec startlxde' > ~/.xinitrc update-alternatives --config x-session-manager
3)配置自動(dòng)登錄
vi /etc/slim.conf
修改配置如下:
default_user ubnt auto_login yes
2.4.2 安裝谷歌瀏覽器
1)下載安裝包
下載頁(yè)面:
http://www.google.cn/chrome/browser/desktop/index.html
下載的命令:
https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
2)啟動(dòng)安裝
dpkg -i google-chrome-stable_current_amd64.deb;apt-get install -f
2.4.3 支持中文
aptitude install fonts-droid
2.5 集成路由與交換功能
2.5.1 增加網(wǎng)橋
1)安裝橋套件
aptitude install bridge-utils
2)創(chuàng)建橋接口
brctl addbr br0
注,刪除請(qǐng)使用
brctl delbr br0
2.5.2 給網(wǎng)卡接口分配特定功能
vim /etc/network/interfaces
加入如下配置:
auto eth0 allow-hotpulg eth0 iface eth0 inet dhcp auto br0 iface br0 inet static address 10.168.1.1 netmask 255.255.255.0 bridge_ports eth3 eth4 eth5 eth6 up /usr/sbin/brctl stp br0 on
注:eth0自動(dòng)獲取IP,eth3-5網(wǎng)橋模式(相當(dāng)于交換機(jī))
重啟服務(wù)使配置生效:
/etc/init.d/networking restart
2.5.3 開啟路由轉(zhuǎn)發(fā)功能
1)臨時(shí)開啟路由轉(zhuǎn)發(fā)
echo 1 > /proc/sys/net/ipv4/ip_forward
2)永久開啟路由轉(zhuǎn)發(fā)
vim /etc/sysctl.conf
去掉此行的注解:
net.ipv4.ip_forward = 1
2.5.4 配置具有SNAT功能防火墻規(guī)則
1)創(chuàng)建防火墻規(guī)則
vim /etc/iptables.up.rules
輸入如下配置:
# Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016 *filter :INPUT DROP [40:2032] :FORWARD ACCEPT [100631:98411806] :OUTPUT ACCEPT [61262:3785634] -A INPUT -i lo -j ACCEPT -A INPUT -i br0 -j ACCEPT -A INPUT -i eth0 -p icmp -j ACCEPT -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -A INPUT -p tcp -m tcp --dport 7080 -j ACCEPT -A INPUT -p tcp -m tcp --dport 7443 -j ACCEPT -A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT COMMIT # Completed on Mon Dec 5 07:48:46 2016 # Generated by iptables-save v1.4.21 on Mon Dec 5 07:48:46 2016 *nat :PREROUTING ACCEPT [1094:127184] :INPUT ACCEPT [112:7768] :OUTPUT ACCEPT [53:3815] :POSTROUTING ACCEPT [77:13304] -A POSTROUTING -s 10.168.1.0/24 -o eth0 -j MASQUERADE COMMIT # Completed on Mon Dec 5 07:48:46 2016
2)配置開機(jī)自動(dòng)加載
echo '#!/bin/sh' > /etc/network/if-pre-up.d/iptables echo '/sbin/iptables-restore < /etc/iptables.up.rules' >> /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables
2.5.5 配置DHCP服務(wù)
1)安裝DHCP服務(wù)
aptitude install isc-dhcp-server
2)修改主配置文件
cp /etc/default/isc-dhcp-server /etc/default/isc-dhcp-server.default vi /etc/default/isc-dhcp-server
配置參數(shù)如下:
DHCPD_CONF=/etc/dhcp/dhcpd.conf INTERFACES="br0"
3)配置加載的子配置文件
cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.default vi /etc/dhcp/dhcpd.conf
配置如下:
ddns-update-style none; option domain-name "cmdschool.org"; option domain-name-servers 202.96.128.86,202.96.128.166; default-lease-time 600; max-lease-time 7200; log-facility local7; subnet 10.168.1.0 netmask 255.255.255.0 { range 10.168.1.51 10.168.1.199; option routers 10.168.1.1; option broadcast-address 10.168.1.255; default-lease-time 600; max-lease-time 7200; }
4)啟動(dòng)服務(wù)
/etc/init.d/isc-dhcp-server start
2.5.6 配置花生殼域名解析
1)安裝軟件包
aptitude install curl
2)創(chuàng)建解析腳本
mkdir ~/script/ vim ~/script/pusoray.sh
輸入如下配置(假設(shè)域名是cmdschool.org):
#!/bin/bash domain="cmdschool.org" user="username" pwd="password" /usr/bin/curl "http://$user:$pwd@ddns.oray.com/ph/update?hostname=$domain"
3)自動(dòng)調(diào)用解析腳本
crontab -e
輸入如下配置:
*/3 * * * * sh ~/script/pusoray.sh
參閱文檔
=============================================================
unifi-video的安裝:
https://help.ubnt.com/hc/en-us/articles/205146160-UniFi-Install-the-UniFi-controller-software-on-the-UniFi-Video-NVR
https://help.ubnt.com/hc/en-us/articles/209754018-UniFi-Video-How-to-Install-UFV-version-3-x-on-a-Legacy-airVision-NVR
Debian源地址:
https://www.debian.org/mirror/list
Mongodb的安裝:
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/
Mongodb的安裝源:
http://downloads-distro.mongodb.org/repo/debian-sysvinit/
UBNT官方源地址:
https://help.ubnt.com/hc/en-us/articles/220066768-UniFi-How-to-Install-Update-via-APT-on-Debian-or-Ubuntu
其他參考:
https://my.oschina.net/u/2000604/blog/304171
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。