使用树莓派搭建HA中心节点记录

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sxhexin/article/details/87256405

安装系统

首先安装墨澜大大定制的HA系统mossbian
https://home-assistant.cc/mossbian/
系统自带国内apt和pip源,但apt源需要手动设置


HA配置

会专门写一篇博客


发布系统到公网

HA系统只能通过局域网访问,so需要在路由器上把端口转发到公网和配置ddns

配置阿里云api授权
https://www.right.com.cn/forum/thread-330561-1-1.html?t=1531614840314
这里为了安全起见,我们使用RAM用户并限定用户权限
自定义一个授权策略,并记住Acces IdAccess Key

    "Version": "1",
    "Statement": [
        {
            "Action": "alidns:*",
            "Resource": "acs:alidns:*:*:domain/your_domain_name",
            "Effect": "Allow"
        },
        {
            "Action": [
                "alidns:DescribeSiteMonitorIspInfos",
                "alidns:DescribeSiteMonitorIspCityInfos",
                "alidns:DescribeSupportLines",
                "alidns:DescribeDomains"
            ],
            "Resource": "acs:alidns:*:*:*",
            "Effect": "Allow"
        }
    ]
}

ddns*

使用的是这个项目
http://www.cnblogs.com/myzony/p/9349578.html
配置setting.json,子域名前缀需要提前在解析里配置好,否则会报错

  // 阿里云的 Access Id
  "access_id": "your_access_id",
  // 阿里云的 Access Key
  "access_key": "your_access_key",
  // TTL 时间
  "interval": 600,
  // 主域名
  "domain": "your_domain_name",
  // 子域名前缀
  "sub_domain": "ha",
  // 记录类型
  "type": "A"
}

由于树莓派是32位系统,所以选择通过 .net core 来运行

写一个小脚本,并配置到crontab里
https://www.cnblogs.com/pengdonglin137/p/3625018.html
https://www.cnblogs.com/linux130/p/5912505.html

  • 脚本
echo "Start Checking!"
/root/dotnet/dotnet /home/pi/publish/AliDDNSNet.dll
echo "Finished Checking!"
  • 配置
    crontab -e 添加 */5 * * * * /home/pi/ddns.sh 并保存

猜你喜欢

转载自blog.csdn.net/sxhexin/article/details/87256405