Docker rancher 部署
Docker-rancher
环境 centos7.4 , Docker version 17.12.0-ce
#下载docker镜像
docker pull mysql:5.7
docker pull rancher/server:latest
docker images
#运行MySQL容器
#创建挂载目录
mkdir -p /data/mysql/{datadir,conf.d,logs}
#创建mysql容器,设置密码sql2018
DBPass=sql2018
docker run --name mysqldb -p 3306:3306 \
-v /data/mysql/datadir:/var/lib/mysql \
-v /data/mysql/conf.d:/etc/mysql/conf.d \
-e MYSQL_ROOT_PASSWORD=$DBPass -d mysql:5.7
#查询测试
docker ps -l
docker exec -it mysqldb mysql -p$DBPass -e "show databases;"
#创建库并授权(库,用户,密码都为cattle)
docker exec -it mysqldb mysql -p$DBPass -e "
create database if not exists cattle collate = 'utf8_general_ci' character set = 'utf8';
grant all on cattle.* to 'cattle'@'%' identified by 'cattle';
grant all on cattle.* to 'cattle'@'localhost' identified by 'cattle';
flush privileges;show databases;"
#运行rancher容器
IP=172.16.50.26 #本机IP
Port=8090 #rancher web端口
docker run -d --name rancher --link=mysqldb:db \
--restart=unless-stopped -p $Port:8080 -p 9345:9345 rancher/server:latest \
--db-host db --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle \
--advertise-address $IP
#等几分钟,当数据表超过100行时,可以浏览器打开了
#显示为109时安装完成
docker exec -it mysqldb mysql -u"cattle" -h localhost -p"cattle" -e "use cattle;show tables;" |wc -l
echo "浏览器访问 $IP:$Port "
#添加主机(节点)
#基础架构——主机——添加主机(保存)——复制第5部分代码,在其它docker节点执行
#本次安装,添加节点代码
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.9 \
http://172.16.50.26:8090/v1/scripts/EBB906FD4DA3BFB93D88:1514678400000:68jkNNZXjsOp2zDIwxHCb4MkjI8
rancher安装k8s(仅供测试)
https://www.kubernetes.org.cn/2955.html
本文来自博客园,作者:blog-elvin-vip,转载请注明原文链接:https://www.cnblogs.com/elvi/p/8478551.html