写点什么

手把手教你安装第一个 LAIN 应用(上)

  • 2020-02-10
  • 本文字数:2943 字

    阅读完需:约 10 分钟

手把手教你安装第一个LAIN应用(上)

一、安装 LAIN 集群

本节包含三种场景下安装 LAIN 集群


  • 本地启动虚拟机安装 LAIN 集群,可供本地测试开发

  • 物理服务器/虚拟机安装 LAIN 集群

  • 云服务器安装 LAIN 集群


三者都需要从 GitHub 获取已经发布的 LAIN 版本源代码: https://github.com/laincloud/lain/releases


下载源码后在目标机器上解压即可。


tar xf lain-VERSION.tar.gz
复制代码

1、本地安装 LAIN 集群

1)环境依赖


  • Linux / MacOS

  • 能够连接到互联网

  • VirtualBox 5.1.22 r115126 (Qt5.6.2)

  • Vagrant 1.9.4

  • 最少 2G 剩余内存(如果需要拉起多个节点,最少 3G)


2)初始化


启动并初始化第一个节点


cd lain-VERSIONvagrant up --provision
复制代码


启动耗时取决于 vagrant box 下载时间, 启动完成后 vagrant 会自动 执行 bootstrap 进行初始化, 初始化需要至少 20 分钟,取决于网络速度。 初始化过程为集群默认配置 vip=192.168.77.201


如果出现以下错误:


Vagrant was unable to mount VirtualBox shared folders. This is usuallybecause the filesystem "vboxsf" is not available. This filesystem ismade available via the VirtualBox Guest Additions and kernel module.Please verify that these guest additions are properly installed in theguest. This is not a bug in Vagrant and is usually caused by a faultyVagrant box. For context, the command attempted was:
mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
The error output from the command was:
/sbin/mount.vboxsf: mounting failed with the error: No such device
复制代码


这个错误是因为宿主机的 Virtual Box 的 Guest Additions 与 laincloud/centos-lain box 已安装的 Guest Additions 版本不一致引起的,导致无法创建 /vagrant 这个同步 目录。请修改工程根目录下的 Vagrantfile,禁止宿主机强行安装新版本的 Guest Additions, 即添加如下配置:


config.vbguest.auto_update = false
复制代码


3)添加更多节点


vagrant up node2
# 待 node2 启动后[vagrant@node1 ~]$ cd /vagrant[vagrant@node1 ~]$ sudo lainctl node add -p playbooks node2:192.168.77.22# root 密码为 vagrant
复制代码


4)同理可以如此添加 node3

2、物理服务器/虚拟机安装 LAIN 集群

1)环境依赖


  • CentOS 7.2

  • NTP 服务保证节点间时间一致

  • 需要能访问到可用的 yum 源(包括 epel)

  • 能够连接到互联网

  • 各节点之间能够互相 ssh

  • 各节点 hostname 不同

  • 各个节点位于同一个路由器之内


2)初始化


第一个节点


cd lain-VERSION# 选择一个同网段的未被使用的 IP 地址作为 VIPsudo ./bootstrap -r docker.io/laincloud --vip={{ vip }}
复制代码


国内用户建议通过 -m 参数使用 aliyun 的加速器下载镜像,使用方式为


sudo ./bootstrap -m https://l2ohopf9.mirror.aliyuncs.com \-r docker.io/laincloud --vip=192.168.77.201
复制代码


添加更多节点


# 需要输入 root 密码sudo lainctl node add -p playbooks {{ hostname }}:{{ ip }}
复制代码

3、云服务器安装 LAIN 集群

1)环境依赖


  • CentOS 7.2

  • NTP 服务保证节点间时间一致

  • 需要能访问到可用的 yum 源(包括 epel)

  • 能够连接到互联网

  • 各节点之间能够互相 ssh

  • 各节点 hostname 不同

  • 各个节点位于同一个 VPC (或虚拟路由器)之内


3) 初始化


第一个节点


