更新脚本

This commit is contained in:
ChenYi 2025-08-29 17:31:21 +08:00
parent 4ce0bb7202
commit 8488cbd847
3 changed files with 31 additions and 26 deletions

View File

@ -25,4 +25,4 @@ ADMIN_WEB_PORT=30711
PULSAR_ADMIN_USER=admin PULSAR_ADMIN_USER=admin
PULSAR_ADMIN_PASSWORD=0fd7afb8b0d04e6abc4fdfdac2190a79 PULSAR_ADMIN_PASSWORD=0fd7afb8b0d04e6abc4fdfdac2190a79
IOTDB_ROOT_PASSWORD=Lixiao@1980 IOTDB_ROOT_PASSWORD=Lixiao@1980
MYSQL_ROOT_PASSWORD=JiShe!aqG#5kGgh&0 MYSQL_ROOT_PASSWORD='JiShe!aqG#5kGgh&0'

View File

@ -34,7 +34,7 @@ services:
hostname: pulsar-cluster-init hostname: pulsar-cluster-init
command: > command: >
/bin/bash -c /bin/bash -c
"bin/pulsar initialize-cluster-metadata --cluster pulsar-cluster-1 --zookeeper zookeeper:${PULSAR_ZOOKEEPER_PORT} --configuration-store zookeeper:${PULSAR_ZOOKEEPER_PORT} --web-service-url http://\${SERVER_IP}:\${PULSAR_ADMIN_PORT} --broker-service-url pulsar://\${SERVER_IP}:\${PULSAR_BROKER_PORT} || echo 'Cluster metadata already exists'" "bin/pulsar initialize-cluster-metadata --cluster pulsar-cluster-1 --zookeeper zookeeper:${PULSAR_ZOOKEEPER_PORT} --configuration-store zookeeper:${PULSAR_ZOOKEEPER_PORT} --web-service-url http://${SERVER_IP}:${PULSAR_ADMIN_PORT} --broker-service-url pulsar://${SERVER_IP}:${PULSAR_BROKER_PORT} || echo 'Cluster metadata already exists'"
depends_on: depends_on:
zookeeper: zookeeper:
condition: service_healthy condition: service_healthy
@ -136,23 +136,23 @@ services:
/bin/bash -c /bin/bash -c
" "
# 等待broker就绪 # 等待broker就绪
until bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' clusters list; do until bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' clusters list; do
echo 'Waiting for Pulsar broker to be ready...' echo 'Waiting for Pulsar broker to be ready...'
sleep 5 sleep 5
done; done;
# 创建租户和命名空间 # 创建租户和命名空间
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' tenants create public --allowed-clusters pulsar-cluster-1 -r admin || echo 'Tenant public already exists'; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' tenants create public --allowed-clusters pulsar-cluster-1 -r admin || echo 'Tenant public already exists';
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' namespaces create public/default || echo 'Namespace public/default already exists'; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' namespaces create public/default || echo 'Namespace public/default already exists';
# 创建非持久化主题 # 创建非持久化主题
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' topics create non-persistent://public/default/default-topic || echo 'Topic non-persistent://public/default/default-topic already exists'; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' topics create non-persistent://public/default/default-topic || echo 'Topic non-persistent://public/default/default-topic already exists';
# 设置命名空间策略 # 设置命名空间策略
echo 'Setting namespace policies...'; echo 'Setting namespace policies...';
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-subscription-types-enabled public/default --types NonDurable; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-subscription-types-enabled public/default --types NonDurable;
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-message-ttl public/default --messageTTL 0; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-message-ttl public/default --messageTTL 0;
bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"\${PULSAR_ADMIN_USER}\",\"password\":\"\${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-retention public/default --sizeLimit -1 --timeLimit -1; bin/pulsar-admin --admin-url http://pulsar-broker:${PULSAR_ADMIN_PORT} --auth-plugin org.apache.pulsar.client.impl.auth.AuthenticationBasic --auth-params '{\"userId\":\"${PULSAR_ADMIN_USER}\",\"password\":\"${PULSAR_ADMIN_PASSWORD}\"}' namespaces set-retention public/default --sizeLimit -1 --timeLimit -1;
echo 'Pulsar initialization completed with Basic Authentication!'; echo 'Pulsar initialization completed with Basic Authentication!';
" "
@ -263,10 +263,14 @@ services:
stdin_open: true stdin_open: true
tty: true tty: true
depends_on: depends_on:
- mysql-service mysql-service:
- redis-service condition: service_started
- iotdb-standalone-service redis-service:
- pulsar-init condition: service_started
iotdb-standalone-service:
condition: service_started
broker:
condition: service_started
networks: networks:
- pulsar-net - pulsar-net
@ -285,7 +289,8 @@ services:
stdin_open: true stdin_open: true
tty: true tty: true
depends_on: depends_on:
- admin-api-service admin-api-service:
condition: service_completed_successfully
networks: networks:
- pulsar-net - pulsar-net

