概述
安装前提
安装JDK(至少1.8及以上版本)并配置环境变量
查看Java版本:
java -version
Windows环境安装
安装ElasticSearch
(1)官网下载ElasticSearch安装压缩包,并解压
下载地址:https://www.elastic.co/cn/downloads/elasticsearch
解压后目录结构如下(示例版本:5.6.8):
(2)启动ElasticSearch
在bin目录下执行 elasticsearch.bat
9200作为Http协议,主要用于外部通讯;9300作为Tcp协议,jar之间就是通过tcp协议通讯
ES本身特点之一就是开箱即用,如果是中小型应用,数据量少,操作不是很复杂,直接启动就可以用了。
(3)检查ES是否启动成功
http://localhost:9200/?pretty
{
"name" : "yJ9kh5T",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "qx9lCXRwQaqBSXGCcq5Emw",
"version" : {
"number" : "5.6.8",
"build_hash" : "688ecce",
"build_date" : "2018-02-16T16:46:30.010Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
name
:node
名称cluster_name
: 集群名称(默认的集群名称就是elasticsearch)version.number
: 5.6.8,es版本号
安装Kibana操作ElasticSearch
(1)下载和解压缩Kibana安装包
注意:应保证kibana版本与es保持一致。
下载地址:https://www.elastic.co/cn/downloads/past-releases#kibana
解压后目录结构如下:
(2)启动Kibana
在bin目录下启动kibana.bat
服务启动后,访问:http://localhost:5601
(3)进入Dev Tools
界面
(4)测试
GET _cluster/health
返回集群信息:
{
"cluster_name": "elasticsearch",
"status": "yellow",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 1,
"active_shards": 1,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 1,
"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": 50
}
Linux环境docke安装
安装ElasticSearch
(1)获取镜像
docker pull elasticsearch:6.4.3
(2)启动elasticsearch
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -d elasticsearch:7.8.3
(3)测试是否安装成功
在浏览器中打开 http://localhost:9200
这个网址,如果能看到以下信息则说明我们的es是已经安装好了的。
{
"name" : "1023f796100f",
"cluster_name" : "docker-cluster",
"cluster_uuid" : "kvUcoarpRCOK5fw7a5Pnsw",
"version" : {
"number" : "7.8.0",
"build_flavor" : "default",
"build_type" : "docker",
"build_hash" : "757314695644ea9a1dc2fecd26d1a43856725e65",
"build_date" : "2020-06-14T19:35:50.234439Z",
"build_snapshot" : false,
"lucene_version" : "8.5.1",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
配置密码
(1)进入elasticsearch
# 进入 es 的 docker 容器中,当前目录为 /usr/share/elasticsearch
docker exec -it d5d232b4954e /bin/bash
# 进入 config 目录
cd config
vim elasticsearch.yml
(2)在配置文件中开启x-pack验证, 修改config目录下面的elasticsearch.yml文件
xpack.security.enabled: true
xpack.license.self_generated.type: basic
xpack.security.transport.ssl.enabled: true
(3) 设置密码
[root@f18d8bc7b8f5 elasticsearch]# cd bin
[root@f18d8bc7b8f5 bin]# ls
elasticsearch elasticsearch-croneval elasticsearch-migrate elasticsearch-setup-passwords elasticsearch-syskeygen x-pack-watcher-env
elasticsearch-certgen elasticsearch-env elasticsearch-node elasticsearch-shard elasticsearch-users
elasticsearch-certutil elasticsearch-env-from-file elasticsearch-plugin elasticsearch-sql-cli x-pack-env
elasticsearch-cli elasticsearch-keystore elasticsearch-saml-metadata elasticsearch-sql-cli-7.6.2.jar x-pack-security-env
[root@f18d8bc7b8f5 bin]# elasticsearch-setup-passwords interactive #此步为手动设置密码
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]: #在这里设置密码,注意最少六位,下面也一样
Reenter password for [elastic]:
Passwords do not match.
Try again.
Enter password for [elastic]:
Reenter password for [elastic]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana]:
Reenter password for [kibana]:
Enter password for [logstash_system]:
Reenter password for [logstash_system]:
Enter password for [beats_system]:
Reenter password for [beats_system]:
Enter password for [remote_monitoring_user]:
Reenter password for [remote_monitoring_user]:
Changed password for user [apm_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]
(3) 退出重启
exit
docker restart elastcisearch
(4)刷新 localhost:9200
安装Kibana(可选)
(1)获取镜像
docker pull kibana:6.4.3
(2)安装启动kibana
安装完成以后需要启动kibana容器,使用–link连接到elasticsearch容器,命令如下:
docker run --name kibana --link=elasticsearch:test -p 5601:5601 -d kibana:6.4.3
启动以后可以打开浏览器输入http://localhost:5601
就可以打开kibana的界面了
安装ik分词插件
(1)进入镜像
docker exec -it elasticsearch /bin/bash
//其中elasticsearch为容器名
(2)安装插件
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.3/elasticsearch-analysis-ik-6.4.3.zip
(3)退出并重启镜像
exit
docker restart elastcisearch
(4)检测是否安装成功
POST http://localhost:9200/_analyze
{
"analyzer":"ik_max_word",
"text":"哈是肯定个好似看到过I有"
}
返回值:
{
"tokens": [{
"token": "哈",
"start_offset": 0,
"end_offset": 1,
"type": "CN_CHAR",
"position": 0
}, {
"token": "是",
"start_offset": 1,
"end_offset": 2,
"type": "CN_CHAR",
"position": 1
}, {
"token": "肯定",
"start_offset": 2,
"end_offset": 4,
"type": "CN_WORD",
"position": 2
}, {
"token": "个",
"start_offset": 4,
"end_offset": 5,
"type": "CN_CHAR",
"position": 3
}, {
"token": "好似",
"start_offset": 5,
"end_offset": 7,
"type": "CN_WORD",
"position": 4
}, {
"token": "看到过",
"start_offset": 7,
"end_offset": 10,
"type": "CN_WORD",
"position": 5
}, {
"token": "看到",
"start_offset": 7,
"end_offset": 9,
"type": "CN_WORD",
"position": 6
}, {
"token": "到过",
"start_offset": 8,
"end_offset": 10,
"type": "CN_WORD",
"position": 7
}, {
"token": "i",
"start_offset": 10,
"end_offset": 11,
"type": "ENGLISH",
"position": 8
}, {
"token": "有",
"start_offset": 11,
"end_offset": 12,
"type": "CN_CHAR",
"position": 9
}]
}
安装Ingest Attachment Processor Plugin
(1) 进入镜像
docker exec -it elasticsearch /bin/bash
//其中elasticsearch为容器名
(2)退出并重启镜像
exit
docker restart elastcisearch
卸载插件
(1) 进入镜像
docker exec -it elasticsearch /bin/bash
//其中elasticsearch为容器名
(2) 卸载指定插件
./bin/elasticsearch-plugin remove ingest-attachment
最后
以上就是无奈小猫咪为你收集整理的ElasticSearch安装安装前提Windows环境安装Linux环境docke安装的全部内容,希望文章能够帮你解决ElasticSearch安装安装前提Windows环境安装Linux环境docke安装所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复