对称性——一种微型集群的集群管理系统
mc2-symmetr的Python项目详细描述
对称性
MC2的群集管理工具。
构建
要创建虚拟环境并安装需求,请运行(默认情况下,它使用python3.7
,您可以更改
在Makefile
变量中VENV_BIN
)
make venv
建立docker映像(可能需要sudo
)
make docker-build-all
与Docker运行对称性
用集群中的信息填充etc/nodes.ini
。
然后可以使用
make start
并将浏览器指向http://localhost:5000/ui/dashboard
停止使用
make stop
两个命令都在docker/symmetry/docker-compose.yml
上使用docker-compose
,可能需要sudo
手动运行对称组件
先决条件
确保virtualenv已激活
source .venv/bin/activate
symmetry向redis发布和读取遥测数据, 所以您首先需要一个正在运行的redis实例:
redis-server
启动遥测deamon
通过
python -m symmetry.cli.telemd
telemd
还接受各种参数来控制运行时方面(激活-h
标志)。
例如,要每0.5秒禁用电源监视和探测节点,请运行
python -m symmetry.cli.telemd --power-disable --agent-interval=.5
您可以通过支持主题来验证遥测守护程序是否发送数据 通过redis cli:
redis-cli psubscribe "telemetry:*"
启动群集deamon
启动群集守护程序(控制群集状态)
python -m symmetry.cli.clusterd
websocket服务器
启动仪表板的WebSocket服务器:
python -m symmetry.cli.websocket
websocket正在端口8082
上运行,并自动连接到localhost:6379
上的本地redis服务器。
与ws://ip:8082/topic
连接以接收给定topic
的所有已发布消息。
运行仪表板
为应用程序提供Gunicorn
gunicorn -w 4 --preload -b 0.0.0.0:5000 \
-c symmetry/webapp/gunicorn.conf.py \
symmetry.webapp.wsgi:api
将浏览器指向http://localhost:5000/ui/dashboard。
使用对称性
创建服务
若要在群集中创建新服务,必须将请求发送到
api/services/{service_id}
端点,service_id
是新服务。
POST
请求有一个可选的
(tar-exported docker image)和一个强制(服务
说明)主体元素。
服务描述的结构如下:
%YAML1.2---id:#must be same id as in endpointmaintainer:#the uploader of the servicename:#"Pretty" version of the nameversion:#any version numberdescription:#simple descriptionimage_tag:#if docker image uploaded then this tag must be provided by the image. otherwise it is pulled port:#the port which is exposed by the service
正确执行后,答案应该如下:
{"name":"Test Service","version":"1.0.0","desc":"This is a simple test_service","maintainer":"silvio","10.0.0.3":"1"}
其他客户端脚本
记录遥测数据
您可以使用遥测客户端cli.telemc
在
各种方式。
# prints to system out
python -m symmetry.cli.telemc
# writes to a csv file
python -m symmetry.cli.telemc --file /tmp/telemetry-results.csv
Arduino功率计
要每隔0.5秒从Arduino电源监视器中采样瓦特数,请致电:
python -m symmetry.cli.power --interval 0.5
这会像遥测守护进程一样将数据写入redis实例。