前言:
最近正在做一个集群配置平台,以前也做过类似的demo,记得是去年做的时候用的是paramiko模块,先说他的连接配置是用ssh,交互也有时用pexpect。在复杂的配置下会经常出问题的。 配置主要是出在正则匹配的方面。
现在到了新公司,第一件是就是重构代码,目的是做成一个全网集群的配置工具,支持nginx、lvs、haproxy多种集群配置的平台。 里面含有流程的自动流转审批,在测试服务器上做测试,配置文件的操作之前的配置,及出问题时候的回滚。
因为新公司的环境是puppet,打算推广下saltstack ! 我还是喜欢saltsatck那种简便的二次开发。
自己现在的思路是:
通过web框架的模板来渲染配置配置,最好是把nginx.conf keepalived.conf 整形到 yaml类似的格式里面。推送到客户端只是get url,通过接口的ip和类型,给你渲染出配置文件,直接下载就行了。
这能说是没招呀~ 哎。。。。 saltstack 这东西不错 !
下面的集群管理平台,我自己也就写了两天,把前端页面及后端的mysql库做了设计。 我会把后续思路和解决方案更新给大家下。 还没有上线,只是给大家一个样子参考 ~
前端没啥东西,就是写了点表单的验证,及美化的js特效。
对于集群的参数,做了特定的格式规范 !
特殊说明,这里可以填写一些特殊的需求 !
点提交后,会给领导发邮件等待确认~
数据是随便写的 ~
mysqldb 获取timestamp的出现点问题,大家可以参考下 ~
ValueError ValueError: unsupported format character 'm' (0x6d) at index 138 Traceback (most recent call last)
对于%的符号,尤其格式化时间用的多,需要这么搞
FROM_UNIXTIME(unix_timestamp(ltime),"%%m-%%d %%H:%%i")
领导说,页面看起来不舒服,改版
关于saltstack这边对于lvs yaml的过程
global_defs: [email protected] vrrp_sync_group: [VI_1,VI_2] vrrp_instance: VI_1: state: master interface: eth0 virtual_router_id: 51 priority: 100 advert_int: 1 authentication: auth_type: PASS auth_pass: 1111 virtual_ipaddress: vip: 192.168.1.100 virtual_server: delay_loop: 5 lb_algo rr: wlc lb_kind DR: DR persistence_timeout: 50 protocol: TCP - real_server: ip: 192.168.1.236 port: 80 weight: weight mode: HTTP_GET heathmonitor: path: /mo/monitor.html connect_timeout: 3 nb_get_retry: 3 delay_before_retry: 3 - real_server: ip: 192.168.1.236 port: 80 weight: weight mode: HTTP_GET heathmonitor: path: /mo/monitor.html connect_timeout: 3 nb_get_retry: 3 delay_before_retry: 3
遇到了一个问题,jinja2的list循环的时候取出他的index 。
这里是用在lvs haproxy nginx的数据渲染的 !
{% for i in ldata['vrrp_sync_group'] %} {{ ldata['vrrp_instance']['VI_1']['virtual_ipaddress'][loop.index0]['vip_server']['vip'] }} {% endfor %} {% for i in range(ldata['vrrp_sync_group']|count) %} {{ ldata['vrrp_instance']['VI_1']['virtual_ipaddress'][loop.index0]['vip_server']['vip'] }} {% endfor %}
已经渲染好keepalived.conf 的测试页面
样式更新了下,都放在一起,确实有点紧
又加了几个功能,把昨天写的逻辑重新变更下,明天开始做后端 !
实时流量图
wgetconf
jinja2的一个问题 {% if type == "kkk" %} 里面的type是jinja2里面的关键字 大家避开这个关键字就行了。。。 原本以为是自己逻辑的问题,搞了半天是关键字的冲突 !!!
这个实现的原理就是利用saltstack的pubsub速度,实现实时数据收集 !
这两天在忙dba的平台,这个东西进展有点缓慢!
加了表单验证
针对返回值的各种判断,和连续ajax
服务器的本身调试页面!
日志图表分析
如果你的uwsgi碰见 500的错误,请一定要先检查你的app程序。
--- no python application found, check your startup logs for errors --- [pid: 19956|app: -1|req: -1/25] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:00 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19958|app: -1|req: -1/26] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:05 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19958|app: -1|req: -1/27] 10.58.101.248 () {38 vars in 931 bytes} [Tue Apr 8 11:24:07 2014] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19958|app: -1|req: -1/28] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:10 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19956|app: -1|req: -1/29] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:15 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19956|app: -1|req: -1/30] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:20 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19956|app: -1|req: -1/31] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:25 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19958|app: -1|req: -1/32] 10.58.101.248 () {36 vars in 604 bytes} [Tue Apr 8 11:24:28 2014] GET / => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19936|app: -1|req: -1/33] 10.58.101.248 () {36 vars in 555 bytes} [Tue Apr 8 11:24:28 2014] GET /favicon.ico => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0) --- no python application found, check your startup logs for errors --- [pid: 19956|app: -1|req: -1/34] 10.58.102.250 () {46 vars in 1025 bytes} [Tue Apr 8 11:24:30 2014] POST /dataapi => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
陆续更新 ~
本文出自 “峰云,就她了。” 博客,谢绝转载!