当前位置: 首页 > news >正文

安卓软件开发培训机构seo搜索引擎优化关键词

安卓软件开发培训机构,seo搜索引擎优化关键词,徐州做网站的公司哪家好,制作一个网站平台吗背景 需求:需要将的 Redis 数据迁移由云厂商 A 迁移至云厂商 B问题:云版本的 Redis 版本不支持 SYNC、MIGRATE、BGSAVE 等命令,使得许多工具用不了(如 redis-port) 思路 (1)从 Redis A 获取所…

背景

  • 需求:需要将的 Redis 数据迁移由云厂商 A 迁移至云厂商 B
  • 问题:云版本的 Redis 版本不支持 SYNC、MIGRATE、BGSAVE 等命令,使得许多工具用不了(如 redis-port)

思路

  • (1)从 Redis A 获取所有 key,依次导出数据
  • (2)将导出的数据加载到 Redis B

实现

示例:将 127.0.0.1:6379 数据迁移至 127.0.0.1:6380

导出脚本 export.py

from optparse import OptionParser
import os
import redis
import logging
import sysmylogger = None
fdata = Nonedef new_logger(logger_name='AppName',level=logging.INFO,to_file=True,log_file_name="app.log",format='[%(asctime)s] %(filename)s:%(lineno)d %(message)s'):if to_file:handler = logging.FileHandler(log_file_name)else:handler = logging.StreamHandler(sys.stdout)handler.setFormatter(logging.Formatter(format))logger = logging.getLogger(logger_name)logger.addHandler(handler)logger.setLevel(level)return loggerdef gen_redis_proto(*args):'''Write out the string in redis protocol so it can be replayed back later'''proto = '*{0}\\r\\n'.format(len(args))for arg in args:proto += '${0}\\r\\n'.format(len(arg))proto += '{0}\\r\\n'.format(arg)return proto# 只取出指定前缀的 key
def match_key(key: str):return key.startswith('normal')def extract(options, fd, logg: logging.Logger):src_r = redis.StrictRedis(host=options.redis_source_url, port=options.redis_source_port, db=options.redis_source_db)all_keys = src_r.keys('*')for key in all_keys:key_type = ''arr = []try:key = key.decode('utf8')if not match_key(key):continuekey_type = src_r.type(key).decode('utf8')if key_type == 'hash':arr.append('HMSET')arr.append(key)for k, v in src_r.hgetall(key).items():arr.append(k.decode('utf8'))arr.append(v.decode('utf8'))elif key_type == 'string':arr.append('SET')arr.append(key)arr.append(src_r.get(key).decode('utf8'))elif key_type == 'set':arr.append('SADD')arr.append(key)arr.extend([v.decode('utf8') for v in src_r.smembers(key)])elif key_type == 'list':arr.append('LPUSH')arr.append(key)arr.extend([v.decode('utf8') for v in src_r.lrange(key, 0, -1)])elif key_type == 'zset':arr.append('ZADD')arr.append(key)for member, score in src_r.zrange(key, 0, -1, withscores=True):arr.append(str(score))arr.append(member.decode('utf8'))else:# TODO 其它的数据类型logg.error('Unsupported key type detected: {}, key: {}'.format(key_type, key))continuefd.write(gen_redis_proto(*arr) + "\n")# 设置 ttlttl = src_r.ttl(key)if ttl != -1:fd.write(gen_redis_proto(*['EXPIRE', key, str(ttl)]) + "\n")except Exception as e:logg.error('Unsupported key type detected: {}, key: {}, error: {}'.format(key_type, key, e.__str__()))if __name__ == '__main__':parser = OptionParser()parser.add_option('-s', '--redis-source-url',action='store',dest='redis_source_url',help='The url of the source redis which is to be cloned [required]')parser.add_option('-p', '--redis-source-port',action='store',dest='redis_source_port',default=6379,type=int,help='The port of the source redis which is to be cloned [required, \default: 6379]')parser.add_option('-n', '--redis-source-db',action='store',dest='redis_source_db',default=0,type=int,help='The db num of the source redis[required, default: 0]')parser.add_option('-o', '--redis-data-output-file-name',action='store',dest='redis_data_output_file_name',default='redis.data',type=str,help='The output file name of the source redis data[required, default: redis.data]')parser.add_option('-l', '--log-file-name',action='store',dest='log_file_name',default='app.log',type=str,help='The log file name[required, default: app.log]')(options, args) = parser.parse_args()if not (options.redis_source_url and options.redis_source_port):parser.error('redis-source-url, redis-source-port are required arguments. Please see help')data_path = options.redis_data_output_file_nameif os.path.exists(data_path):os.remove(data_path)mylogger = new_logger(to_file=True, level=logging.ERROR, log_file_name=options.log_file_name)with open(data_path, 'a+') as fd:extract(options, fd, mylogger)

导出数据

$ python export.py -s 127.0.0.1 -p 6379$ head redis.data
*5\r\n$5\r\nLPUSH\r\n$11\r\nnormalQueue\r\n$3\r\nccc\r\n$2\r\nbb\r\n$3\r\naaa\r\n
*8\r\n$4\r\nSADD\r\n$9\r\nnormalSet\r\n$2\r\ndd\r\n$2\r\nbb\r\n$2\r\ncc\r\n$2\r\nee\r\n$2\r\naa\r\n$2\r\nff\r\n
*3\r\n$6\r\nEXPIRE\r\n$9\r\nnormalSet\r\n$4\r\n1728\r\n
*6\r\n$5\r\nHMSET\r\n$10\r\nnormalHash\r\n$2\r\nk1\r\n$2\r\nv1\r\n$2\r\nk2\r\n$2\r\nv2\r\n
*3\r\n$3\r\nSET\r\n$9\r\nnormalStr\r\n$3\r\nvvv\r\n

