如何基于Debian部署UBNT Unifi控制器?
- By : Will
- Category : Ubnt Unifi-AP
- Tags: APT, Controller, debian, ubnt, unifi
1 前言
由于原来的控制器损坏,所有需要重新配置一个新的控制器,所以此文是控制器配置过程的笔记。
2 实践部分
2.1 环境配置
2.1.1 系统环境信息
hostNanme = ubnt.cmdschool.org
ipAddress = 10.168.0.143
OperatingSystem = Debian10.2
2.1.2 配置网络
vi /etc/systemd/network/static.network
加入如下配置,
[Match] Name=ens33 [Network] Address=10.168.0.143/24 Gateway=10.168.0.1
2.1.3 配置主机名称
hostnamectl set-hostname ubnt.cmdschool.org
2.1.4 配置DNS
vi /etc/resolv.conf
输入如下配置:
nameserver 202.96.128.86 nameserver 202.96.128.166
注:DNS服务器请根据实际环境配置
2.1.5 配置时区
timedatectl set-timezone Asia/Shanghai
2.1.6 配置最近的apt源
vi /etc/apt/sources.list
注解掉以下行
#deb cdrom:[Debian GNU/Linux 10.2.0 _Buster_ - Official amd64 NETINST 20191116-09:56]/ buster main #deb http://deb.debian.org/debian/ buster main #deb-src http://deb.debian.org/debian/ buster main #deb http://security.debian.org/debian-security buster/updates main #deb-src http://security.debian.org/debian-security buster/updates main # buster-updates, previously known as 'volatile' #deb http://deb.debian.org/debian/ buster-updates main #deb-src http://deb.debian.org/debian/ buster-updates main
保存退出后运行以下命令:
echo "deb http://mirrors.163.com/debian buster main" > /etc/apt/sources.list.d/debian.list echo "deb-src http://mirrors.163.com/debian buster main" >> /etc/apt/sources.list.d/debian.list echo "deb http://mirrors.163.com/debian-security buster/updates main" >> /etc/apt/sources.list.d/debian.list echo "deb-src http://mirrors.163.com/debian-security buster/updates main" >> /etc/apt/sources.list.d/debian.list echo "deb http://mirrors.163.com/debian buster-updates main" >> /etc/apt/sources.list.d/debian.list echo "deb-src http://mirrors.163.com/debian buster-updates main" >> /etc/apt/sources.list.d/debian.list
配置完成糊,你需要使用如下命令更新源仓库,
apt update
2.1.7 升级系统
apt upgrade
升级完毕后,请使用如下命令重启系统,
reboot
重启完毕后,请使用如下命令检查系统版本,
cat /etc/debian_version
可见如下显示,
10.2
2.1.8 安装包管理工具并更新库
apt-get install aptitude; apt-get install -f; apt-get clean
2.1.9 配置时间同步
安装时间同步相关包,
aptitude install chrony
同步时间,
chronyc sources
2.2 软件环境配置
2.2.1 安装常用的工具包
aptitude install vim curl net-tools
2.2.2 安装证书配置相关包
aptitude install gnupg ca-certificates apt-transport-https
2.3 尝试运行安装包
2.3.1 下载安装包
wget https://dl.ui.com/unifi/5.12.35/unifi_sysvinit_all.deb
如需其他版本请从如下链接下载,
https://www.ui.com/download/unifi
2.3.2 测试安装
cd ~ dpkg -i unifi_sysvinit_all.deb
可见如下提示,
Selecting previously unselected package unifi. (Reading database ... 30042 files and directories currently installed.) Preparing to unpack unifi_sysvinit_all.deb ... Unpacking unifi (5.12.35-12979-1) ... dpkg: dependency problems prevent configuration of unifi: unifi depends on binutils; however: Package binutils is not installed. unifi depends on mongodb-server (>= 2.4.10) | mongodb-10gen (>= 2.4.14) | mongodb-org-server (>= 2.6.0); however: Package mongodb-server is not installed. Package mongodb-10gen is not installed. Package mongodb-org-server is not installed. unifi depends on mongodb-server (<< 1:3.6.0) | mongodb-10gen (<< 3.6.0) | mongodb-org-server (<= 1.0.8); however: Package jsvc is not installed. dpkg: error processing package unifi (--install): dependency problems - leaving unconfigured Processing triggers for systemd (241-7~deb10u2) ... Errors were encountered while processing: unifi
注:我们后面需要根据提示安装依赖的软件包
2.4 配置mongoDB服务端
2.4.1 配置mongoDB相关源
wget -qO - https://www.mongodb.org/static/pgp/server-3.4.asc | apt-key add - echo "deb http://mirrors.163.com/mongodb/apt/debian jessie/mongodb-org/3.4 main" > /etc/apt/sources.list.d/mongodb-org-3.4.list echo "deb http://mirrors.163.com/debian-security jessie/updates main" >> /etc/apt/sources.list.d/debian.list
配置完成后,你需要使用如下命令更新源仓库,
apt-get update
2.4.2 安装mongoDB服务端软件包
aptitude install mongodb-org-server
2.4.3 启动服务并设置默认启动
systemctl start mongod.service systemctl enable mongod.service
另外,你可使用如下命令查询状态、停止或重启服务,
systemctl status mongod.service systemctl stop mongod.service systemctl restart mongod.service
2.5 安装Java
2.5.1 配置Java相关源
echo "deb http://mirrors.163.com/debian sid main" >> /etc/apt/sources.list.d/debian.list
以上主要针对软件包“java8-runtime-headless”而配置,配置完成后,你需要使用如下命令更新源仓库,
apt-get update
2.5.2 安装Java包
aptitude install openjdk-8-jre-headless
默认情况下,以下安装包会自动安装,如果没有请使用以下命令手动安装,
aptitude install binutils jsvc
2.5.3 更换Oracle Java
基于兼容性考量,某情况下需要使用Oracle Java,如有需求请参阅如下链接安装“jdk1.8.0_151”,
https://www.cmdschool.org/archives/397
文章会引导你定义如下环境变量并导入,
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_151' > /etc/profile.d/jdk.sh echo 'export JRE_HOME=${JAVA_HOME}/jre' >> /etc/profile.d/jdk.sh echo 'export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib' >> /etc/profile.d/jdk.sh echo 'export PATH=${JAVA_HOME}/bin:$PATH' >> /etc/profile.d/jdk.sh source /etc/profile.d/jdk.sh
配置完毕后,请使用如下命令确认安装的软件包可用,
java -version
可见如下显示,
java version "1.8.0_151" Java(TM) SE Runtime Environment (build 1.8.0_151-b12) Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
然后,unifi的程序需要使用配置宣告JDK的位置,
echo "JAVA_HOME=/usr/java/jdk1.8.0_151" | tee -a /etc/default/unifi
2.6 配置unifi程序
2.6.1 安装unifi
cd ~ dpkg -i unifi_sysvinit_all.deb
安装完毕后,可使用如下命令行检查服务启动,
netstat -anp | grep `pgrep -u unifi java` | grep ":::*"
可见如下显示,
tcp6 0 0 :::6789 :::* LISTEN 516/java tcp6 0 0 :::8843 :::* LISTEN 516/java tcp6 0 0 :::8880 :::* LISTEN 516/java tcp6 0 0 :::8080 :::* LISTEN 516/java tcp6 0 0 :::8443 :::* LISTEN 516/java udp6 0 0 :::5353 :::* 516/java udp6 0 0 :::5353 :::* 516/java udp6 0 0 :::3478 :::* 516/java udp6 0 0 :::10001 :::* 516/java udp6 0 0 192.168.0.200:46866 :::* 516/java udp6 0 0 :::1900 :::* 516/java
默认情况下,服务会自动启动,如果没有使用请使用以下命令启动并配置默认启动,
systemctl start unifi.service systemctl enable unifi.service
另外,如果需要查询状态、停止或重启服务请使用如下命令,
systemctl status unifi.service systemctl stop unifi.service systemctl restart unifi.service
2.6.2 测试unifi运行
https://10.168.0.143:8443
可见如下显示,
参阅文档
=============================================================
unifi的安装
————–
https://help.ubnt.com/hc/en-us/articles/220066768-UniFi-How-to-Install-Update-via-APT-on-Debian-or-Ubuntu
Debian源地址
————–
https://www.debian.org/mirror/list
https://www.debian.org/distrib/packages
Mongodb的安装
————–
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/
https://docs.mongodb.com/manual/installation/
Mongodb的安装源
————–
https://www.mongodb.org/static/pgp/
https://repo.mongodb.org/apt/debian/
http://downloads-distro.mongodb.org/repo/debian-sysvinit/
UBNT官方源地址
————–
https://www.ui.com/download/unifi/
如何使用Oracle Java
——————–
https://help.ubnt.com/hc/en-us/articles/115003151108-UniFi-How-to-Configure-a-Debian-Ubuntu-Controller-to-use-Oracle-Java
unifi教程
—————–
https://help.ubnt.com/hc/en-us/categories/200320654-UniFi-Network
如何手动更新AP的固件
——————–
https://help.ubnt.com/hc/en-us/articles/204910064-UniFi-Upgrading-firmware-image-via-SSH%C2%A0#SSH
Debian的网络配置
——————–
https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_modern_network_configuration_without_gui
没有评论