yum -y update
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum install docker-ce
可以都加上
科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://<你的ID>.mirror.aliyuncs.com
七牛云加速器:https://reg-mirror.qiniu.com
{
“registry-mirrors”: [
“https://ung2thfc.mirror.aliyuncs.com”,
“https://registry.docker-cn.com”,
“http://hub-mirror.c.163.com”,
“https://docker.mirrors.ustc.edu.cn”
]
}
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["你的加速地址"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
启动
systemctl start docker
设置开机启动
systemctl enable docker
yum list installed | grep docker
yum remove docker*
rm -rf /var/lib/docke
docker pull redis
docker images
创建宿主机目录
mkdir /usr/local/dockersoft/redis
创建持久化文件目录
mkdir /usr/local/dockersoft/redis/data
将原redis.conf拷贝到这个redis目录下,修改redis.conf配置文件
#bind 127.0.0.1 # 注释掉,即允许远程连接
protected-mode no #启用保护模式
appendonly yes #持久化
requirepass 123456 #密码
docker run -itd --name redis -v /usr/local/dockersoft/redis/redis.conf:/etc/redis.conf -v /usr/local/dockersoft/redis/data:/data -p 6379:6379 redis redis-server /etc/redis.conf
6379:第一个6379是远程指定的端口
–name:给容器起一个名
-p:端口映射 容器:宿主机
-v:挂载自定义配置 自定义配置:容器内部配置
-d:后台运行
redis-server --appendonly yes: 在容器执行redis-server启动命令,并打开redis持久化配置
-e设置环境变量参数,如: -e require-pass=123456
docker pull nginx
mkdir /usr/local/dockersoft/nginx
cd /usr/local/dockersoft/nginx
mkdir logs conf html
docker run -itd --name nginx -p 80:80 -v /usr/local/dockersoft/nginx/html:/usr/share/nginx/html:ro -v /usr/local/dockersoft/nginx/logs:/var/log/nginx -v /usr/local/dockersoft/nginx/conf/nginx.conf:/etc/nginx/nginx.conf:ro nginx
docker pull zookeeper
docker run -d -p 2181:2181 --name some-zookeeper --restart always zookeeper
docker pull wurstmeister/zookeeper
docker pull wurstmeister/kafka
docker run -d --name zookeeper-12181 -p 12181:2181 -t wurstmeister/zookeeper
docker run -d --name kafka-19092 -p 19092:9092 --link zookeeper-wurstmeister-12181:zookeeper -e KAFKA_BROKER_ID=1 -e HOST_IP=101.33.245.109 -e KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://101.33.245.109:9092 -e KAFKA_ADVERTISED_HOST_NAME=101.33.245.109 -t wurstmeister/kafka
部分参数含义:
KAFKA_BROKER_ID=1 kafka在集群中的唯一标识
KAFKA_ZOOKEEPER_CONNECT=zookeeper:12181 监听zookeeper的地址
KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.65.7:19092 kafka服务器的地址
进入容器
docker exec -it ${CONTAINER ID} /bin/bash
进入kafka的bin目录下
cd /opt/kafka_2.13-2.8.1/bin
创建topic
./kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic mykafka
查看topic信息-first:topic名
./kafka-topics.sh --zookeeper 192.168.233.129:12181 --describe --topic first
运行生产者
./kafka-console-producer.sh --broker-list localhost:9092 --topic mykafka
消费topic
./kafka-console-consumer.sh --bootstrap-server 127.0.0.1:9092 --from-beginning --topic mykafka
docker pull elasticsearch:7.17.6
docker images
# 创建挂载文件夹
mkdir /usr/local/elasticsearch/config
mkdir /usr/local/elasticsearch/data
mkdir /usr/local/elasticsearch/plugins
# 创建配置文件
vim /usr/local/elasticsearch/config/elasticsearch.yml
#配置yml文件
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
# 设置挂载目录权限
chmod -R 777 /usr/local/elasticsearch
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.6/elasticsearch-analysis-ik-7.17.6.zip
docker run --name elasticsearch --restart=always -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e "ES_JAVA_OPTS=-Xms512m -Xmx512m" \
-v /usr/local/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /usr/local/elasticsearch/data:/usr/share/elasticsearch/data \
-v /usr/local/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.17.6
# 进入容器
docker exec -it elasticsearch /bin/bash
# bin目录下,需要输入多次,有都多个账号
./bin/elasticsearch-setup-passwords interactive