Elasticsearch 7.x windows快速安装部署

Elasticsearch下载地址:https://www.elastic.co/cn/downloads/elasticsearch

elasticsearch-analysis-ik下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases

elasticsearch-head下载:https://github.com/mobz/elasticsearch-head

 

Elasticsearch.Net和NEST文档:https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/index.html

1、安装

下载完成后,先把文件解压放到自己喜欢的目录下,建议不要放在Program Files里,因为在添加ik分词的时候,如果所在目录路径里有空格出现会报错。

配置jdk环境,Elasticsearch文件自带了jdk,无需再下载安装。

设置路径: 计算机=》属性=》高级=》环境变量=》系统变量=》新建

或运行:sysdm.cpl

变量名:ES_JAVA_HOME 或 JAVA_HOME
变量值:D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\jdk
变量名:ES_HOME
变量值:D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0

设置完成后即可启动。

启动方式1:设置完成后双击D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin下的elasticsearch.bat启动,如果双击启动后窗口一闪而过,一般是因为环境变量设置有问题,可通过第二种方式来启动查看日志;

启动方式2:通过dos启动,这样在启动失败的时候可以看到错误日志(推荐);

D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin>elasticsearch.bat //回车

 

2、开启远程访问

//打开配置文件进行修改
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config\elasticsearch.yml
network.host: 0.0.0.0
discovery.seed_hosts: ["172.17.0.3"]

//重启生效

3、设置密码

https://www.elastic.co/guide/en/elasticsearch/reference/7.16/security-minimal-setup.html

这里需要为4个用户分别设置密码,elastic, kibana, logstash_system,beats_system

//打开配置文件在末尾追加以下设置并保存
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\config\elasticsearch.yml

xpack.security.enabled: true
//如果是单节点,添加以下设置可确保您的节点不会无意中连接到可能在您的网络上运行的其他集群
discovery.type: single-node

D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\bin>elasticsearch-setup-passwords interactive //回车

Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,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]:
Enter password for [apm_system]:
Reenter password for [apm_system]:
Enter password for [kibana_system]:
Reenter password for [kibana_system]:
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_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]

//重启后生效

//修改密码
curl -H "Content-Type:application/json" -XPOST -u elastic 'http://localhost:9200/_xpack/security/user/elastic/_password' -d '{ "password" : "123456" }'

 

4、安装ik分词

根据文章开头给出的地址下载到本地,并进行解压。把解压后的整个文件夹复制到elasticsearch的plugins目录下。

//这是我自己的ik安装目录
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\plugins
D:\elasticsearch-7.8.0-windows-x86_64\elasticsearch-7.8.0\plugins\elasticsearch-analysis-ik-7.8.0\config

重新启动Elasticsearch,设置生效。 如果报错,一般是你的目录里有格式导致,上边已经说过了。

//分词效果
//发送:post localhost:9200/_analyze
//默认分词器分词效果
{"text":"测试分词器,后边是测试内容:spring cloud实战"}
//ik分词器分词效果
{"text":"测试分词器,后边是测试内容:spring cloud实战","analyzer":"ik_max_word" }

 

 5、google浏览器插件 elasticsearch-head安装

elasticsearch-head 插件下载地址:https://github.com/mobz/elasticsearch-head/

 根据文章开头给出的地址下载到本地,并进行解压,解压后会有一个 es-head.crx文件,将其更名为es-head.rar 后再解压,然后通过google浏览器=》更多工具=》扩展程序=》打开开发者模式=》加载已解压的扩展程序 添加已解析的es-head文件夹即可。

6、kibana安装

下载kibana并解压,进入根目录,执行命令启动

启动命令
.\bin\kibana //Ctrl-C 停止 Kibana

 文档地址:https://www.elastic.co/guide/cn/kibana/current/windows.html

  如果es开户了权限,kibana需要设置对应的密钥 

elasticsearch.username: "kibana"
elasticsearch.password: "pass"

 7、常用命令

elasticsearch-service.bat install //安装Elasticsearch服务 
elasticsearch-service.bat remove // 删除已安装的Elasticsearch服务
elasticsearch-service.bat start: //启动Elasticsearch服务(如果已安装) 
elasticsearch-service.bat stop: //停止服务(如果启动) 
elasticsearch-service.bat manager //启动GUI来管理已安装的服务

 

posted @ 2020-06-30 13:34  anech  阅读(5135)  评论(0编辑  收藏  举报