作者介绍
yinanwu(吴沂楠),腾讯云 Elasticsearch 高级开发工程师
本文介绍通过开源社区提供的solr-to-es迁移工具,将Solr节点中的文档迁移到腾讯云ES中的方法。
使用限制
solr-to-es迁移工具仅支持迁移到腾讯云ES 6.4.3、6.8.2版本,迁移完成后可以在控
制台通过升级ES集群大版本升级到更高版本。
操作步骤
-
准备腾讯云ES 6.4.3或6.8.2版本集群。
-
准备一台Centos 7.2版本的CVM,网络和solr及ES集群通畅。
-
在CVM上安装Python 3版本(如3.7.3),通过pip安装elasticsearch 6.8.2版本、
pysolr 3.9.0版本:
pip3 install elasticsearch==6.8.2 pip3 install pysolr==3.9.0
-
在CVM上拉取solr-to-es源码,并安装:
git clone https://github.com/o19s/solr-to-es.git
cd solr-to-es
python3 setup.py install
使用solr-to-es迁移数据,下面的语句把solr里的collections中通过*:*查询到的文档分页导入到腾讯云ES的指定的索引和doc type中。更多使用方式,可以参考社区中详细的介绍:https://github.com/o19s/solr-to-es#readme
solr-to-es --solr-query "*:*" --es-user "elastic" --es-password "腾讯云ES密码" http://{solr地址}:{solr端口}/solr/{collections名} http://{腾讯云ES地址}:9200 {ES索引名} {ES doc type}
例如:
solr-to-es --solr-query "*:*" --es-user "elastic" --es-password "mypassword" http://127.0.0.1:8983/solr/node http://10.2.2.23:9200 my_index my_type
上面语句迁移完成后可以在ES中查询:
curl -XGET -u 'elastic:mypassword' http://10.2.2.23:9200/my_index/my_type/_search