栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

rancher 管理容器集群部署

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

rancher 管理容器集群部署

所有节点同时执行安装,docker版本18.0,mariadb10.0,

1.时间同步

yum -y install ntp
yum update -y
/bin/systemctl start ntpd.service
ntpdate -s time.nist.gov;hwclock -w --localtime */10 * * * * ntpdate -s time.nist.gov;hwclock -w --localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
cat >>/etc/sysconfig/clock < 

2.准备工作防火墙启动

yum -y install epel*
yum -y install wget htop iftop  unzip net-tools
systemctl start  firewalld  
systemctl enable firewalld  
firewall-cmd --state
firewall-cmd  --zone=public --add-port=10050-10051/udp --permanent
firewall-cmd  --zone=public --add-port=10050-10051/tcp --permanent
firewall-cmd  --zone=public --add-port=22-50000/tcp --permanent
firewall-cmd  --reload

在不同的节点上执行下面命令
hostnamectl set-hostname master
hostnamectl set-hostname node1
hostnamectl set-hostname node2

cat >>/etc/hosts < 

3.docker安装

yum install -y yum-utils device-mapper-persistent-data lvm2 wget
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
yum -y install docker-ce-18.06.1.ce-3.el7
docker --version
mkdir /etc/docker
cat > /etc/docker/daemon.json << EOF
 {
"registry-mirrors": ["https://jo6348gu.mirror.aliyuncs.com"]
 }
EOF
systemctl enable docker && systemctl start docker

rancher管理端操作

4.创建rancher/server服务端

docker pull mariadb:10.0   
docker run --name mariadb -p 13306:3306 -e MYSQL_ROOT_PASSWORD=nihaoma -d d1bde56970c6
docker exec -it mariadb bash
mysql -u root -pnihaoma
mysql
> CREATE DATAbase IF NOT EXISTS cattle COLLATE = 'utf8_general_ci' CHARACTER SET = 'utf8';
> GRANT ALL ON cattle.* TO 'tvb9ring'@'%' IDENTIFIED BY 'tvb9ring';
> GRANT ALL ON cattle.* TO 'tvb9ring'@'localhost' IDENTIFIED BY 'tvb9ring';
> FLUSH PRIVILEGES;
exit
exit

docker run -d --restart=always -p 18080:8080 --name rancher rancher/server:stable --db-host 10.100.10.190 --db-port 13306 --db-user tvb9ring --db-pass tvb9ring --db-name cattle

node1,node2上操作

5.加入rancher集群操作,先rancher管理界面设置密码获取秘钥

http://10.100.10.190:18080

 

添加节点主机

 

 node1上执行

[root@node1 ~]# sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://10.100.10.190:18080/v1/scripts/1C27D070EF76E020057C:1609372800000:Ug2pO4gg1MVUMMfj71QsGYqdsY
Unable to find image 'rancher/agent:v1.2.11' locally
v1.2.11: Pulling from rancher/agent
b3e1c725a85f: Pull complete 
6a710864a9fc: Pull complete 
d0ac3b234321: Pull complete 
87f567b5cf58: Pull complete 
063e24b217c4: Pull complete 
d0a3f58caef0: Pull complete 
16914729cfd3: Pull complete 
bbad862633b9: Pull complete 
3cf9849d7f3c: Pull complete 
Digest: sha256:0fba3fb10108f7821596dc5ad4bfa30e93426d034cd3471f6ccd3afb5f87a963
Status: Downloaded newer image for rancher/agent:v1.2.11

node2上执行

[root@node2 ~]# sudo docker run --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11 http://10.100.10.190:18080/v1/scripts/1C27D070EF76E020057C:1609372800000:Ug2pO4gg1MVUMMfj71QsGYqdsY
Unable to find image 'rancher/agent:v1.2.11' locally
v1.2.11: Pulling from rancher/agent
b3e1c725a85f: Pull complete 
6a710864a9fc: Pull complete 
d0ac3b234321: Pull complete 
87f567b5cf58: Pull complete 
063e24b217c4: Pull complete 
d0a3f58caef0: Pull complete 
16914729cfd3: Pull complete 
bbad862633b9: Pull complete 
3cf9849d7f3c: Pull complete 
Digest: sha256:0fba3fb10108f7821596dc5ad4bfa30e93426d034cd3471f6ccd3afb5f87a963
Status: Downloaded newer image for rancher/agent:v1.2.11

 

 

 

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/296438.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号