这里仅实践操作并根据实际问题进行记录笔记。
运行 ES8
我们需要在自己的电脑上安装好 Docker Desktop。接着我们运行如下的命令:出现两个异常,一个是需要使用winpty
因为我使用win的docker desktop,另外一个问题是docker启动elasticsearchERROR: Elasticsearch did not exit normally - check the logs at xxx
。解决办法:在运行命令中添加 -e "discovery.type=single-node"
。最终运行命令
$ docker network create elastic
$ docker pull docker.elastic.co/elasticsearch/elasticsearch:8.3.3
winpty docker run -e ES_JAVA_OPTS="-Xms1024m -Xmx1024m" -e "discovery.type=single-node" --name es-node01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elastic.co/elasticsearch/elasticsearch:8.3.3$ docker logs es-node01 -f --tail 1000$ docker pull docker.elastic.co/kibana/kibana:8.3.3
$ winpty docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.3.3
最后显示图,如下:
验证访问
$ docker cp es-node01:/usr/share/elasticsearch/config/certs/http_ca.crt .
$ curl -X GET --cacert ./http_ca.crt -u elastic:8-u-CiRMc1FgM8k*fNRY https://localhost:9200/{"name" : "80785c9c7f2e","cluster_name" : "docker-cluster","cluster_uuid" : "yfxAwhuwSdiAXYgrXSfp-Q","version" : {"number" : "8.3.3","build_flavor" : "default","build_type" : "docker","build_hash" : "801fed82df74dbe537f89b71b098ccaff88d2c56","build_date" : "2022-07-23T19:30:09.227964828Z","build_snapshot" : false,"lucene_version" : "9.2.0","minimum_wire_compatibility_version" : "7.17.0","minimum_index_compatibility_version" : "7.0.0"},"tagline" : "You Know, for Search"
}
安装 IK
sh-5.0$ cd /usr/share/elasticsearch/
sh-5.0$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip^C
sh-5.0$ pwd
/usr/share/elasticsearch
sh-5.0$ ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip
-> Installing https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.3.3/elasticsearch-analysis-ik-8.3.3.zip
[=================================================] 100%??
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See https://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.Continue with installation? [y/N]y
-> Installed analysis-ik
-> Please restart Elasticsearch to activate any plugins installedsh-5.0$ ./bin/elasticsearch-plugin list
analysis-ik上面的命令显示我们的 IK 已经安装成功了。
这个时候需要我们重新启动一下我们的 Elasticsearch,以便这个 plugin 能装被加载。
验证访问
安装后没有重启
正确应该是
安装 KIB
验证访问
访问地址:http://localhost:5601
访问账号:elastic
访问密码:8-u-CiRMc1FgM8k*fNRY
首次验证:569 587 (KIB后台打印)
首次token:eyJ2ZXIiOiI4LjMuMyIsImFkciI6WyIxNzIuMjMuMC4yOjkyMDAiXSwiZmdyIjoiMGU3MDAzMmVlMjMxMzAyODA5ZWQ1MTg2YjI2ZjA1ZmEyODE5NzkwMTdiZjg4NGY3Nzc2NzIzZTBlNWM0MmEyNSIsImtleSI6IkF1QnZSWW9CTWRwSnl4VVZQYmowOjRPUG9lMlI0UjNlWXFLZGtmRHUyNlEifQ==
辅助参考
Elastic:开发者上手指南
Elasticsearch:使用 Docker compose 来一键部署 Elastic Stack 8.x
ElasticSearch
IK Analysis for Elasticsearch
elasticsearch-analysis-ik