Docker common middleware installation

1 Introduction

This article will introduce in detail how to use docker to install various commonly used middleware installation tutorials, mainly including: mysql, gitlab, nacos, redis, xxljob, zipkin, sentinel, seata, rocketMQ, jenkins, oracle, zookeeper, kafaka.
注意:All the following operations are all based on docker. If docker is not installed, please see: Install docker on Linux-CentOS7

2. Middleware installation

2.1、mysql

sudo docker run \
-d \
-p 3306:3306 \
-v /usr/local/mysql/conf:/etc/mysql/conf.d \
-v /usr/local/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=xiashiman6688# \
--restart always \
--name mysql \
mysql:5.6.47

2.2, gitlab container

sudo docker run \
-itd \
-p 9980:80 \
-p 9922:22 \
-v /usr/local/Gitlab/etc:/etc/gitlab \
-v /usr/local/Gitlab/log:/var/log/gitlab \
-v /usr/local/Gitlab/opt:/var/opt/gitlab \
--restart always \
--privileged=true \
--name gitlab \
gitlab/gitlab-ce

insert image description here

2.3、nacos

docker run \
    --name nacos \
    -d \
    -p 8848:8848 \
    -p 9848:9848 \
    -p 9849:9849 \
    --restart=always \
    -e JVM_XMS=256m \
    -e JVM_XMX=256m \
    -e MODE=standalone \
    -v /usr/local/nacos/logs:/home/nacos/logs \
    -v /usr/local/nacos/init.d/custom.properties:/home/nacos/init.d/custom.properties \
    nacos/nacos-server:v2.1.0

2.4、redis

