Fetch the repository succeeded.
-----nacos:
docker run -d -p 8848:8848 --name mynacos \
-e JVM_XMS=512m -e JVM_XMX=512m \
nacos/nacos-server:latest
账户:nacos
密码:nacos
-----redis:
docker run -v /home/redis/redis.conf:/usr/local/etc/redis/redis.conf -v /home/redis/data:/data -p 6379:6379 --name myredis -d --privileged=true redis:6.2.14 redis-server /usr/local/etc/redis/redis.conf
redis.conf
# bind 127.0.0.1 -::1
protected-mode no
port 6379
requirepass "" #填写你的密码
tcp-backlog 511
tcp-keepalive 300
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/data/redis.log" # 日志保存地址
databases 16
always-show-logo no
set-proc-title yes
proc-title-template "{title} {listen-addr} {server-mode}"
save 900 1
save 300 100
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /data
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
lazyfree-lazy-user-flush no
oom-score-adj-values 0 200 800
disable-thp yes
appendonly no
appendfilename "appendonly.aof"
# appendfsync always
appendfsync everysec
# appendfsync no
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
-----kafka:
先安装docker-compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose -k
docker 安装kafka:
docker pull bitnami/zookeeper:3.6
docker pull bitnami/kafka:3.0
docker pull hlebalbau/kafka-manager
两个kafka节点:
cat <<EOF > /home/kafka/kafka.yml
version: "1"
services:
zookeeper:
image: 'bitnami/zookeeper:3.6'
container_name: zookeeper
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
volumes:
- ./zookeeper:/bitnami/zookeeper/data
# restart: always
kafka1:
image: 'bitnami/kafka:3.0'
container_name: kafka1
ports:
- '9092:9092'
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka1:9092
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_HEAP_OPTS=-Xms512m -Xmx512m
volumes:
- ./kafka1:/bitnami/kafka/data
# restart: always
depends_on:
- zookeeper
kafka2:
image: 'bitnami/kafka:3.0'
container_name: kafka2
ports:
- '9093:9093'
environment:
- KAFKA_BROKER_ID=2
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9093
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka2:9093
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_HEAP_OPTS=-Xms512m -Xmx512m
volumes:
- ./kafka2:/bitnami/kafka/data
# restart: always
depends_on:
- zookeeper
kafka_manager:
image: 'hlebalbau/kafka-manager:latest'
container_name: kafka-manager
ports:
- "9099:9099"
environment:
ZK_HOSTS: "zookeeper:2181"
# restart: always
depends_on:
- zookeeper
- kafka1
- kafka2
EOF
创建主题,2个分区:docker exec -it kafka1 kafka-topics.sh --create --topic travel-topic --partitions 2 --replication-factor 2 --bootstrap-server kafka1:9092
单节点:
cat <<EOF > /home/kafka/kafka.yml
version: "1"
services:
zookeeper:
image: 'bitnami/zookeeper:3.6'
container_name: zookeeper
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
volumes:
- ./zookeeper:/bitnami/zookeeper/data
# restart: always
kafka:
image: 'bitnami/kafka:3.0'
container_name: kafka
ports:
- '9092:9092'
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://你的服务器公网ip:9092 #服务器公网ip
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
volumes:
- ./kafka:/bitnami/kafka/data
# restart: always
depends_on:
- zookeeper
EOF
启动:docker-compose -f /home/kafka/kafka.yml up -d
重启:docker-compose -f /home/kafka/kafka.yml restart
关闭:docker-compose -f /home/kafka/kafka.yml down # 停止并删除所有相关的Kafka容器。不删除用stop
查看启动日志:docker-compose -f /home/kafka/kafka.yml logs
创建主题,分区: 分区名为 travel-topic
docker exec -it kafka kafka-topics.sh --create --topic travel-topic --partitions 2 --replication-factor 1 --bootstrap-server kafka:9092
查看已创建主题:
kafka-topics.sh --list --bootstrap-server localhost:9092
查看分区:
kafka-topics.sh --describe --topic travel-topic --bootstrap-server localhost:9092
消费消息:
kafka-console-consumer.sh --topic travel-topic --bootstrap-server localhost:9092
生产消息:
kafka-console-producer.sh --topic travel-topic --bootstrap-server localhost:9092
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。