cd lain-VERSION
# 如果 VPC 不对数据包进行来源 IP 限制(如青云)sudo ./bootstrap -r docker.io/laincloud
# 如果 VPC 限制了数据包的来源 IP(如阿里云)sudo ./bootstrap -r docker.io/laincloud --ipip
复制代码


添加更多节点


# 需要输入 root 密码sudo lainctl node add -p playbooks {{ hostname }}:{{ ip }}
复制代码

4、配置 LAIN Console 的域名解析

LAIN Console 组件是 LAIN 集群的控制台,配置域名解析后即可在浏览器访问 http://console.lain.local


echo "IP/VIP  console.lain.local" >> /etc/hosts
复制代码

5、常见问题

add-node ssh-copy-id 失败


如果出现 ssh-copy-id 失败,可能需要把 node1:/root/.ssh/lain.pub 内容放到 node2:/root/.ssh/authorized_keys里,新增一行。当然原因可能是多样的,最有可能就是 lain-02 的 /root/.ssh 目录或者目录中的文件权限不对

二、安装 LAIN 客户端

开发 LAIN 应用时,需要安装 LAIN 客户端。LAIN 客户端依赖于: - docker - python


只要支持 docker 和 python 的系统,就可以使用 LAIN 客户端,比如 Linux 和 macOS。


以下均假设 LAIN 集群的 domain 为 lain.local,对于其他 domain,将下文中的 lain.local 替换即可。

1、安装与配置 docker

1)安装


请参考 https://docs.docker.com/engine/installation/ 安装 docker >= 1.12。


2)配置


Insecure Registries


安装好之后,请参考 https://docs.docker.com/registry/insecure/registry.lain.local 添加进 docker daemon 的 insecure-registries 选项。


例如,在 Linux 上,如下的 /etc/docker/daemon.json 表示将 registry.lain.local 加入了 insecure-registries


{  "insecure-registries" : ["registry.lain.local"]}
复制代码


macOS 上的 insecure registries 配置如下图所示:


1559274816295067665.jpeg



配置 insecure-registries 是因为 LAIN 集群的镜像仓库只提供了 HTTP 服务,没有提供 HTTPS 服务。

2、安装与配置 lain-cli

pip install lain-cli
复制代码


推荐使用 virtualenv 安装这个 python 包,即:


pip install virtualenv  # 安装 virtualenvvirtualenv lain  # lain 是虚拟环境的名字,也可以取其他名字source lain/bin/activate  # 激活 lain 虚拟环境pip install lain-clideactivate  # 退出 lain 虚拟环境
复制代码


以后需要使用 lain-cli 的时候,用 source ${lain-virtualenv-path}/bin/activate 激活 lain 虚拟环境; 不使用 lain-cli 的时候,用 deactivate 退出 lain 虚拟环境


安装好之后,需要配置 lain-cli,让 lain-cli 知道 LAIN 集群的 Domain 等信息:


lain config show  # 显示当前配置lain config save-global private_docker_registry registry.lain.local # 配置 docker 私有仓库lain config save local domain lain.local  # 保存 lain.local 集群,并取名为 local
复制代码


假如 LAIN 集群开启了 sso 验证(默认未开启),请配置 sso:


lain config save local sso_url https://sso.lain.local
复制代码

3、配置 LAIN 组件的域名解析

如果 LAIN 集群不能在公网上解析(比如本地启动的集群),请配置 /etc/hosts。


如果启动集群时,使用了 vip 模式,即使用了 /vagrant/bootstrap -r docker.io/laincloud --vip=192.168.77.201启动,请执行:


echo "192.168.77.201  registry.lain.local console.lain.local entry.lain.local lvault.lain.local ipaddr-client.lain.local ipaddr-service.lain.local ipaddr-client.ipaddr-resource.resource.lain.local" >> /etc/hosts
复制代码


192.168.77.201 是启动集群时的 vip 参数


如果启动集群时,没有使用 vip 模式,即使用了 /vagrant/bootstrap -r docker.io/laincloud 启动,请执行:


echo "192.168.77.21  registry.lain.local console.lain.local entry.lain.local lvault.lain.local ipaddr-client.lain.local ipaddr-service.lain.local ipaddr-client.ipaddr-resource.resource.lain.local" >> /etc/hosts
复制代码


