智能进销存软件:革新现代库存管理
222
2023-11-13
【摘要】 本书摘自《OpenStack 云平台-部署与高可用实战》一书中第9.2.1节,肖睿 雷宇飞主编。
9.2.1 主机配置
在安装配置 Rancher 之前,需要先对主机进行基本的初始化配置,例如:设置主机 名、关闭防火墙与 SeLinux 、在 hosts 文件中添加地址解析、修改内核参数等。具体操作
步骤如下所示。
(1)设置主机名
在三台主机上分别设置主机名。
[root@localhost ~]#hostnamectl set-hostname rancher
//在IP 地址为192.168.0.10的主机上设置主机名为 rancher
[root@localhost ~]#bash
[root@rancher ~]#
[root@localhost ~]#hostnamectl set-hostname node1
//在IP 地址为192.168.0.11的主机上设置主机名为 nodel
[root@localhost ~]#bash
[root@node1 ~]#
[root@localhost ~]#hostnamectl set-hostname node2
//在IP地址为192.168.0.12的主机上设置主机名为 node2
[root@localhost ~]#bash
[root@node2 ~]#
(2)关闭防火墙与 SeLinux
将所有主机的防火墙与SeLinux 都设置为关闭状态,下面以rancher 主机为例进行介绍。 [root@rancher ~]#systemctl disable firewalld
[root@rancher ~]#systemctlstop firewalld
[root@rancher ~]#sed-i's/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config //关闭 SeLinux 后需要重启机器才能生效
(3)添加地址解析记录
在所有主机的 hosts 文件中添加 hosts 地址解析,下面以rancher 主机为例进行介绍。
[root@rancher ~]#vim /etc/hosts
192.168.0.10 rancher
192.168.0.11 nodel
192.168.0.12 node2
(4)修改内核参数
在所有主机上修改内核参数并执行“sysctl-p”命令使配置立即生效。下面以 rancher 主机为例进行介绍。
[root@rancher ~]#cat <net.ipv4.ip_forward=1
EOF
[root@rancher ~]#sysctl -p
net.ipv4.ip_forward =1
9.2.2 安装并启动 Docker
Rancher 官网中推荐使用社区版 Docker CE进行部署,所以需要重新配置 Docker 安 装源。在所有主机上安装 Docker CE,下面以 rancher 主机为例进行介绍。
[root@rancher ~]#yum install -y yum-utils device-mapper-persistent-data lvm2
//安装依赖包
[root@rancher ~]#yum-config-manager\
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
//添加 Docker-ce 软件包源
已加载插件:fastestmirror,langpacks
adding repo from:https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.
repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@rancher ~]#yum install -y docker-ce
[root@rancher ~]#systemctl start docker
[root@rancher ~]#systemctl enable docker
9.2.3 部署 Rancher
安 装 完 Docker 后,在 rancher 主机上使用 Docker 创建并运行 Rancher 容器,具体操
作如下所示。
[root@rancher ~]#docker run-d --restart=unless-stopped -p 80:80-p443:443 rancher/rancher:stable
Unable to find image 'rancher/rancher:stable'locally
stable:Pulling from rancher/rancher
124c757242f8:Pull complete
2ebc019eb4e2:Pull complete
dac0825f7ffb:Pull complete
82b0bb65d1bf:Pull complete
ef3b655c7f88:Pull complete
437f23e29d12:Pull complete
52931d58clce:Pull complete
b930be4ed025:Pull complete
4a2d2c2e82le:Pull complete
9137650edb29:Pull complete
fl660f8f83bf:Pull complete
a645405725ff:Pull complete
Digest:sha256:6d53d3414abfbae44fe43bad37e9da738f3a02e6c00a0cd0c17f7d9f2aee373a
Status:Downloaded newer image for rancher/rancher:stable
87c4893fea3250adb02857f1244d27ef6abb97de6bb4529e0d21fea9c7456515
上述命令执行完后,在浏览器中输入:http://192.168.0.10,访 问Rancher 图形界面控 制台,如图9 . 3所示。
首次访问时,需要为默认管理员用户 admin 设置密码,本章中设置为123 .com, 如 图 9 . 4 所示。如果认为设置的密码过于简单,可以勾选下面的 “Use a new randomly generated password” 复选框,就会出现一个新生成的随机密码,可使用该密码作为管理员用户 admin 的密码。
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们 18664393530@aliyun.com 处理,核实后本网站将在24小时内删除侵权内容。