Node.js/ElasticSearch:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
 
(未显示同一用户的3个中间版本)
第62行: 第62行:
Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455
Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455
Fri, 28 May 2021 11:00:32 GMT | dump complete
Fri, 28 May 2021 11:00:32 GMT | dump complete
</syntaxhighlight>|$|/home/kangkk}}
导入数据,创建索引
{{shc|<syntaxhighlight lang="bash">
curl -XPUT http://账号:密码@IP:端口/索引名称</syntaxhighlight>|$|/home/kangkk}}
开始导入
{{shc|<syntaxhighlight lang="bash">
./node_modules/elasticdump/bin/elasticdump --input ./索引名称_mapping.json --output http://账号:密码@IP:端口/ --type=mapping
./node_modules/elasticdump/bin/elasticdump --input ./索引名称.json --output http://账号:密码@IP:端口/ --type=data
</syntaxhighlight>|$|/home/kangkk}}
</syntaxhighlight>|$|/home/kangkk}}


=== taskrabbit/elasticsearch-dump ===
=== taskrabbit/elasticsearch-dump ===
=== 其他 ===
查看索引大小。
{{Shc_out|<syntaxhighlight lang="bash">
curl -X GET http://账号:密码@IP:端口/_cat/indices?v</syntaxhighlight>|<syntaxhighlight lang="bash">
health status index                    uuid                  pri rep docs.count docs.deleted store.size pri.store.size
green  open  .security-7              aGvmk0RpT0CJXkB46wN-lg  1  0        44            0    77.2kb        77.2kb
green  open  .kibana_task_manager_1  7E4IiOYTTHiPhzqVsE29ug  1  0          2            0      6.6kb          6.6kb
green  open  .apm-agent-configuration BEkeof_DQ8mtnbfn2PWwQA  1  0          0            0      283b          283b
yellow open  某个索引                kinMZdbPRSenXvSxeBewzA  1  1      3455            0    931.9kb        931.9kb
green  open  .kibana_1                WaiT4ix5RbOJV5Z_VOl92g  1  0        33            6    72.3kb        72.3kb
</syntaxhighlight>|$|/home/kangkk}}
== error ==
* <code>Error Emitted => {"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}],"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}</code>
: 没有安装IK分词器(elasticsearch-analysis-ik)


== 配置 ==
== 配置 ==

2021年5月30日 (日) 15:03的最新版本

引言

ElasticSearch,文档

服务器安装 elasticsearch 需要依赖 java

/home/kangkk
yum install java -y
[jian@kang /home/kangkk]$
java -version
openjdk version "1.8.0_262"
OpenJDK Runtime Environment (build 1.8.0_262-b10)
OpenJDK 64-Bit Server VM (build 25.262-b10, mixed mode)

下载并安装 GPG key

/home/kangkk
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

添加 yum 仓库

/home/kangkk
vi /etc/yum.repos.d/elasticsearch.repo
/etc/yum.repos.d/elasticsearch.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

安装 elasticsearch

/home/kangkk
yum install elasticsearch

迁移

elasticdump

/home/kangkk
npm install elasticdump

导出数据

[jian@kang /home/kangkk]$
./node_modules/elasticdump/bin/elasticdump --input http://用户名:密码@IP:端口/索引名称 --output ./索引名称_mapping.json --type=mapping
Fri, 28 May 2021 10:59:42 GMT | starting dump
Fri, 28 May 2021 10:59:42 GMT | got 1 objects from source elasticsearch (offset: 0)
Fri, 28 May 2021 10:59:42 GMT | sent 1 objects to destination file, wrote 1
Fri, 28 May 2021 10:59:42 GMT | got 0 objects from source elasticsearch (offset: 1)
Fri, 28 May 2021 10:59:42 GMT | Total Writes: 1
Fri, 28 May 2021 10:59:42 GMT | dump complete
[jian@kang /home/kangkk]$
./node_modules/elasticdump/bin/elasticdump --input http://用户名:密码@IP:端口/索引名称 --output ./索引名称.json --type=data
Fri, 28 May 2021 11:00:01 GMT | starting dump
Fri, 28 May 2021 11:00:01 GMT | got 100 objects from source elasticsearch (offset: 0)
Fri, 28 May 2021 11:00:01 GMT | sent 100 objects to destination file, wrote 100
Fri, 28 May 2021 11:00:02 GMT | got 100 objects from source elasticsearch (offset: 100)
Fri, 28 May 2021 11:00:02 GMT | sent 100 objects to destination file, wrote 100
...
Fri, 28 May 2021 11:00:32 GMT | sent 55 objects to destination file, wrote 55
Fri, 28 May 2021 11:00:32 GMT | got 0 objects from source elasticsearch (offset: 3455)
Fri, 28 May 2021 11:00:32 GMT | Total Writes: 3455
Fri, 28 May 2021 11:00:32 GMT | dump complete

导入数据,创建索引

/home/kangkk
 curl -XPUT http://账号:密码@IP:端口/索引名称

开始导入

/home/kangkk
./node_modules/elasticdump/bin/elasticdump --input ./索引名称_mapping.json --output http://账号:密码@IP:端口/ --type=mapping
./node_modules/elasticdump/bin/elasticdump --input ./索引名称.json --output http://账号:密码@IP:端口/ --type=data

taskrabbit/elasticsearch-dump

其他

查看索引大小。

[jian@kang /home/kangkk]$
curl -X GET http://账号:密码@IP:端口/_cat/indices?v
health status index                    uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .security-7              aGvmk0RpT0CJXkB46wN-lg   1   0         44            0     77.2kb         77.2kb
green  open   .kibana_task_manager_1   7E4IiOYTTHiPhzqVsE29ug   1   0          2            0      6.6kb          6.6kb
green  open   .apm-agent-configuration BEkeof_DQ8mtnbfn2PWwQA   1   0          0            0       283b           283b
yellow open   某个索引                 kinMZdbPRSenXvSxeBewzA   1   1       3455            0    931.9kb        931.9kb
green  open   .kibana_1                WaiT4ix5RbOJV5Z_VOl92g   1   0         33            6     72.3kb         72.3kb

error

  • Error Emitted => {"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}],"type":"mapper_parsing_exception","reason":"analyzer [ik_smart] not found for field [title]"}
没有安装IK分词器(elasticsearch-analysis-ik)

配置