Linux安装kubeedge_亲测成功
官方github下载kubeedge地址
keadm-v1.6.1-linux-amd64.tar.gz
如果github访问不了,或者太慢,可以给我留言或评论,我发给大家
–cloudcore-ipport=192.168.0.123:10000 cloudcore端的IP和端口
–edgenode-name=testing123 边缘节点的名称,不带此参数,默认使用hostname
–kubeedge-version=1.6.1 kubeedge的版本,会去下载指定版本的kubeedge包
–token 在cloudcore端使用命令获取:keadm gettoken
#解压keadm
tar -zxvf keadm-v1.6.1-linux-amd64.tar.gz
#加入kubeedge
./keadm-v1.6.1-linux-amd64/keadm/keadm join --cloudcore-ipport=192.168.0.123:10000 --cgroupdriver=systemd --edgenode-name=testing123 --kubeedge-version=1.6.1 --token=3ccaxxxxxxxxxxxxx228136.eyJhbxxxxxxxxxxxxGcTB9.fFbUkVvK2GLxxxxxxxxxDYBuu5N7w
#需要在线安装mosquitto mqtt要一点时间, 也可以手动提前去安装,后期会讲解
install MQTT service successfully.
#提示安装MQTT成功
#然后会去下载kubeedge-v1.6.1-linux-amd64.tar.gz包和checksum校验文件
#执行完后
#查看mqtt启动情况
ps aux|grep mosquitto
#查看mqtt版本
mosquitto -v
#查看mqtt是否开机启动
systemctl is-enabled mosquitto
#查看edgecore启动情况
ps aux|grep edgecore
#查看日志
journalctl -u edgecore.service -b
journalctl -u edgecore.service -f
#edge端创建的表相关日志
create table `device`
-- --------------------------------------------------
-- Table Structure for `github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtclient.Device`
-- --------------------------------------------------
CREATE TABLE IF NOT EXISTS `device` (
`id` varchar(64) NOT NULL PRIMARY KEY,
`name` text,
`description` text,
`state` text,
`last_online` text
);
create table `device_attr`
-- --------------------------------------------------
-- Table Structure for `github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtclient.DeviceAttr`
-- --------------------------------------------------
CREATE TABLE IF NOT EXISTS `device_attr` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
`deviceid` text,
`name` text,
`description` text,
`value` text,
`optional` bool,
`attr_type` text,
`metadata` text
);
create table `device_twin`
-- --------------------------------------------------
-- Table Structure for `github.com/kubeedge/kubeedge/edge/pkg/devicetwin/dtclient.DeviceTwin`
-- --------------------------------------------------
CREATE TABLE IF NOT EXISTS `device_twin` (
`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT,
`deviceid` text,
`name` text,
`description` text,
`expected` text,
`actual` text,
`expected_meta` text,
`actual_meta` text,
`expected_version` text,
`actual_version` text,
`optional` bool,
`attr_type` text,
`metadata` text
);
create table `meta`
-- --------------------------------------------------
-- Table Structure for `github.com/kubeedge/kubeedge/edge/pkg/metamanager/dao.Meta`
-- --------------------------------------------------
CREATE TABLE IF NOT EXISTS `meta` (
`key` varchar(256) NOT NULL PRIMARY KEY,
`type` varchar(32) NOT NULL DEFAULT '' ,
`value` text
);
#报错,token已经过期了
testing123 edgecore[2023]: F0510 03:42:38.908203 2023 certmanager.go:91] Error: failed to get edge certificate from the cloudcore, error: Invalid authorization token
#重置kubeedge
keadm reset --force
#重新获取最新token,然后重新keadm join
edge端使用sqlite3数据库
edge端数据库文件在: /var/lib/kubeedge/
#进入数据库
sqlite3 edgecore.db
.database
.table
select * from device;
.exit
#查看edgecore是否开机启动
systemctl is-enabled edgecore
#如果没有设置则设置 开启自启动
如果没有设置则设置 开启自启动
vim /etc/systemd/system/edgecore.service
[Unit]
Description=edgecore.service
[Service]
Type=simple
ExecStart=/usr/local/bin/edgecore
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
#添加文件权限并启动edgecore
chmod +x /etc/systemd/system/edgecore.service
#重新加载配置文件
systemctl daemon-reload
#启动edgecore
systemctl start edgecore
#设置开机自启
systemctl enable edgecore.service
#查看edgecore开机启动状态 enabled:开启, disabled:关闭
systemctl is-enabled edgecore
#查看状态
systemctl status edgecore