Bootstrap

在 win 10 上安装 Elasticsearch 7.10.1

#28天写作 挑战

第 2 天

安装过程,小白记录,大神请绕行

在 win 10 上安装了 Elasticsearch 7.10.1,没有安装独立的 JDK,而是使用 elastic 自带 bundled 的。

第一次执行 elasticsearch.bat 的时候似乎比较慢,可能是在本地编译。

{
  "name": "win10-node-1",
  "cluster_name": "study-application",
  "cluster_uuid": "ras0xD8ARh-WGaJ4VwUY1Q",
  "version": {
    "number": "7.10.1",
    "build_flavor": "default",
    "build_type": "zip",
    "build_hash": "1c34507e66d7db1211f66f3513706fdf548736aa",
    "build_date": "2020-12-05T01:00:33.671820Z",
    "build_snapshot": false,
    "lucene_version": "8.7.0",
    "minimum_wire_compatibility_version": "6.8.0",
    "minimum_index_compatibility_version": "6.0.0-beta1"
  },
  "tagline": "You Know, for Search"
}

关闭的时候似乎要按两次 Ctrl+C。

装的是最新版的,但是还不知道考试的时候哦那个的哪一版。

接下来是安装 Kibana 7.10.1,然后在浏览器里访问 http://localhost:5601/ 我得到了:

Kibana server is not ready yet

在日志里面:

log   [05:44:32.159] [error][data][elasticsearch] [TimeoutError]: Request timed out
log   [05:44:32.160] [warning][savedobjects-service] Unable to connect to Elasticsearch. Error: Request timed out

在官方论坛上找到解决方案将 Elasticserch 的配置文件 elasticsearch.yml 中的  network.host 改为 127.0.0.1,默认的好像是 192.168.0.1,而且还要去掉注释用的 # 号

network.host: 127.0.0.1

然后,我就得到了如下报错信息:

log   [05:53:00.484] [error][data][elasticsearch] [resource_already_exists_exception]: index [.kibana_task_manager_1/heG_0JL6T2Wg9oZNP70bfA] already exists

大意是有两个索引已经存在了,同样在官方论坛找到解法,另起一个控制台,然后执行:

curl https://localhost:9200/_cat/indices/*?v
curl -XDELETE http://localhost:9200/.kibana*

第一条命令是查看索引,第二条是删除以 .kibana 开头的索引。

终于可以在浏览器里面看到 Kibana 的界面了,找到 Management 中的 DevTools,然后执行:

GET _cluster/health

得到

{
  "cluster_name" : "study-application",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 6,
  "active_shards" : 6,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 0,
  "delayed_unassigned_shards" : 0,
  "number_of_pending_tasks" : 0,
  "number_of_in_flight_fetch" : 0,
  "task_max_waiting_in_queue_millis" : 0,
  "active_shards_percent_as_number" : 100.0
}

ES 是面向文档的,文档中存储的数据结构,与面向对象的数据结构是一样的,基于这种文档数据结构,ES 可以提供复杂的索引,全文检索,分析聚合等功能

有点好奇,ES 和对象数据库有什么关系?

在中华石杉的视频里面,Elasticsearch 5.2 版本,只启动一个实例的时候,集群的状态是 yellow,而在我的 7.10.1 上,是 green 的。

GET /_cat/health?v

epoch      timestamp cluster           status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1609986928 02:35:28  study-application green           1         1      6   6    0    0        0             0                  -                100.0%

从截图可以看到 shards 和 pri 都是 6,与之前 5.2 版本不同(5.2 都是 1)

GET /_cat/indices?v

# 7.10.1
health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
green  open   .apm-custom-link                -cHKkvF8S_um5DOZUKSZEA   1   0          0            0       208b           208b
green  open   .kibana_task_manager_1          UPJGtaocRaykb09d8QoPoA   1   0          5         3570    420.3kb        420.3kb
green  open   .apm-agent-configuration        yIuKhjPES8O6rATBYWuChA   1   0          0            0       208b           208b
green  open   .kibana-event-log-7.10.1-000001 OEvvbMYIRfacpDICarEBZw   1   0          1            0      5.6kb          5.6kb
green  open   .kibana_1                       D1uIPOjURDquh-msVgkG9Q   1   0         21            2      2.1mb          2.1mb

# 5.2 
health status index   uuid                   pri rep docs.count docs.deleted store.size pri.store.size 
yellow open   .kibana rUm9n9wMRQCCrRDEhqneBg   1   1          1            0      3.1kb          3.1kb