写点什么

手把手教你安装第一个 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:041285

评论

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

创新赋能助力品牌崛起 恒洁开启品质卫浴新未来

【性能优化实战】都知道小程序FMP优化实录,android音视频开发何俊林

android 程序员 移动开发

【Android高级架构师系统学习文章】Android基础-Activity全方位解析

android 程序员 移动开发

Java程序员必备的辅助开发神器(2022年版),建议收藏

Tom弹架构

Java 开发工具

【干货】Android BAT高级面试必问36题以及算法合集,android视频开发框架

android 程序员 移动开发

【Flutter 专题】117 图解 Dismissible 滑动清除 Widget

android 程序员 移动开发

极光笔记丨数据质量建设实践

极光GPTBots-极光推送

大数据 数据质量 数据质量指标

Microchip推出面向家用电器市场的电容式触摸屏控制器系列产品

【干货】2021Android高级开发面试宝典以及答案整理1,透彻分析源码

android 程序员 移动开发

【开发12年码农教你】Android端简单易用的SPI框架-,写给程序员的Flutter详细教程

android 程序员 移动开发

【Flutter 专题】120 Flutter & 腾讯移动通讯 TPNS,腾讯Android面试

android 程序员 移动开发

【Flutter桌面篇】Flutter&Windows应用尝鲜,flutter框架缺点

android 程序员 移动开发

【Jetpack篇】协程,腾讯T3团队整理

android 程序员 移动开发

【View系列】View事件分发源码探索,android高级开发实战

android 程序员 移动开发

【包学包会】从一次请求开始,android蓝牙开发视频

android 程序员 移动开发

【 FlutterUnit 食用指南】 开源篇,Android自定义View详解

android 程序员 移动开发

【- Flutter 桌面篇 -】 FlutterUnit win版闪亮登场,android入门基础

android 程序员 移动开发

【Java转Android】33,高级Android开发面试解答之线程篇

android 程序员 移动开发

【AAC 系列三】深入理解架构组件,androidjetpack视频

android 程序员 移动开发

【Flutter 专题】126 图解自定义两侧对齐 ACETabBar 标签导航栏

android 程序员 移动开发

【Java转Android】29,真的已经讲烂了

android 程序员 移动开发

【Kotlin篇】多方位处理协程的异常,Android高级工程师进阶学习—Android热修复原理

android 程序员 移动开发

浪潮云说 | “缓”而不慢,内存数据库Redis

云计算

【干货篇】Android各版本拦截进程对AMS的请求实战,移动互联网开发技术就业前景

android 程序员 移动开发

学会会声会影,轻松成为视频剪辑达人

懒得勤快

【扔物线】消失这半年,讲的真详细

android 程序员 移动开发

【 Flutter 手势探索】我的第二本小册来了,嵌入式音视频方向

android 程序员 移动开发

【Flutter 专题】117 图解 Dismissible 滑动清除 Widget(1)

android 程序员 移动开发

【Java转Android】58,讲的太清楚了

android 程序员 移动开发

【中级—(1),flutter面试题

android 程序员 移动开发

【中级—,一线互联网架构师设计思想解读开源框架

android 程序员 移动开发

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