All Projects → arstercz → Atlas_auto_setline

arstercz / Atlas_auto_setline

Licence: other
a tool for automatic offline/online unusable slave node in Atlas open source software

Programming Languages

perl
6916 projects

Projects that are alternatives of or similar to Atlas auto setline

react-health-check
Lightweight React hook for checking health of API services.
Stars: ✭ 28 (-40.43%)
Mutual labels:  offline
Canvas-Vision
📷 Wallpaper Downloading Android App
Stars: ✭ 14 (-70.21%)
Mutual labels:  offline
HelpOff
Providing help via offline system : Runner-Up at NMIMS Hackathon 2018
Stars: ✭ 20 (-57.45%)
Mutual labels:  offline
Telegraf-Test
Telegraf Test - Simple Test ToolKit of Telegram Bots
Stars: ✭ 22 (-53.19%)
Mutual labels:  offline
examples-android
Android demo application for GLMap framework
Stars: ✭ 14 (-70.21%)
Mutual labels:  offline
cobra-policytool
Manage Apache Atlas and Ranger configuration for your Hadoop environment.
Stars: ✭ 16 (-65.96%)
Mutual labels:  atlas
xyTalk-pc
企业IM即时通讯定制平台,百万级高并发、高性能、可扩展、安全、高交互体验的企业通信和协作im平台。包含通讯服务、客户端(PC、Android、iOS)、Web门户(用于集成企业应用)、WebAPI。
Stars: ✭ 48 (+2.13%)
Mutual labels:  offline
aws-mobile-appsync-events-starter-ios
GraphQL starter application with Realtime and Offline functionality using AWS AppSync
Stars: ✭ 99 (+110.64%)
Mutual labels:  offline
choo-offline
🔧 offline first support for choo apps
Stars: ✭ 12 (-74.47%)
Mutual labels:  offline
pyHeadspace
command-line script to download headspace packs, singles, everyday meditation and other sessions. You could also download all packs at once
Stars: ✭ 37 (-21.28%)
Mutual labels:  offline
service-workers-offline
Code for the Service Workers / PWA section of the Service Workers & Offline course by Kyle Simpson
Stars: ✭ 99 (+110.64%)
Mutual labels:  offline
BlurringAtlasForUGUI
A blur effect for uGUI in Unity, that is effective even for atlas images including dynamic fonts.
Stars: ✭ 29 (-38.3%)
Mutual labels:  atlas
global-upvote
A progressive web app that provides top voted stories across the web, summarized and updated every sixty seconds.
Stars: ✭ 25 (-46.81%)
Mutual labels:  offline
progressive
This is the repository for my course, Building a Progressive Web App on LinkedIn Learning and Lynda.com.
Stars: ✭ 26 (-44.68%)
Mutual labels:  offline
node-libzim
Binding to libzim, read/write ZIM files in Javascript
Stars: ✭ 23 (-51.06%)
Mutual labels:  offline
organicmaps
🍃 Organic Maps is a free Android & iOS offline maps app for travelers, tourists, hikers, and cyclists. It uses crowd-sourced OpenStreetMap data and is developed with love by MapsWithMe (MapsMe) founders and our community. No ads, no tracking, no data collection, no crapware. Your donations and positive reviews motivate and inspire our small team!
Stars: ✭ 3,689 (+7748.94%)
Mutual labels:  offline
FastWebView
自定义本地缓存策略和资源加载策略,突破原生WebView缓存限制,实现多种缓存模式,支持离线加载和预加载,可大幅提升加载速度。
Stars: ✭ 211 (+348.94%)
Mutual labels:  offline
hexo-offline
Out-of-the-box hexo offline experience
Stars: ✭ 69 (+46.81%)
Mutual labels:  offline
react-weather-app
⛅️ PWA Weather App made with ReactJS
Stars: ✭ 147 (+212.77%)
Mutual labels:  offline
File-Explorer
A File Manager with stunning design & astonishing develops, beautifully written in PHP, everything fused in a single file.
Stars: ✭ 31 (-34.04%)
Mutual labels:  offline

Atlas_auto_setline

a tool for automatic offline/online unusable slave node in Atlas open source software

此脚本配合360 Atlas中间件的使用, 检测slave状况(延迟或slavethread错误),自动上线或下线存在于Atlas admin接口里的slave节点;

  • 不对master做改动,仅检测slave信息;
  • 支持多个slave, 详见 perldoc atlas_auto_setline说明;
  • 多个atlas端口必须是同一实例下的;
  • 新加循环检测, 默认每10s检测一次, 在上下线过程中忽略kill的INT和TERM两个信号;

需要安装的依赖:

DBI
DBD::mysql
Config::Auto

db.conf文件配置(单实例下的多个库)举例,:

#slave host and atlas admin host info.
slave_host:172.30.0.15,172.30.0.16     #多台slave以','分隔
slave_port:3306                        #slave 服务端口
slave_user:slave_user                  #可以检测slave 延迟状态的用户
slave_pass:xxxxxx                      #slave_user口令   
atlas_host:172.30.0.18                 #atlas对外服务的ip, 建议是虚ip
atlas_port:5012                        #atlas对外服务的管理端口, 一个atlas的mysql-proxyd占用一个端口, 如果起了多个, 以','分隔指定多个端口
atlas_user:admin                       #atlas的管理账户
atlas_pass:xxxxxxx                     #atlas管理账户的口令信息
mail:[email protected]

