Docker常用软件安装
【摘要】
Docker常用软件安装(持续更新)
docker安装基本操作参考另一篇博客:
https://blog.csdn.net/qq_43692950/article/details/1074517...
Docker常用软件安装(持续更新)
docker安装基本操作参考另一篇博客:
https://blog.csdn.net/qq_43692950/article/details/107451706
一、Mysql 安装
1. mysql安装
- 查询mysql版本
docker search mysql
- 1
- 下载MySQL5.7版本
docker pull mysql:5.7
- 1
- 如果服务器没有网络情况下,可载入mysql镜像
docker load -i mysql_5.7.12-image.tar.gz
- 1
- 创建MySQL容器,设置root账户密码为root
docker create --name mysql -e MYSQL_ROOT_PASSWORD=root -p 3306:3306 mysql:5.7
- 1
- 启动容器
docker start mysql
- 1
- 进入mysql容器内
docker exec -it mysql /bin/bash
- 1
- mysql连接
mysql -u root –p
- 1
- 开启远程连接
GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
- 1
- 释放3306端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent&firewall-cmd --reload
- 1
二、Redis 安装
1. redis安装
- 拉取镜像
docker pull redis
- 1
- 创建容器并启动
docker run -itd --name redis-test -p 6379:6379 redis
- 1
- 或创建容器再启动
docker create -it --name redis -p 6379:6379 redis
docker start redis
- 1
- 2
- 释放6379端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent&firewall-cmd --reload
- 1
三、Elasticsearch&kibana 安装
1. es安装
- 拉取镜像:
docker pull elasticsearch
- 1
- 创建容器并运行:
docker run -it --name elasticsearch \
-d -p 9200:9200 \
-p 9300:9300 \
-p 5601:5601 \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-e "xpack.security.enabled=false" elasticsearch
- 1
- 2
- 3
- 4
- 5
- 6
- 或创建容器再运行:
docker create -it --name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
-p 5601:5601 \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-e "xpack.security.enabled=false" elasticsearch
docker start elasticsearch
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 7.x 部署
docker run -it --name elasticsearch \
-p 9200:9200 \
-p 9300:9300 \
-p 5601:5601 \
-e ES_JAVA_OPTS="-Xms512m -Xmx512m" \
-e "discovery.type=single-node" \
-e "xpack.security.enabled=false" elasticsearch:7.9.2
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 释放端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent&firewall-cmd --reload
- 1
2. kibana安装
- 拉取镜像
docker pull kibana
- 1
- 创建容器并运行:
docker run -it -d --name kibana \
-e ELASTICSEARCH_URL=http://192.168.40.129:9200 \
--network=container:elasticsearch kibana
- 1
- 2
- 3
- 或创建容器再运行:
docker create -it --name kibana \
-e ELASTICSEARCH_URL=http://192.168.40.129:9200 \
--network=container:elasticsearch kibana
docker start kibana
- 1
- 2
- 3
- 4
- 5
- 释放端口
firewall-cmd --zone=public --add-port=5601/tcp --permanent&firewall-cmd --reload
- 1
- kibana 访问地址:
http://192.168.40.129:5601
四、Nginx安装及配置
1. 安装
- 拉取镜像
docker pull nginx
- 1
- 启动容器
docker run -itd --name nginx -p 80:80 nginx
- 1
2. 反向代理
- 拉取nginx.conf,或者自己建文件。
docker cp nginx:/etc/nginx/nginx.conf ./
- 1
- 修改本地nginx.conf,在http中添加:
server {
listen 80;
server_name bxc.com;
location / {
proxy_pass http://192.168.40.129:8091;
index index.html index.htm;
}
}
server {
listen 80;
server_name 192.168.40.129;
location / {
proxy_pass http://192.168.40.129:8092;
index index.html index.htm;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 创建容器启动(前面创建的容器要删掉)
docker create -it --name nginx \
-p 80:80 \
-v /home/bxc/java/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/bxc/java/nginx/logs:/var/log/nginx \
nginx
docker start nginx
- 1
- 2
- 3
- 4
- 5
- 6
- 7
3. 负载均衡
- 修改本地nginx.conf,在http中添加:
upstream backserver {
server 192.168.40.129:8091;
server 192.168.40.129:8092;
server 192.168.40.129:8093;
}
server {
listen 80;
server_name bxc.com;
location / {
proxy_pass http://backserver;
index index.html index.htm;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 创建容器启动(前面创建的容器要删掉)
docker create -it --name nginx \
-p 80:80 \
-v /home/bxc/java/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/bxc/java/nginx/logs:/var/log/nginx \
nginx
docker start nginx
- 1
- 2
- 3
- 4
- 5
- 6
- 7
4. 静态资源
- 修改本地nginx.conf
server {
listen 8080;
server_name bxc.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 创建本地一个目录专门放静态资源,我的目录为/home/bxc/java/nginx/html。
创建容器启动(前面创建的容器要删掉)
docker create -it --name nginx \
-p 80:80 \
-p 8080:8080 \
-v /home/bxc/java/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/bxc/java/nginx/logs:/var/log/nginx \
-v /home/bxc/java/nginx/html:/usr/share/nginx/html \
nginx
docker start nginx
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
上面配置别忘了释放docker 和 宿主机服务器的端口。
五、Zookeeper安装
1. zk安装
- 镜像拉取
docker pull wurstmeister/zookeeper
- 1
- 创建容器并启动
docker run -it --name zookeeper -p 2181:2181 -d wurstmeister/zookeeper
- 1
- 或者先创建容器后启动
docker create -it --name zookeeper -p 2181:2181 wurstmeister/zookeeper
docker start zookeeper
- 1
- 2
- 释放端口
firewall-cmd --zone=public --add-port=2181/tcp --permanent&firewall-cmd --reload
- 1
六、Kafka安装
1. 安装
- 拉取镜像
docker pull wurstmeister/kafka
- 1
- 创建容器并启动
docker run -it --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.40.129:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.40.129:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -d wurstmeister/kafka
- 1
- 2
- 3
- 4
- 5
- 6
- 或者先创建容器后启动
docker create -it --name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.40.129:2181 \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.40.129:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 wurstmeister/kafka
docker start kafka
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 释放端口
firewall-cmd --zone=public --add-port=9092/tcp --permanent&firewall-cmd --reload
- 1
- 集群
搭建kafka集群,请先搭建好上述zookeeper集群。
七、RocketMQ安装
1. 单点安装
- 拉取镜像
docker pull rocketmqinc/rocketmq
- 1
- 创建namesrv挂载目录
mkdir -p /home/rocketmq/namesrv/logs
mkdir -p /home/rocketmq/namesrv/store
- 1
- 2
- 启动namesrv服务
docker run -itd \
--name rmqnamesrv \
-p 9876:9876 \
-v /home/rocketmq/namesrv/logs:/root/logs \
-v /home/rocketmq/namesrv/store:/root/store \
-e "MAX_POSSIBLE_HEAP=100000000" \
rocketmqinc/rocketmq sh mqnamesrv
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 创建broker挂载目录
mkdir -p /home/rocketmq/broker/logs
mkdir -p /home/rocketmq/broker/store
mkdir -p /home/rocketmq/broker/conf
- 1
- 2
- 3
- 创建broker配置文件
vim /home/rocketmq/broker/conf/broker.conf
- 1
brokerClusterName = DefaultCluster
brokerName = broker-a
brokerId = 0
deleteWhen = 04
fileReservedTime = 48
brokerRole = ASYNC_MASTER
flushDiskType = ASYNC_FLUSH
brokerIP1 = {宿主机id}
autoCreateTopicEnable=true
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 启动broker服务
docker run -itd --name rmqbroker \
-p 10911:10911 -p 10909:10909 \
-v /home/rocketmq/broker/logs:/root/logs \
-v /home/rocketmq/broker/store:/root/store \
-v /home/rocketmq/broker/conf/broker.conf:/opt/rocketmq-4.4.0/conf/broker.conf \
-e "NAMESRV_ADDR=192.168.40.130:9876" \
-e "MAX_POSSIBLE_HEAP=200000000" \
rocketmqinc/rocketmq sh mqbroker -c ../conf/broker.conf
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 安装控制台
docker pull styletang/rocketmq-console-ng
- 1
docker run -itd --name rocketmq-console \
-e "JAVA_OPTS=-Drocketmq.config.namesrvAddr=192.168.40.130:9876 -Drocketmq.config.isVIPChannel=false" \
-p 8096:8080 \
styletang/rocketmq-console-ng
- 1
- 2
- 3
- 4
- 释放端口
firewall-cmd --zone=public --add-port=9876/tcp --permanent
firewall-cmd --zone=public --add-port=10911/tcp --permanent
firewall-cmd --zone=public --add-port=10909/tcp --permanent
firewall-cmd --zone=public --add-port=8096/tcp --permanent
firewall-cmd --reload
- 1
- 2
- 3
- 4
- 5
八、RabbitMQ安装
1. 安装
- 拉取镜像:
docker pull rabbitmq:management
- 1
- 启动容器:默认用户名密码为:guest
docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 rabbitmq:management
- 1
- admin访问地址:
http://192.168.40.130:15672
- 1
- 释放端口:
firewall-cmd --zone=public --add-port=15672/tcp --permanent&firewall-cmd --reload
firewall-cmd --zone=public --add-port=5672/tcp --permanent&firewall-cmd --reload
- 1
- 2
九、CanalServer搭建
- 拉取镜像
docker pull canal/canal-server
- 1
- tcp模式创建容器并运行:
docker run --name canal-server \
-e canal.instance.master.address=192.168.40.129:3306 \
-e canal.instance.dbUsername=canal \
-e canal.instance.dbPassword=canal \
-p 11111:11111 \
-d canal/canal-server
- 1
- 2
- 3
- 4
- 5
- 6
或tcp模式创建容器再运行:
docker create --name canal-server \
-e canal.instance.master.address=192.168.40.129:3306 \
-e canal.instance.dbUsername=canal \
-e canal.instance.dbPassword=canal \
-p 11111:11111 canal/canal-server
docker start canal-server
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- kafka模式:
拉取 instance.properties 配置文件到本地
docker cp canal-server:/home/admin/canal-server/conf/example/instance.properties ./
- 1
拉取 canal.properties 配置文件到本地
docker cp canal-server:/home/admin/canal-server/conf/canal.properties ./
- 1
修改本地 instance.properties
#数据库地址
canal.instance.master.address=192.168.40.129:3306
#数据库用户名和密码
canal.instance.dbUsername=root
canal.instance.dbPassword=root
#topic
canal.mq.topic=dbtopic
- 1
- 2
- 3
- 4
- 5
- 6
- 7
修改本地 canal.properties
#修改模式为kafka
canal.serverMode = kafka
#kafka服务地址
kafka.bootstrap.servers = 192.168.40.129:9092
- 1
- 2
- 3
- 4
创建容器,并将本地文件挂载到docker容器中(前面创建的容器要删掉):
docker create --name canal-server \
-v /home/bxc/canal/dockerCanalServer/instance.properties:/home/admin/canal-server/conf/example/instance.properties \
-v /home/bxc/canal/dockerCanalServer/canal.properties:/home/admin/canal-server/conf/canal.properties \
-p 11111:11111 canal/canal-server
- 1
- 2
- 3
- 4
启动容器:
docker start canal-server
- 1
十、FastDfs搭建
1. 单tracker和单Storage
- 拉取镜像
docker pull morunchang/fastdfs
- 1
(1)配置tracker
- 启动tracker
docker run -d --name tracker --net=host \
-p 21000:21000 \
-p 22122:22122 \
morunchang/fastdfs sh tracker.sh
- 1
- 2
- 3
- 4
- 进入tracker容器
docker exec -it tracker /bin/bash
- 1
- 修改 /etc/nginx/conf/nginx.conf
vim /etc/nginx/conf/nginx.conf
- 1
listen 21000;
- 1
- 修改 /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
- 1
tracker_server=本机ip:22122
http.tracker_server_port=21000
- 1
- 2
- 修改tracker配置
vim /etc/fdfs/tracker.conf
- 1
port=22122
http.server_port=21000
- 1
- 2
- 重启tracker容器
docker restart tracker
- 1
(2)配置Storage
- 创建挂载目录
mkdir /home/fastdfs
- 1
- 启动
docker run -d --name storage \
--net=host \
-p 22000:22000 \
-p 23000:23000 \
-e TRACKER_IP=本机ip:22122 \
-e GROUP_NAME=group1 \
-v /home/fastdfs:/data/fast_data \
morunchang/fastdfs sh storage.sh
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 进入容器
docker exec -it storage /bin/bash
- 1
- 修改/etc/nginx/conf/nginx.conf文件
vim /etc/nginx/conf/nginx.conf
- 1
- 修改 /etc/fdfs/client.conf
vim /etc/fdfs/client.conf
- 1
tracker_server=本机ip:22122
http.tracker_server_port=21000
- 1
- 2
- 修改 /etc/fdfs/storage.conf
vim /etc/fdfs/storage.conf
- 1
port=23000
tracker_server=本机ip:22122
http.server_port=22000
- 1
- 2
- 3
- 重启Storage容器
docker restart storage
- 1
- 释放端口
firewall-cmd --zone=public --add-port=21000/tcp --permanent
firewall-cmd --zone=public --add-port=22000/tcp --permanent
firewall-cmd --zone=public --add-port=22122/tcp --permanent
firewall-cmd --zone=public --add-port=23000/tcp --permanent
firewall-cmd --reload
- 1
- 2
- 3
- 4
- 5
2. 多tracker和多Storage集群搭建
多tracker和多Storage集群搭建,修改东西大致和上面一致,tracker在每个tracker节点和上面修改一致,Storage只需在上面修改的tracker_server部分,在下方在继续添加tracker_server即可,再加修改/etc/fdfs/mod_fastdfs.conf 文件的tracker_server。
文章来源: blog.csdn.net,作者:小毕超,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/qq_43692950/article/details/111084773
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)