场景
- elasticsearch集群需要很强的硬件, 但是个人是没有的, 所以利用docker生成需要的环境
容器环境
docker 安装
- docker 按照不说了, 网上一大把教程, 不过需要注意的是win10家庭版环境是不行的
建立容器
-
ubuntu1
- docker run -p 1080:8080 -p 10:80 -p 1200:9200 -p 1601:5601 --ip 172.17.0.2 -v /c/Users/carso/dockerinfo:/usr/local/data --name ubuntu1 -dit ubuntu /bin/bash
-
ubuntu2
- docker run -p 2080:8080 -p 20:80 -p 2200:9200 -p 2601:5601 --ip 172.17.0.3 -v /c/Users/carso/dockerinfo:/usr/local/data --name ubuntu2 -dit ubuntu /bin/bash
-
ubuntu3
- docker run -p 3080:8080 -p 30:80 -p 3200:9200 -p 3601:5601 --ip 172.17.0.4 -v /c/Users/carso/dockerinfo:/usr/local/data --name ubuntu3 -dit ubuntu /bin/bash
-
ubuntu4
- docker run -p 4080:8080 -p 40:80 -p 4200:9200 -p 4601:5601 --ip 172.17.0.5 -v /c/Users/carso/dockerinfo:/usr/local/data --name ubuntu4 -dit ubuntu /bin/bash
-
命令解释
- -p 指定win10端口和容器端口之间的映射关系,无法直接访问容器的端口; 在初始化的时候就确定了,以后很难改变
- –ip 为容器分配ip,否则容器重启IP会变
- -v 挂载win10的目录到容器指定的目录
- -d 后台运行容器
- -it 分配一个供交互的伪终端
- run 创建容器
初始化容器环境
-
更换阿里的源 ubuntu18.04
-
建立一个拥有sudo权限的用户
-
安装java 环境
- apt install default-jre
- apt install default-jdk
-
阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse