如何使用Elasticsearch和cAdvisor监控Docker容器
时间:2025-11-05 00:36:59 出处:数据库阅读(143)

复制#!/usr/bin/env bash # # Create a Swarm Mode cluster with a single master and a configurable number of workers workers=${WORKERS:-"worker1 worker2"} ####################################### # Creates a machine on Digital Ocean # Globals: # DO_ACCESS_TOKEN The token needed to access DigitalOceans API # Arguments: # $1 the actual nameto give to the machine ####################################### create_machine() { docker-machine create -d digitalocean --digitalocean-access-token=$DO_ACCESS_TOKEN --digitalocean-size 2gb $1 } ####################################### # Executes a command on the specified machine # Arguments: # $1 The machine on which to run the command # $2..$n The command toexecuteon that machine ####################################### machine_do() { docker-machine ssh $@ } main() { if [ -z "$DO_ACCESS_TOKEN" ]; then echo "Please export a DigitalOcean Access token: https://cloud.digitalocean.com/settings/api/tokens/new" echo "export DO_ACCESS_TOKEN=<yourtokenhere>" exit 1 fi if [ -z "$WORKERS" ]; then echo "You havent provided your workers by setting the \$WORKERS environment variable,何使和 using the default ones: $workers" fi # Create the firstandonly master echo "Creating the master" create_machine master1 master_ip=$(docker-machine ip master1) # Initialize the swarm mode on it echo "Initializing the swarm mode" machine_do master1 docker swarm init --advertise-addr $master_ip # Obtain the token to allow workers tojoin worker_tkn=$(machine_do master1 docker swarm join-token -q worker) echo "Worker token: ${worker_tkn}" # Createandjoin the workers for worker in $workers; do echo "Creating worker ${worker}" create_machine $worker machine_do $worker docker swarm join--token $worker_tkn $master_ip:2377 done } main $@ 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.31.32.33.34.35.36.37.38.39.40.41.42.43.44.45.46.47.48.49.50.51.52.53.54.55.56.57.58.59.60.61.62.63.64.65.66.67.
分享到:
温馨提示:以上内容和图片整理于网络,仅供参考,希望对您有帮助!如有侵权行为请联系删除!