Docker学习,常用安装:Zookeeper、ES、Minio
一、Docker安装Zookeeper
##查询zookeeper镜像
docker search zookeeper
##拉去zookeeper镜像
docker pull zookeeper:latest
##本地创建zookeeper的挂载目录
mkdir -p /opt/software/myfile/zookeeper/conf
mkdir -p /opt/software/myfile/zookeeper/data
mkdir -p /opt/software/myfile/zookeeper/datalog
cd /opt/software/myfile/zookeeper
##运行一个zookeeper 复制它的配置文件到本地
docker run --name zookeeper -p 2181:2181 -d zookeeper
docker container cp zookeeper:/conf .
##关闭并删除docker
docker stop zookeeper
docker rm zookeeper
##启动一个新的zookeeper容器,并挂载本地配置和数据目录
docker run --name zookeeper \
-p 2181:2181 \
-v /opt/software/myfile/zookeeper/conf:/conf \
-v /opt/software/myfile/zookeeper/data:/data \
-v /opt/software/myfile/zookeeper/datalog:/datalog \
--restart=always \
-d zookeeper
二、Docker安装Elasticsearch
1、拉取镜像
docker pull elasticsearch:7.12.0
2、创建本地挂载目录
mkdir -p /opt/software/myfile/elasticsearch/config
mkdir -p /opt/software/myfile/elasticsearch/data
mkdir -p /opt/software/myfile/elasticsearch/plugins
权限设置
sudo chmod -R 777 /opt/software/myfile/elasticsearch/
3、配置文件
echo "http.host: 0.0.0.0" >> /opt/software/myfile/elasticsearch/config/elasticsearch.yml
4、创建容器
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms84m -Xmx512m" \
-v /opt/software/myfile/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /opt/software/myfile/elasticsearch/data:/usr/share/elasticsearch/data \
-v /opt/software/myfile/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.12.0
说明:
-p 端口映射
-e discovery.type=single-node 单点模式启动
-e ES_JAVA_OPTS="-Xms84m -Xmx512m":设置启动占用的内存范围
-v 目录挂载
-d 后台运行
5、其他命令
docker ps 查看是否启动
docker logs elasticsearch 启动日志查询
docker restart elasticsearch 重启
docker exec -it elasticsearch bash 进入
异常处理:
异常一:文件夹未设置所有用户读写执行权限,处理:sudo chmod -R 777 /opt/software/myfile/elasticsearch/
三、Docker安装Minio
1、先准备Minio外部挂载配置文件(/opt/software/myfile/minio/conf)和存储上传文件的目录(/opt/software/myfile/minio/data)
mkdir -p /opt/software/myfile/minio/conf
mkdir -p /opt/software/myfile/minio/data
2、下载并查看镜像
docker search minio
docker pull minio/minio
3、创建Minio容器并运行
docker run -p 9000:9000 -p 9090:9090 \
--net=host \
--name minio \
-d --restart=always \
-e "MINIO_ACCESS_KEY=admin" \
-e "MINIO_SECRET_KEY=admin123" \
-v /opt/software/myfile/minio/data:/data \
-v /opt/software/myfile/minio/conf:/root/.minio \
minio/minio server \
/data --console-address ":9090" -address ":9000"
9000是minio的服务端端口 9090是客户端端口
MINIO_ACCESS_KEY 账号
MINIO_SECRET_KEY 密码
4、登录:http://192.168.73.107:9090 admin admin123
5、创建组和用户
6、创建accessKey和secretKey
TIG1FU12193G6LPOOQXG
PtMOEjBXMZ+jRkMRlOQPWEq2958ceIGcImxYiEpD
7、创建bucket 和 上传文件