写点什么

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

评论

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

Android 6,android网络开发技术实战详解

android 程序员 移动开发

Android Glide 3,flutter小程序

android 程序员 移动开发

android hxgsecurity 常用的集中加密方式封装,android项目开发案例

android 程序员 移动开发

android Jetpack Navigation组件——堆栈操作和动画效果

android 程序员 移动开发

Android Launcher——ui框架,嵌入式音视频方向

android 程序员 移动开发

墨刀发布企业版v3.5 ! 再度赋能“团队协同”新模式

Androdid Droid Fu介绍,flutter底部弹窗

android 程序员 移动开发

Android - 定位方式,火星坐标系统,一键锁屏,字节Android高工面试

android 程序员 移动开发

读完这些“Java技术栈”,拿下阿里Offer没问题

Java MySQL spring 程序员 JVM

android activity Intent 传值 传对象,android开发框架开源登录界面

android 程序员 移动开发

Android - 在线浏览源码,电话短信相关,文本变化监听器

android 程序员 移动开发

Android Dialog 的一些使用和优化心得(DialogFragment的使用和优化)

android 程序员 移动开发

Android Jsoup:实现HTML解析和Epub解析,论程序员成长的正确姿势

android 程序员 移动开发

android LifeCycle-简单使用和详细原理解析,2021大厂Android面试经历

android 程序员 移动开发

华为云GaussDB持续深耕创新与开放,打造企业核心数据上云信赖之选

华为云数据库小助手

GaussDB GaussDB(for openGauss) 华为云数据库 GaussDB(for MySQL) UGO

android activity Intent 传值 传对象(1),头条三面技术四面HR

android 程序员 移动开发

Android 11 Beta 版正式发布!以及众多面向开发者的重磅更新

android 程序员 移动开发

软件测试常用工具总结(测试管理、单元测试、接口测试、自动化测试、性能测试、负载测试...)

六十七点五

程序员 软件测试 自动化测试 接口测试 测试工程师

Android 12体验!新的黑夜模式、影音格式,详解系列文章

android 程序员 移动开发

云原生:详解|K8s技术栈解析, 一文读懂K8s工作原理

息之

架构 容器 云原生 k8s 集群

Android Framework学习笔记(七)AMS全家桶,剖析Android开发未来的出路在哪里

android 程序员 移动开发

Android 3年外包工面试笔记,有机会还是要去大厂学习提升

android 程序员 移动开发

Android 8 通知渠道(Notification Channels),美团移动端开发工程师

android 程序员 移动开发

Android Activity 启动出现白屏带标题或闪屏问题解决,移动开发者社区

android 程序员 移动开发

Android APK反编译就这么简单 详解(附图),字节跳动大神讲座

android 程序员 移动开发

Android App Bundle探索,android系统软件开发

android 程序员 移动开发

Android App关于应用程序升级的一点内容,app软件开发课程

android 程序员 移动开发

Androdid Droid Fu介绍(1),万字Android技术类校招面试题汇总

android 程序员 移动开发

想要实现元宇宙,需要哪些技术支撑?

行云创新

技术 云原生 vr 云宇宙 虚拟

Android Binder 的主要内容概述以及特性和原理,Android开发前景怎么样

android 程序员 移动开发

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