注:因版本更新,文中UI界面与最新版本略有差异。
通过一个您已经熟悉的任何一种主流的发行版Linux虚拟机,就可以开始一个快速简单的Rancher测试体验。
建议虚拟机的规格:1vcpu,不小于4GB内存,一块能够连通互联网的网卡。本文编写的测试机是AWS虚拟机上的Amazon
Linux AMI,对CentOS/RHEL有直接参考意义。
Linux主机准备
安装和运行Docker命令和服务,这基本是Rancher对于操作系统的最小化需求了。如果您还不太熟悉Linux或者Docker可以参考以下文档:
Ubuntu用户参考文档:https://docs.docker.com/engine/installation/ubuntulinux/
CentOS/RHEL用户参考文档:http://www.dedoimedo.com/computers/docker-guide.html
Docker命令和服务安装好之后需要确认:
#确认docker的版本,下面是centos的输出
[ec2-user@ip-172-31-30-38 ~]$ sudo docker version
Client:
Version:
1.9.1
API version: 1.21
Go
version: go1.4.2
Git
commit: a34a1d5/1.9.1
Built:
OS/Arch:
linux/amd64
Server:
Version:
1.9.1
API version: 1.21
Go
version: go1.4.2
Git
commit: a34a1d5/1.9.1
Built:
OS/Arch:
linux/amd64
#确认docker服务已经启动并且运行,下面是以centos为例
[ec2-user@ip-172-31-30-38 ~]$ sudo service docker status
docker (pid 7652) is running...
启动Rancher服务器
Rancher服务器是一个Docker
image,所以其软件本身不需要安装,只需执行Docker命令下载并且运行Rancher服务器的镜像即可。
[ec2-user@ip-172-31-30-38 ~]$ sudo docker run -d
--restart=always -p 8080:8080 rancher/server
Unable to find image 'rancher/server:latest' locally
latest: Pulling from rancher/server
0bf056161913: Pull complete
1796d1c62d0c: Pull complete
e24428725dd6: Pull complete
89d5d8e8bafb: Pull complete
a31a85515ea3: Pull complete
c2fd2bef635f: Pull complete
cb545eb6ebd1: Pull complete
7beaeed203e7: Pull complete
f483a41462cd: Pull complete
2fd8dc138841: Pull complete
a4e1df2cafae: Pull complete
5f632b46feff: Pull complete
a4ff409fd1b0: Pull complete
8713e0a3f956: Pull complete
7f6c235d968a: Verifying Checksum
c074ec496974: Download complete
390a2453f500: Download complete
c7f9c84ef74a: Download complete
Status: Downloaded newer image for rancher/server:latest
docker.io/rancher/server: this image was pulled from a legacy
registry. Important: This registry version will
not be supported in future versions of docker.
7c41a0a1a9c79842bca53c19e4ec106b0c2dc6469baec6077a40405f80b26963
[ec2-user@ip-172-31-30-38 ~]$
命令行参数解释:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...] 运行一个docker容器
-d
在后台运行docker容器,并且打印出它的容器ID (Run container in background and print
container ID)
--restart=always 当容器存在时所应用的重启策略,总是重启。
-p 8080:65432
容器端口在虚拟机本机上使用8080端口,Rancher服务器的UI对外服务的端口是8080,如果您的服务器是远程的服务器,还需要考虑到你的测试客户机和虚拟机之间的防火墙策略,确保所使用的Rancer服务器UI对外服务端口不是防火墙阻止的端口。
rancher/server 这里声明让docker去docker hub下载并且运行名称为
rancher/server 的docker镜像到本地。
#检查docker已经正确下载了rancher/server 镜像到本地
[ec2-user@ip-172-31-30-38 ~]$ sudo docker images
REPOSITORY
TAG
IMAGE</