Docker基础:ES详解
测试:curl localhost:9200{"name" : "56bbec414277","cluster_name" : "docker-cluster","cluster_uuid" : "Q94SOO_LRJ-wZ20u_P_M6w","version" : {"number" : "7.6.2","build_flavor" : "default","build_type" : "do
1.安装ES
[root@localhost bin]# docker run -d --name elasticsearch01 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms128m -Xmx512m" elasticsearch:7.6.2
测试:curl localhost:9200
{
"name" : "56bbec414277",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "Q94SOO_LRJ-wZ20u_P_M6w",
"version" : {
"number" : "7.6.2",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "ef48eb35cf30adf4db14086e8aabd07ef6fb113f",
"build_date" : "2020-03-26T06:34:37.794943Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
成功~~~
2.安装es_head
docker run -d --name es-head -p 9100:9100 docker.io/mobz/elasticsearch-head:5
#修改es配置文件,使其允许跨域(需要9100端口访问9200端口)
docker exec -it elasticsearch01 /bin/bash
yum install vim
vim config/elasticsearch.yml
#修改为下面代码,注意冒号后有一个空格
#这是yml的固定格式,在vim中可以使用ctrl+n进行代码补全
http.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
#退出es容器
exit
#重启es容器
docker restart elasticsearch01
访问测试:
3.安装kibana
#拉取
docker pull kibana:7.6.2
#运行(172.17.0.2需替换为es容器的ip,使用docker inspect命令查询)
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://172.17.0.2:9200 -p 5601:5601 -d kibana:7.6.2
#进入容器
docker exec -it 容器ID或容器名 /bin/bash
#使用vi 修改文件内容
vi /usr/share/kibana/config/kibana.yml
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://172.17.0.2:9200" ]
xpack.monitoring.ui.container.elasticsearch.enabled: true
#设置kibana中文显示,也可以不加
i18n.locale: zh-CN
输入网址:localhost:5601(vmware中访问则使用localhost,若是本地机访问则使用ens33中的ip网址)
5.安装ik分词器
docker exec -it elasticsearch01 /bin/bash
yum install -y wget
cd plugins/
mkdir ik/
cd ik/
#我们在官网中找到与es相对应版本的ik
wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.2/elasticsearch-analysis-ik-7.6.2.zip
unzip elasticsearch-analysis-ik-7.6.2.zip
rm elasticsearch-analysis-ik-7.6.2.zip
#退出容器,最后重启es即可
docker restart elasticsearch01
进入kibana测试
#两种分词模式
GET _analyze
{
"analyzer": "ik_smart"
, "text": "我是中国人"
}
GET _analyze
{
"analyzer": "ik_max_word"
, "text": "我是中国人"
}
成功~~~
更多推荐
所有评论(0)