192.168.77.21 是集群的主节点的 IP,即启动集群的节点的 IP。


本文转载自宜信技术学院网站。


原文链接:http://college.creditease.cn/detail/254


2020-02-10 21:041318

评论

发布
暂无评论
发现更多内容

使用Python和Gradio构建基于OpenAI GPT-4的AI聊天机器人

qife122

Python 聊天机器人

Cisco Catalyst 9000 Series Switches, IOS XE Release 17.17.1 ED

sysin

Cisco

[VLDB 2025]面向Flink集群巡检的交叉对比学习异常检测

阿里云大数据AI技术

人工智能 云计算 大数据 flink 异常检测

RocketMQ 的消费者类型详解与最佳实践

Apache RocketMQ

阿里云 RocketMQ 云原生 消息队列

Jarvis Agent项目介绍

SkyFire

agent LLM Jarvis

Xcode 26 beta 4 (17A5285i) - Apple 平台 IDE

sysin

xcode

揭秘LummaStealer恶意软件:虚假验证码如何攻陷预订网站

qife122

恶意软件 钓鱼攻击

Windows 10 version 22H2 中文版、英文版下载 (2025 年 7 月更新)

sysin

Windows 10

Windows 11 24H2 中文版、英文版 (x64、ARM64) 下载 (2025 年 7 月更新)

sysin

windows 11

RocketMQ 5.0 可观测能力升级:Metrics 指标分析

Apache RocketMQ

阿里云 RocketMQ 云原生 消息队列

10款主流电子签章软件深度横评+选型指南(2025最新版)

数字工具研究

电子签章软件

Web3 项目的外包开发的技术难点

北京木奇移动技术有限公司

区块链开发 软件外包公司 web3开发

2025最新测评:亲测国内主流的十大电子签章软件

数字工具研究

电子签章软件 电子签章软件怎么选

黑龙江等保测评:保障医疗行业信息系统安全的生命线

等保测评

Windows 11 23H2 中文版、英文版 (x64、ARM64) 下载 (2025 年 7 月更新)

sysin

windows 11

事件总线 + 函数计算构建云上最佳事件驱动架构应用

Apache RocketMQ

云原生 函数计算 事件总线 架构应用

找到合适的Web3外包开发公司

北京木奇移动技术有限公司

区块链开发 软件外包公司 web3开发

哈尔滨二级等保:适合中小企业的安全选择

等保测评

提高财务敏捷性,构建科学的资金运营战略

智达方通

全面预算管理 财务管理 财务规划

基于YOLOv8的电网绝缘子破损与闪络缺陷检测识别项目|完整源码数据集+PyQt5界面+完整训练流程+开箱即用!

申公豹

yolo

Web3外包开发注意事项

北京木奇移动技术有限公司

区块链开发 软件外包公司 web3开发

联邦学习中的持续学习技术

qife122

机器学习 联邦学习

RocketMQ 监控告警:生产环境如何快速通过监控预警发现堆积、收发失败等问题?

Apache RocketMQ

阿里云 RocketMQ 云原生 消息堆积

消息收发弹性——生产集群如何解决大促场景消息收发的弹性&降本诉求

Apache RocketMQ

阿里云 RocketMQ 云原生

阿里云 API 网关 x OKG:游戏连接治理的「最后一公里」

阿里巴巴云原生

2025年最佳网络监控工具Top8

qife122

网络安全 网络监控

基于 EventBridge API Destination 构建 SaaS 集成实践方案

Apache RocketMQ

阿里云 消息队列 EventBridge

黑龙江等保测评:筑牢网络安全基石的关键举措

等保测评

华为小艺AI竞赛Agent首战国际数学奥林匹克大赛(IMO)荣获佳绩!

新消费日报

Windows Server 2022 中文版、英文版下载 (2025 年 7 月更新)

sysin

Windows Server

手把手教你安装第一个LAIN应用(上)_安全_LAIN团队_InfoQ精选文章