标签:分配 manage dem 依赖 mirrors docker部署 centos sts 完成
本篇文章是基于Docker搭建大数据集群系列的开篇之作
bash yum install -y yum-utils #安装工具包,缺少这些依赖将无法完成
bash yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
bash yum install docker-ce
bash systemctl start docker
bash docker version
bash docker run hello-world
bash docker pull centos
bash docker imsages
docker network create --subnet=172.15.0.0/16 netgroup```
### 创建容器
> --name 容器名称
> -h 容器主机名
> --net 设置网桥
> --ip 指定容器IP
**master**
docker run -d --privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup --name cluster-master -h cluster-master --net netgroup --ip 172.15.0.2 centos /usr/sbin/init
**slave1**
docker run -d --privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup --name cluster-slave1-h cluster-slave1--net netgroup --ip 172.15.0.3 centos /usr/sbin/init
**slave2**
docker run -d --privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup --name cluster-slave2-h cluster-slave2--net netgroup --ip 172.15.0.4 centos /usr/sbin/init
**slave3**
docker run -d --privileged -ti -v /sys/fs/cgroup:/sys/fs/cgroup --name cluster-slave3-h cluster-slave3--net netgroup --ip 172.15.0.5 centos /usr/sbin/init
### 查看运行中的容器
bash
docker ps### 查看所有容器,包括未运行的容器
bash
docker pa -a### 运行容器
bash
docker run 容器名或容器ID### 进入容器
bash
docker run exec -ti 容器名或容器ID bash### 配置hosts文件
bash
yum install vim
vim /etc/hosts
172.15.0.2 cluster-master
172.15.0.3 cluster-slave1
172.15.0.4 cluster-slave2
172.15.0.5 cluster-slave3
scp /etc/hosts cluster-slave1:/etc/
scp /etc/hosts cluster-slave2:/etc/
scp /etc/hosts cluster-slave3:/etc/
## 三、容器免密钥通信 ### 更换阿里YUM源
bash
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
### 部署OpenSSH
bash
yum -y install openssh openssh-server openssh-clients
systemctl start sshd
```
敲出下面命令后连续回车三次
bash ssh-keygen -t rsa
bash passwd root
在所有结点都生成密钥之后再进行这步
master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave3
slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave3
slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave3
slave3
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-master
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave1
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave2
ssh-copy-id -f -i ~/.ssh/id_rsa.pub cluster-slave3
第一次敲下面命令时,会向你询问,直接打
yes
,然后输入对应主机的访问密码
第二次敲ssh
命令时,应当直接能够访问,无需输入密码
退出当前用户使用命令exit
master
ssh cluster-master
ssh cluster-slave1
ssh cluster-slave1
ssh cluster-slave1
slave1
ssh cluster-master
ssh cluster-slave1
ssh cluster-slave1
ssh cluster-slave1
slave2
ssh cluster-master
ssh cluster-slave1
ssh cluster-slave1
ssh cluster-slave1
slave3
ssh cluster-master
ssh cluster-slave1
ssh cluster-slave1
ssh cluster-slave1
docker commit -m '提交文字说明' -a '作者' 容器名 提交后的镜像名:提交后的镜像tag名
docker tag 镜像id 要推入的仓库的用户名/要推入的仓库名:新定义的tag
docker push 要推入的仓库的用户名/要推入的仓库名:镜像标签
标签:分配 manage dem 依赖 mirrors docker部署 centos sts 完成
原文地址:https://www.cnblogs.com/njpkhuan/p/11611966.html