atlas_port和atlas_user和atlas_pass三个参数应该指定atlas的管理端口和管理的用户信息, 用于读取 atlas 的后端状态backend.

可添加到任务计划循环检测, 如下:

#!/bin/bash
(
   flock -x -n 200
   if [[ $? -ne 0 ]]; then
     echo "Failed acquiring lock"
     exit 1
   fi
   perl atlas_auto_setline.pl --conf=db.conf --verbose --setline --interval=10 >>setline.log 2>&1
 ) 200>/web/scripts/atlas_auto/atlas.lock

测试说明:

关闭SQL_THREAD:

mysql> select * from backends;
+-------------+-------------------+-------+------+
| backend_ndx | address           | state | type |
+-------------+-------------------+-------+------+
|           1 | 172.30.0.14:3306 | up    | rw   |
|           2 | 172.30.0.14:3306 | up    | ro   |
|           3 | 172.30.0.15:3306 | up    | ro   |
|           4 | 172.30.0.16:3306 | up    | ro   |
+-------------+-------------------+-------+------+
4 rows in set (0.00 sec)

停止ip为16的slave的复制线程后(多个端口,多个offline操作):

# perl atlas_auto_setline.pl --conf=db.conf --verbose --setline --threshold=30
 +---2014-04-15 11:53:01, 172.30.0.15, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 13
 +---2014-04-15 11:53:01, 172.30.0.16, Slave_IO_Running: No, Slave_SQL_Running: No, Seconds_Behind_Master: NULL
 +-- 2014-04-15 11:53:01 OK SET offline node 172.30.0.16:3306

atlas下线:

mysql> select * from backends;
+-------------+-------------------+-------+------+
| backend_ndx | address           | state | type |
+-------------+-------------------+-------+------+
|           1 | 172.30.0.14:3306 | up     | rw   |   
|           2 | 172.30.0.14:3306 | up     | ro   |   
|           3 | 172.30.0.15:3306 | up     | ro   |   
|           4 | 172.30.0.16:3306 | offline| ro   |   
+-------------+-------------------+-------+------+
4 rows in set (0.00 sec)

启动SQL_THREAD:

# perl atlas_auto_setline.pl --conf=db.conf --verbose --setline --threshold=30
 +---2014-04-15 11:54:01, 172.30.0.15, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-04-15 11:54:01, 172.30.0.16, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +-- 2014-04-15 11:54:01 OK SET online node 172.30.0.16:5012

手工offline一个节点:

mysql> set offline 4;         
+-------------+------------------+---------+------+
| backend_ndx | address          | state   | type |
+-------------+------------------+---------+------+
|           3 | 172.30.0.16:3306 | offline | ro   |
+-------------+------------------+---------+------+

1 row in set (0.00 sec)


mysql> select * from backends;
+-------------+-------------------+-------+------+
| backend_ndx | address           | state | type |
+-------------+-------------------+-------+------+
|           1 | 172.30.0.14:3306 | up     | rw   |   
|           2 | 172.30.0.14:3306 | up     | ro   |   
|           3 | 172.30.0.15:3306 | up     | ro   |   
|           4 | 172.30.0.16:3306 | offline| ro   |   
+-------------+-------------------+-------+------+
4 rows in set (0.00 sec)

运行脚本使其上线:

# perl atlas_auto_setline.pl --conf=db.conf --verbose --setline --threshold=30
 +---2014-04-15 11:56:01, 172.30.0.15, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-04-15 11:56:01, 172.30.0.16, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +-- 2014-04-15 11:56:01 OK SET online node 172.30.0.16:5012

上线成功:

循环检测

# perl atlas_auto_setline.pl --conf=db.conf --verbose --setline --threshold=30 --interval=10
 +---2014-09-22 16:22:42, 172.30.0.154, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:22:42, 172.30.0.133, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:22:52, 172.30.0.154, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:22:52, 172.30.0.133, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:23:02, 172.30.0.154, Slave_IO_Running: No, Slave_SQL_Running: No, Seconds_Behind_Master: NULL
 +-- 2014-09-22 16:23:02 OK SET offline node 172.30.0.154:5012
 +---2014-09-22 16:23:02, 172.30.0.133, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:23:12, 172.30.0.154, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +-- 2014-09-22 16:23:12 OK SET online node 172.30.0.154:5012
 +---2014-09-22 16:23:12, 172.30.0.133, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:23:22, 172.30.0.154, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:23:22, 172.30.0.133, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0
 +---2014-09-22 16:23:32, 172.30.0.154, Slave_IO_Running: Yes, Slave_SQL_Running: Yes, Seconds_Behind_Master: 0

说明

MySQL Server 版本为 5.6, 运行脚本的时候会有安全提示 Warning: Using a password on the command line interface can be insecure., 这个错误信息可以忽略, 不影响脚本的执行. perl DBI驱动不兼容atlas的管理端口, 只能通过 mysql -h 的方式调用取到结果, 5.6 的警告信息可以忽略, 也可以在my.cnf 配置里[client]设置密码信息, 然后脚本里去掉 -p$pass这部分就可以避免出现错误信息, 或使用 2>/dev/null 将错误重定向. 增加隐藏连接 MySQL 的密码信息功能, 参考文章 safe-bash-with-mysql

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].