先电云计算dockerpaas平台搭建(超详细!推)
准备工作节点角色 主机名内存 储存 IP仓库节点 server 4G 40G 192.168.10.10Server节点 server 4G 40G 192.168.10.10Client client 4G 40G 192.168.10.20设备名:Server节点主要作为系统的运行指令的发送节点server:192.168.10.10Client节点 主要为服务运行的节...
·
准备工作
节点角色 主机名 内存 储存 IP
仓库节点 server 4G 40G 192.168.10.10
Server节点 server 4G 40G 192.168.10.10
Client client 4G 40G 192.168.10.20
设备名:
- Server节点
主要作为系统的运行指令的发送节点
server:192.168.10.10 - Client节点 主要为服务运行的节点,可以使用一个或者多个均可
client:192.168.10.20 - Registry节点 主要作为系统所有的运行的镜像仓库节点
registry:192.168.10.10
- 首先我们需要准备两个镜像包,一个是centos,一个是paas包
.
2.用传输工具把之前说的两个包传入虚拟机内,这里我用的是Xftp 5
3. 这里我是直接传输到虚拟机的 /root/ 目录下的
4.因为直接用虚拟机不方便操作,所以这里我们改用远程登录工具来,这里我使用的是
到这里准备工作就做完了
下面开始操作
1 到 3 步两个节点都要做
1.关闭selinux
#vi /etc/sysconfig/selinux
SELINUX=disabled
#reboot
#getenforce
Disabled
2. 设置ssh无秘钥登录
#ssh-keygen
一直回车到结束
#ssh-copy-id 192.168.10.20
#yes
#输入192.168.10.20的密码
3.关闭防火墙
#systemctl stop firewalld
#systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
4.修改主机名和域名解析(主机名映射)
server节点
#hostnamectl set-hostname server
#bash
#vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.10 server(添加)
192.168.10.20 client(添加)
#ping client
client 节点
#hostnamectl set-hostname client
#bash
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.10 server(添加)
192.168.10.20 client(添加)
#ping server
5.修改系统内核,打开内核转发功能(两个节点都要设置)
#vi /etc/sysctl.conf
#System default settings live in /usr/lib/sysctl.d/00-system.conf.
#To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward = 1(添加)
net.ipv4.conf.default.rp_filter = 0(添加)
net.ipv4.conf.all.rp_filter = 0(添加)
#sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
6.挂载镜像和配置本地yum
server节点
# mkdir /opt/centos
# mkdir /opt/docker
## mount -o loop XianDian-PaaS-v2.2.iso /opt/docker/
mount: /dev/loop0 is write-protected, mounting read-only
#mount -o loop CentOS-7-x86_64-DVD-1511.iso /opt/centos/
mount: /dev/loop1 is write-protected, mounting read-only
#rm -rfv /etc/yum.repos.d/* 或者 mv -rfv /etc/yum.repos.d/* /home
#vi /etc/yum.repos.d/docker.repo
(添加下面这些)
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[docker]
name=docker
baseurl=file:///opt/docker/docker
gpgcheck=0
enabled=1
server节点安装FTP
#yum -y install vsftpd
#vi /etc/vsftpd/vsftpd.conf
anon_root=/opt(添加这一行)
#systemctl restart vsftpd
#systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
client节点
#rm -rfv /etc/yum.repos.d/* 或者 mv -rfv /etc/yum.repos.d/* /home
#vi /etc/yum.repos.d/docker.repo
(添加下面这些)
[centos]
name=centos
baseurl=//server/centos
gpgcheck=0
enabled=1
[docker]
name=docker
baseurl=ftp://server/docker/docker
gpgcheck=0
enabled=1
清理yum(两个节点都要做)
#yum clean all
#yum list
二
1. 安装docker服务 (两个节点都要安装)
# yum -y install docker
# systemctl restart docker
# systemctl enable docker
2.以下部署DOCKER仓库(server),上传仓库部署使用的镜像。
#cd /opt/docker/images/rancher1.6.5/
#docker load -i registry_latest.tar
#docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest c9bd19d022f6 3 years ago 33.27 MB
3.启动仓库容器服务(server)
# docker run -d -p 5000:5000 --restart=always --name registry docker.io/registry:latest
20a07207bf28256d13fbc53cf2a1d978a4827bf8f360b32a8106d996f024c001
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
20a07207bf28 docker.io/registry:latest "/entrypoint.sh /etc/" 8 seconds ago Up 3 seconds 0.0.0.0:5000->5000/tcp registry
4.设置创库地址(两个节点都要设置)
# vi /etc/sysconfig/docker
(添加这两行)
ADD_REGISTRY='--add-registry 192.168.10.10:5000'
INSECURE_REGISTRY='--insecure-registry 192.168.10.10:5000'
#systemctl daemon-reload
#systemctl restart docker
#docker info
#docker tag c9bd19d022f6 192.168.10.10:5000/registry:latest
#docker push 192.168.10.10:5000/registry:latest
至此仓库就建立好了,我们需要将所有镜像全部推送到仓库中,提供给其他节点使用。
5.部署Rancher-Server服务,上传rancher-server镜像
# docker load -i rancher_server_v1.6.5.tar
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> f89070da7581 3 weeks ago 984.9 MB
10.0.3.137:5000/registry latest c9bd19d022f6 15 months ago 33.27 MB
docker.io/registry latest c9bd19d022f6 15 months ago 33.27 MB
# docker tag f89070da7581 192.168.10.10:5000/rancher/server:v1.6.5
# docker push 192.168.10.10:5000/rancher/server:v1.6.5
6.启动rancher-server服务
# docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:v1.6.5;
2ff52cf39d6f2637ac300e7d430dc828fba99cef4ec118793e91e9d680a16509
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ff52cf39d6f rancher/server:v1.6.5 "/usr/bin/entry /usr/" 18 seconds ago Up 6 seconds 3306/tcp, 0.0.0.0:8080->8080/tcp modest_turing
20a07207bf28 docker.io/registry:latest "/entrypoint.sh /etc/" 39 minutes ago Up 38 minutes 0.0.0.0:5000->5000/tcp registry
然后通过网页访问server节点的8080节点
7.Rancher服务设置。
选择ADMIN-Access Controller,选择LOCAL进行认证设置
选择ADMIN-Settings,下拉到最下面,找到Advanced Settings
打开Advanced Settings,下拉到最后设置仓库地址
选择右下方的语言,可以进行中文切换
选择Default-环境管理,点击添加环境,选择Cattle环境模板,环境名称自定义
查看建立的环境状态,Active状态为正常
切换到新建的环境
8.添加环境内的主机
添加主机之前要确保仓库中有agent服务的相关镜像,没有的话需要提前传到私有仓库中,clinet节点配置好私有仓库地址即可直接拉取。
#ll
REPOSITORY TAG IMAGE ID CREATED SIZE
192.168.10.10:5000/rancher/server v1.6.5 f89070da7581 22 months ago 984.9 MB
192.168.10.10:5000/centos latest ff426288ea90 23 months ago 207.2 MB
192.168.10.10:5000/rancher/scheduler v0.8.2 690ef14a99b7 2 years ago 241.9 MB
192.168.10.10:5000/rancher/agent v1.2.5 ef5fea38dbe6 2 years ago 237.1 MB
192.168.10.10:5000/rancher/network-manager v0.7.4 787fc137ac53 2 years ago 248.8 MB
192.168.10.10:5000/rancher/metadata v0.9.2 d46f30a656e0 2 years ago 251.5 MB
192.168.10.10:5000/rancher/net v0.11.3 9495baae8faf 2 years ago 267.3 MB
192.168.10.10:5000/rancher/dns v0.15.1 af5509fe436b 2 years ago 239.8 MB
192.168.10.10:5000/rancher/healthcheck v0.3.1 10710b438de7 2 years ago 383.9 MB
192.168.10.10:5000/rancher/net holder 665d9f6e8cc1 2 years ago 267.2 MB
docker.io/registry latest c9bd19d022f6 3 years ago 33.27 MB
192.168.10.10:5000/registry latest c9bd19d022f6 3 years ago 33.27 MB
上传镜像到私有仓库完成后,点击添加主机
9.设置client节点的ip,并点击复制到粘贴板到client节点执行
10.切换到应用-基础环境,等待基础设施应用自动部署成功,如图是基础设施应用部署成功的效果
搭建docker平台完成
更多推荐
已为社区贡献9条内容
所有评论(0)