View File

@ -198,15 +198,15 @@ echo ""
echo "🎉 Pulsar 基本认证集群启动完成!" echo "🎉 Pulsar 基本认证集群启动完成!"
echo "" echo ""
echo "📋 连接信息:" echo "📋 连接信息:"
echo " Pulsar Broker: \${SERVER_IP}:\${PULSAR_BROKER_PORT}" echo " Pulsar Broker: ${SERVER_IP}:$PULSAR_BROKER_PORT}"
echo " Pulsar Admin: http://\${SERVER_IP}:\${PULSAR_ADMIN_PORT}" echo " Pulsar Admin: http://${SERVER_IP}:$PULSAR_ADMIN_PORT}"
echo " IoTDB: \${SERVER_IP}:\${IOTDB_PORT} (root/\${IOTDB_ROOT_PASSWORD})" echo " IoTDB: ${SERVER_IP}:${IOTDB_PORT} (root/${IOTDB_ROOT_PASSWORD})"
echo " Redis: \${SERVER_IP}:6379" echo " Redis: ${SERVER_IP}:6379"
echo " MySQL: \${SERVER_IP}:\${MYSQL_PORT}" echo " MySQL: ${SERVER_IP}:$MYSQL_PORT}"
echo " Admin API: http://\${SERVER_IP}:\${ADMIN_API_PORT}" echo " Admin API: http://${SERVER_IP}:$ADMIN_API_PORT}"
echo " Admin UI: http://\${SERVER_IP}:\${ADMIN_WEB_PORT}" echo " Admin UI: http://${SERVER_IP}:$ADMIN_WEB_PORT}"
echo " 用户名: \${PULSAR_ADMIN_USER}" echo " 用户名: ${PULSAR_ADMIN_USER}"
echo " 密码: \${PULSAR_ADMIN_PASSWORD}" echo " 密码: ${PULSAR_ADMIN_PASSWORD}"
echo "" echo ""
echo "🔧 常用命令:" echo "🔧 常用命令:"
echo " 查看状态: docker compose ps" echo " 查看状态: docker compose ps"
@ -214,9 +214,9 @@ echo " 查看日志: docker compose logs -f"
echo " 停止服务: docker compose down" echo " 停止服务: docker compose down"
echo "" echo ""
echo "🧪 测试连接:" echo "🧪 测试连接:"
echo " Pulsar: curl -u \${PULSAR_ADMIN_USER}:\${PULSAR_ADMIN_PASSWORD} http://\${SERVER_IP}:\${PULSAR_ADMIN_PORT}/admin/v2/clusters" echo " Pulsar: curl -u $PULSAR_ADMIN_USER}:$PULSAR_ADMIN_PASSWORD} http://$SERVER_IP}:$PULSAR_ADMIN_PORT}/admin/v2/clusters"
echo " Redis: redis-cli -h \${SERVER_IP} -p 6379 ping" echo " Redis: redis-cli -h ${SERVER_IP} -p 6379 ping"
echo " MySQL: mysql -h \${SERVER_IP} -P \${MYSQL_PORT} -u root -p\${MYSQL_ROOT_PASSWORD} -e 'SELECT 1'" echo " MySQL: mysql -h ${SERVER_IP} -P ${MYSQL_PORT} -uroot -p${MYSQL_ROOT_PASSWORD} -e 'SELECT 1'"
echo " IoTDB: docker exec -it iotdb-standalone ./start-cli.sh -h iotdb-standalone -u root -p Lixiao@1980" echo " IoTDB: docker exec -it iotdb-standalone ./start-cli.sh -h iotdb-standalone -u root -p Lixiao@1980"
echo "" echo ""
echo "🎯 等待服务启动完成..." echo "🎯 等待服务启动完成..."