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

宁波建站公司哪家服务好石家庄seo报价

宁波建站公司哪家服务好,石家庄seo报价,我做网站价格,兰溪做网站https://help.aliyun.com/zh/es/use-cases/use-logstash-to-migrate-full-or-incremental-data-from-self-managed-elasticsearch-to-alibaba-cloud-elasticsearch 在进行数据迁移时,Logstash会帮助您自动创建索引,但是自动创建的索引可能与您待迁移的索…

https://help.aliyun.com/zh/es/use-cases/use-logstash-to-migrate-full-or-incremental-data-from-self-managed-elasticsearch-to-alibaba-cloud-elasticsearch

在进行数据迁移时,Logstash会帮助您自动创建索引,但是自动创建的索引可能与您待迁移的索引存在差异,导致迁移前后数据的格式不一致。因此建议您在数据迁移前,在阿里云Elasticsearch中手动创建目标索引,确保迁移前后索引数据完全一致。

您可以通过Python脚本创建目标索引,具体操作步骤如下:

适配 Python 3.10.9

#!/usr/bin/python
# -*- coding: UTF-8 -*-
# 文件名:indiceCreate.py
import base64
import http.client
import json## 源集群host。
oldClusterHost = "localhost:9200"
## 源集群用户名,可为空。
oldClusterUserName = "elastic"
## 源集群密码,可为空。
oldClusterPassword = "xxxxxx"
## 目标集群host,可在阿里云Elasticsearch实例的基本信息页面获取。
newClusterHost = "jiankunking****.elasticsearch.aliyuncs.com:9200"
## 目标集群用户名。
newClusterUser = "elastic"
## 目标集群密码。
newClusterPassword = "xxxxxx"
DEFAULT_REPLICAS = 0def httpRequest(method, host, endpoint, params="", username="", password=""):conn = http.client.HTTPConnection(host)headers = {}if (username != ""):'Hello {name}, your age is {age} !'.format(name='Tom', age='20')up = ('{username}:{password}'.format(username=username, password=password))# print(up)# print(up.encode())# base64string = base64.encodestring(#     up.encode()).replace('\n', '')base64string = base64.b64encode(up.encode()).decode()print(base64string)headers["Authorization"] = "Basic %s" % base64string;if "GET" == method:headers["Content-Type"] = "application/x-www-form-urlencoded"conn.request(method=method, url=endpoint, headers=headers)else:headers["Content-Type"] = "application/json"conn.request(method=method, url=endpoint, body=params, headers=headers)response = conn.getresponse()res = response.read()return resdef httpGet(host, endpoint, username="", password=""):return httpRequest("GET", host, endpoint, "", username, password)def httpPost(host, endpoint, params, username="", password=""):return httpRequest("POST", host, endpoint, params, username, password)def httpPut(host, endpoint, params, username="", password=""):return httpRequest("PUT", host, endpoint, params, username, password)def getIndices(host, username="", password=""):endpoint = "/_cat/indices"indicesResult = httpGet(oldClusterHost, endpoint, oldClusterUserName, oldClusterPassword)indicesList = indicesResult.decode().split("\n")indexList = []for indices in indicesList:if (indices.find("open") > 0):indexList.append(indices.split()[2])return indexListdef getSettings(index, host, username="", password=""):endpoint = "/" + index + "/_settings"indexSettings = httpGet(host, endpoint, username, password)print(index + "  原始settings如下:\n" + indexSettings.decode())settingsDict = json.loads(indexSettings)## 分片数默认和源集群索引保持一致。number_of_shards = settingsDict[index]["settings"]["index"]["number_of_shards"]## 副本数默认为0。number_of_replicas = DEFAULT_REPLICASnewSetting = "\"settings\": {\"number_of_shards\": %s, \"number_of_replicas\": %s}" % (number_of_shards, number_of_replicas)return newSettingdef getMapping(index, host, username="", password=""):endpoint = "/" + index + "/_mapping"indexMapping = httpGet(host, endpoint, username, password)print(index + " 原始mapping如下:\n" + indexMapping.decode())mappingDict = json.loads(indexMapping)mappings = json.dumps(mappingDict[index]["mappings"])newMapping = "\"mappings\" : " + mappingsreturn newMappingdef createIndexStatement(oldIndexName):settingStr = getSettings(oldIndexName, oldClusterHost, oldClusterUserName, oldClusterPassword)mappingStr = getMapping(oldIndexName, oldClusterHost, oldClusterUserName, oldClusterPassword)createstatement = "{\n" + str(settingStr) + ",\n" + str(mappingStr) + "\n}"return createstatementdef createIndex(oldIndexName, newIndexName=""):if (newIndexName == ""):newIndexName = oldIndexNamecreatestatement = createIndexStatement(oldIndexName)print("新索引 " + newIndexName + " 的setting和mapping如下:\n" + createstatement)endpoint = "/" + newIndexNamecreateResult = httpPut(newClusterHost, endpoint, createstatement, newClusterUser, newClusterPassword)print("新索引 " + newIndexName + " 创建结果:" + createResult.decode())## main
indexList = getIndices(oldClusterHost, oldClusterUserName, oldClusterPassword)
systemIndex = []
for index in indexList:if (index.startswith(".")):systemIndex.append(index)else:createIndex(index, index)
if (len(systemIndex) > 0):for index in systemIndex:print(index + " 或许是系统索引,不会重新创建,如有需要,请单独处理~")
http://www.hkea.cn/news/768694/

相关文章:

  • 长春服务好的网络营销seo网站推广的主要目的
  • 搜索引擎优化和关键词竞价广告的区别宿州百度seo排名软件
  • 一搜同志网站建设电话青岛网站seo优化
  • 官方做任务网站网络营销公司注册找哪家
  • django做视频网站网络营销推广专家
  • 国外手做网站搜索引擎推广的关键词
  • 网站建设商标注册多少类目域名注册免费
  • 哪里有网站设计公司长沙网络公司最新消息
  • 试描述一下网站建设的基本流程百度怎么发布短视频
  • 我现在有域名怎么做网站搜索关键词热度
  • 海外如何 淘宝网站建设快速seo整站优化排行
  • 代还信用卡网站建设赣州seo顾问
  • 响应式网站建设推广开网店
  • 成都专业网站推广公司优化大师优化项目有
  • 怎么用wordpress搭建网站百度关键词排名点
  • 外挂网站模板域名搜索引擎入口
  • 手机网站开发 pdfseo搜索引擎优化工作内容
  • 上海中小网站建设洛阳seo博客
  • 南宁网站建设公司哪家专业搜索引擎优化包括
  • 新疆住房与建设厅网站新产品推广方式有哪些
  • 做网站站怎么赚钱网络营销模式有哪些?
  • 南通城市建设集团有限公司网站南京谷歌推广
  • 南通网站定制方案怎么查找关键词排名
  • 权大师的网站是哪个公司做的百度做个人简介多少钱
  • 烟台网站建设设计软文广告经典案例100字
  • 做微信用什么网站广州百度seo代理
  • 网站建设目标 优帮云跨境电商营销推广
  • 郑州华恩科技做网站怎么样竞价排名适合百度吗
  • flask做大型网站开发深圳seo博客
  • 合肥网站建设平台小程序怎么引流推广