docker run \
--restart=always \
--log-opt max-size=100m \
--log-opt max-file=2 \
-p 6379:6379 \
--name redis \
-v /usr/local/redis/redis.conf:/etc/redis/redis.conf \
-v /usr/local/redis/data:/data \
-d redis:5.0.7 \
redis-server /etc/redis/redis.conf \
--appendonly yes \
–restart=always 总是开机启动
–log是日志方面的
-p 6379:6379 将6379端口挂载出去
–name 给这个容器取一个名字
-v 数据卷挂载
/home/redis/myredis/myredis.conf:/etc/redis/redis.conf 这里是将 liunx 路径下的myredis.conf 和redis下的redis.conf 挂载在一起。
/home/redis/myredis/data:/data 这个同上
-d redis:版本号 表示后台启动哪个版本的redis
redis-server /etc/redis/redis.conf 以配置文件启动redis,加载容器内的conf文件,最终找到的是挂载的目录 /etc/redis/redis.conf 也就是liunx下的/home/redis/myredis/myredis.conf
–appendonly yes 开启redis 持久化
–requirepass 000415 设置密码 (如果你是通过docker 容器内部连接的话,就随意,可设可不设。但是如果想向外开放的话,一定要设置

2.5、xxljob

docker run \
-e PARAMS="--spring.datasource.url=jdbc:mysql://43.138.106.84:3306/xxl_job_dev?Unicode=true&characterEncoding=UTF-8 \
--spring.datasource.username=xxljob \
--spring.datasource.password=xxljob" \
-p 8080:8080 \
-v /tmp:/data/applogs \
--name xxl-job-admin \
--restart=always \
-d xuxueli/xxl-job-admin:2.3.1

2.6、zipkin

docker run \
-e PARAMS="--spring.datasource.url=jdbc:mysql://localhost:3306/zipkin?Unicode=true&characterEncoding=UTF-8 \
--spring.datasource.username=root \
--spring.datasource.password=123456" \
-p 9411:9411 \
--name zipkin \
--restart=always \
-d openzipkin/zipkin:2.12.9

2.7、sentinel

docker run \
--name sentinel \
--restart=always \
-p 8858:8858 \
-v /usr/local/sentinel_home:/home/sentinel_home \
-d bladex/sentinel-dashboard:1.8.0 

2.8、set

2.8.1. Obtain image

docker pull seataio/seata-server

2.8.2. Run the container and get the configuration

In order to facilitate our modification of the seata configuration, we need to run the seata-server first, then copy the configuration to the host, delete the previous configuration after completion, and run the container through the host.

docker run \
-d \
--restart always  \
--name  seata-server \
-p 8091:8091  \
-v /usr/local/seata:/seata-server \
seataio/seata-server:1.5.1

2.9、rockerMQ

2.9.1、rockerMQ-namesrv

docker run \
-d \
--name rocketmq-namesrv \
--network rocketmq \
--restart=always \
-p 9876:9876 \
-v /usr/local/rocketmq/namesrv/logs:/root/logs \
-v /usr/local/rocketmq/namesrv/store:/root/store \
apache/rocketmq:4.9.3 sh \
mqnamesrv 

Configuration file path: /usr/local/rocketmq/broker/conf/broker.conf

2.9.2、rockerMQ-broker

docker run \
-d \
--name rocketmq-broker \
--network rocketmq \
--restart=always \
-p 10909:10909 \
-p 10911:10911 \
-v /usr/local/rocketmq/broker/logs:/root/logs \
-v /usr/local/rocketmq/broker/store:/root/store \
-v /usr/local/rocketmq/broker/conf:/home/rocketmq/rocketmq-4.9.3/conf \
-e "JAVA_OPT_EXT=-server -Xms256m -Xmx700m" apache/rocketmq:4.9.3 sh mqbroker \
-c /usr/local/rocketmq/broker/conf/broker.conf 

不指定内存:(-e那行换成如下)
apache/rocketmq:4.9.3 sh mqbroker 

2.9.3、rockerMQ-console

docker run \
-d \
--name rocketmq-console \
--network rocketmq \
-e "JAVA_OPTS=-Drocketmq.namesrv.addr=rocketmq-namesrv:9876 \
-Dcom.rocketmq.sendMessageWithVIPChannel=false" \
-p 8000:8080 \
--restart=always \
apacherocketmq/rocketmq-dashboard:latest

2.10、jenkins

docker run \
-itd \
--name jenkins \
-p 8829:8080 \
-p 50000:50000 \
--restart always \
-e JAVA_OPTS=-Duser.timezone=Asia/Shanghai -v /usr/soft/jenkins_home:/var/jenkins_home \
//-v  /usr/local/maven/apache-maven-3.6.3:/usr/local/maven \
-v /etc/localtime:/etc/localtime \
jenkinszh/jenkins-zh

2.11. Start Oracle

docker run \
-d \
-p 1521:1521 \
--name oracle11g \
registry.cn-hangzhou.aliyuncs.com/helowin/oracle_11g \
-v /usr/local/oracle/product/11.2.0/dbhome_2:/home/oracle/app/oracle/product/11.2.0/dbhome_2

Check the container startup status: docker ps | grep oracle11g
Enter the oracle11g container for configuration: docker exec -it oracle11g bash
Switch to the root user for configuration: su root Enter password: helowin Edit
the profile file Configure the ORACLE environment variable: vi /etc/profile , And add the following content, save and exit to make the configuration take effectsource /etc/profile

export ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_2
export ORACLE_SID=helowin
export PATH=$ORACLE_HOME/bin:$PATH

Create soft connection: ln -s $ORACLE_HOME/bin/sqlplus /usr/bin
Switch to oracle user: su - oracle
log in to sqlplus and modify sys and system user passwords:

sqlplus /nolog	# 登录
conn /as sysdba # 连接
alter user system identified by system; # 修改system密码为system
alter user sys identified by sys; # 修改sys密码为sys
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
exit;

Check the oracle instance status: lsnrctl status
insert image description here

2.12、kafka

2.12.1. Start the kafka container

docker run \
-d \
--restart=always \
--log-driver json-file \
--log-opt max-size=100m \
--log-opt max-file=2 \
--name kafka \
-p 9092:9092 \
-e KAFKA_BROKER_ID=0 \
-e KAFKA_ZOOKEEPER_CONNECT=120.53.12.20:2181/kafka \
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://120.53.12.20:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-v /usr/local/kafka/etc/localtime:/etc/localtime \
wurstmeister/kafka

2.12.2. Parameter description:

  • -e KAFKA_BROKER_ID=0 : In the kafka cluster, each kafka has a BROKER_ID to distinguish itself
  • -e KAFKA_ZOOKEEPER_CONNECT=192.168.244.132:2181/kafka : configure zookeeper to manage kafka path 172.16.0.13:2181/kafka
  • -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.244.132:9092 : Register the address and port of kafka to zookeeper. If it is remote access, it should be changed to external network IP, such as Java program access, which cannot be connected.
  • -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 : Configure kafka's listening port
  • -v /etc/localtime:/etc/localtime : container time synchronization virtual machine time

2.12.3. Verify whether Kafka can be used

1. Enter the container: docker exec -it kafka bash
2. Enter the /opt/kafka_2.12-2.3.0/bin/ directory: cd /opt/kafka_2.13-2.8.1/bin/
3. Run the kafka producer Send message: ./kafka-console-producer.sh --broker-list localhost:9092 --topic sun
4. Send message: {"datas":[{"channel":"","metric":"temperature" , "producer": "ijinus", "sn": "IJA0101-00002245", "time": "1543207156000", "value": "80"}], "ver": "1.0"} 5. Open a new
window , run the kafka consumer to receive messages: ./kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic sun --from-beginning
执行完上诉命令后,在生产者窗口中 输入任意内容回车,即可在消费者的窗口查看到消息

2.12.4, kafka management platform

docker pull docker.io/sheepkiller/kafka-manager


docker run \
-it \
-d \
--rm \
-p 9000:9000 \
-e ZK_HOSTS="120.53.12.20:2181" \
--net=host \
sheepkiller/kafka-manager

Guess you like

Origin blog.csdn.net/wmj20001225/article/details/132635557