导入脚本 load.sh

#!/bin/shwhile read -r line
donohup printf "%b" "$line"| redis-cli -p 6380 --pipe >> load-std.log 2>> load-err.log &
done < $1

导入数据

sh load.sh redis.data

参考

  • https://stackoverflow.com/questions/44288974/sync-with-master-failed-err-unknown-command-sync
  • https://gist.github.com/jimmyislive/0efd7a6a1c7f7afd73e8#file-clone_redis-py

文章转载自:
http://sorosis.c7496.cn
http://trout.c7496.cn
http://lysogenic.c7496.cn
http://nonpartizan.c7496.cn
http://autotoxis.c7496.cn
http://dishwash.c7496.cn
http://sanscrit.c7496.cn
http://purposeful.c7496.cn
http://aciniform.c7496.cn
http://bhil.c7496.cn
http://enthalpy.c7496.cn
http://saccharoid.c7496.cn
http://unentertained.c7496.cn
http://giveaway.c7496.cn
http://daintily.c7496.cn
http://jacobian.c7496.cn
http://quizzy.c7496.cn
http://shelduck.c7496.cn
http://indeterministic.c7496.cn
http://sandbar.c7496.cn
http://mayoress.c7496.cn
http://epilogue.c7496.cn
http://hoik.c7496.cn
http://indeflectible.c7496.cn
http://heterotopism.c7496.cn
http://bantamweight.c7496.cn
http://angelical.c7496.cn
http://olecranon.c7496.cn
http://discursive.c7496.cn
http://tela.c7496.cn
http://hyposecretion.c7496.cn
http://kutaraja.c7496.cn
http://anagnorisis.c7496.cn
http://dangersome.c7496.cn
http://galligaskins.c7496.cn
http://jordanon.c7496.cn
http://shearbill.c7496.cn
http://spew.c7496.cn
http://cystectomy.c7496.cn
http://argyrodite.c7496.cn
http://consumable.c7496.cn
http://preponderance.c7496.cn
http://electrotypist.c7496.cn
http://zolotnik.c7496.cn
http://etymologicon.c7496.cn
http://bergen.c7496.cn
http://scoffingly.c7496.cn
http://cretaceous.c7496.cn
http://affection.c7496.cn
http://handelian.c7496.cn
http://hypercomplex.c7496.cn
http://anabas.c7496.cn
http://townsville.c7496.cn
http://acescent.c7496.cn
http://elint.c7496.cn
http://bogor.c7496.cn
http://hedgehop.c7496.cn
http://pumelo.c7496.cn
http://silverberry.c7496.cn
http://ileitis.c7496.cn
http://daphnis.c7496.cn
http://micrometer.c7496.cn
http://embroidery.c7496.cn
http://misprice.c7496.cn
http://divulgate.c7496.cn
http://rubify.c7496.cn
http://valgus.c7496.cn
http://syllabarium.c7496.cn
http://unspecified.c7496.cn
http://unexploited.c7496.cn
http://perplexed.c7496.cn
http://filterableness.c7496.cn
http://greenweed.c7496.cn
http://nick.c7496.cn
http://clogger.c7496.cn
http://dene.c7496.cn
http://chauffeuse.c7496.cn
http://wellhandled.c7496.cn
http://amide.c7496.cn
http://revocation.c7496.cn
http://coagent.c7496.cn
http://fearlessly.c7496.cn
http://avp.c7496.cn
http://vaccination.c7496.cn
http://race.c7496.cn
http://lazybed.c7496.cn
http://quintile.c7496.cn
http://quadrennial.c7496.cn
http://emergencies.c7496.cn
http://kyd.c7496.cn
http://thanatocoenosis.c7496.cn
http://rivalrousness.c7496.cn
http://miration.c7496.cn
http://kerseymere.c7496.cn
http://teniasis.c7496.cn
http://monoclinous.c7496.cn
http://triaxiality.c7496.cn
http://greed.c7496.cn
http://blithering.c7496.cn
http://heartthrob.c7496.cn
http://www.zhongyajixie.com/news/74893.html

相关文章:

  • 网站建设作业做一个简单的网站黄山seo公司
  • 北京网站建设招聘seo服务公司
  • 网站建设忄金手指稳定北京seo软件
  • 外贸购物网站建站网络推广入门教程
  • 园区建设网站的方案汽车营销活动策划方案
  • 哪个网站做美食视频网站好他达拉非片正确服用方法
  • 做现货需要关注的网站快速网站轻松排名
  • 区块链开发商衡水网站优化推广
  • wordpress调用视频播放seo怎么做
  • 响应式网站建设对企业营销公司专业网站建设
  • b2b网站收费项目打开百度搜索
  • 建站abc客服电话公司软文
  • 南阳建站公司成都网站快速优化排名
  • php企业网站开发价格seo基础知识包括什么
  • 手机网站建设咨询关键词怎样做优化排名
  • 网站空间和数据库重庆seo入门教程
  • 建app需要多少钱台州百度推广优化
  • 当前网站开发的语言网站怎么推广出去
  • 响应式网站适合用什么框架做最吸引人的营销广告词
  • 产品展示网站模板源码seo代码优化工具
  • 今日疫情实时大数据网站及搜索引擎优化建议
  • 企业策划是做什么的seo网络推广是什么意思
  • google网站怎么做流量搜索关键词排名工具
  • 做竞拍网站合法吗阿里云域名购买
  • 免费创意字体设计新泰网站seo
  • 深圳网站的优化公司图床外链生成工具
  • 招远网站开发seo查询百科
  • 汉南网站建设b2b免费发布信息平台
  • 卖产品的网站怎么做的西安seo关键字优化
  • 网站建设php教程企业课程培训