迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:sparrow开源软件地址:https://gitee.com/jimit/sparrow开源软件介绍:Sparrow分布式数据库中间件 简介
安装依赖库# 环境基于python2.7pip install -r requirements.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com --allow-external mysql-connector-python 配置文件# 配置环境 [debug|sandbox|production(默认)] (可以写入具体执行用户的.bashrc文件中)export JI_ENVIRONMENT=debug# 转存周期 亦即多久从热库转存一次数据到冷库 d以日为周期, w以周为周期, m以月为周期DUMP_CYCLE# 数据转存所需时间 单位秒DATA_FLY_TIME# 数据库默认名称 详细配置中可做差异配置 DATABASE# 数据库默认端口 后面详细配置中可做差异配置DB_PORT# 每次最多返回的记录数DB_RESULT_LIMIT# 热\冷库的时间线字段TIME_LINE_FIELD# 时间线字段的倍率 为了支持时间单位毫秒\纳秒所设, 仅用在dump脚本中, 1为妙, 1000为毫秒...TIME_X# 日志路径 注意读写权限LOG_FILE_BASE# 记录ID刻度的KeyIDsKeeper# Redis相关配置REDISDB_S# 具体的域配置 [states.DBDomain.light.value|states.DBDomain.hot.value|states.DBDomain.cold.value], 对应轻\热\冷 domain# 读写模式 [states.RWMode.SW_SR.value|states.RWMode.BW_AR.value], 对应单例写\单例读, 均衡写\聚合读, 一般轻库\冷库单写单读, 热库均衡写\聚合读rw_mode# 是否禁用该域 [True|False] 被禁用的域,配置信息不被解析disable# 连接池大小 注意: 所有的连接池加起来不能超过数据库环境变量max_connections, (参考命令: SHOW VARIABLES LIKE 'max_connections';)# 包含转存脚本的连接数pool_size 冷库格式
转存的时间
启动# HTTP APIpython sparrow.py# zmq APIpython zmq_scheduler.py &python zmq_sparrow.py & 数据库设计限制
HTTP API插入curl -X "POST" "http://localhost:5000/oo/login_auth" \ -H "Content-Type: application/json" \ -d "{\"id\":1,\"login_name\":\"[email protected]\",\"password\":\"000000.com\",\"create_time\":0}" 更新curl -X "PATCH" "http://localhost:5000/oo/login_auth/1" \ -H "Content-Type: application/json" \ -d "{\"password\":\"newpswd\"}" 获取curl -X "GET" "http://localhost:5000/oo/order_form?filter_str=__order_by__id,__limit__1000,__range__1451197800~1451518200" 删除curl -X "DELETE" "http://localhost:5000/oo/login_auth/1" zmq APIRPC message = dict() message['action'] = 'RPC' message['object_name'] = 'order_form' message['params'] = { 'function': 'generate_id_by', # 支持的方法 'generate_id_by | get_id_of_max_by' } socket.send_json(message) result = socket.recv_json() result: { state: { code: "200", zh-cn: "成功", en-us: "OK" } id: 1 } 插入message = dict()message['action'] = 'POST'message['object_name'] = 'order_form'message['params'] = { 'id': 1, 'create_time': 0, 'finished_time': 0}socket.send_json(message)socket.recv_json()result:{ state: { code: "200", zh-cn: "成功", en-us: "OK" }} 更新message = dict()message['action'] = 'PATCH'message['object_name'] = 'order_form'message['params'] = { 'id': 1, 'create_time': 0, 'finished_time': 0}socket.send_json(message)socket.recv_json()result:{ state: { code: "200", zh-cn: "成功", en-us: "OK" }} 获取message = dict()message['action'] = 'GET'message['object_name'] = 'order_form'message['params'] = { 'filter_str': '__order_by__id,__limit__1000,__range__1451197800~1451518200'}socket.send_json(message)socket.recv_json()result:{ state: { code: "200", zh-cn: "成功", en-us: "OK" }, list: [ {} ]} 删除message = dict()message['action'] = 'DELETE'message['object_name'] = 'order_form'message['params'] = { 'id': 1}socket.send_json(message)socket.recv_json()result:{ state: { code: "200", zh-cn: "成功", en-us: "OK" }} filter_str语法eqid__eq__100id等于100的记录 gtid__gt__100id大于100的记录 ltid__lt__100id小于100的记录 neid__ne__100id不等于100的记录 inid_in__100~101~103id等于100或101或103的记录 order_by__order_by__create_time依据create_time字段顺序排序 order_by_desc__order_by_desc__create_time依据create_time字段倒序排序 limit__limit__10限制返回前10条记录 range__range__1451197800~1451518200以1451197800~1451518200时间范围限定查找空间 综合示例__order_by_desc__id,__limit__1000,__range__1451197800~1451518200依据id字段,倒序返回1451197800~1451518200时间空间中的前1000条记录id__gt__100,id__lt__1000,name__eq__james返回id大于100且小于1000的记录中,name等于james的记录 错误码 error_codes = { '41250': { 'code': '41250', 'zh-cn': u'未支持索引的字段' }, '50050': { 'code': '50150', 'zh-cn': u'MySQL 链接或执行出错' }, '50051': { 'code': '50051', 'zh-cn': u'Redis 链接或执行出错' } } FAQ
Q: 有两种方式 a. 通过修改配置文件my.cnf [mysqld] max_connections = 1000 b. 修改环境变量 SET GLOBAL max_connections = 1000; ![]() |
请发表评论