elasticsearch 6.x (一) 部署 windows入门 spingboot连接

大家好,我是烤鸭:

    今天分享的是 elasticsearch 6.x 部署 windows服务器。

    环境:

        win10

        elasticsearch-6.2.4

        springboot 2.0.0.RELEASE

       

1. 官网下载elasticsearch

    这个是最新版本的es下载地址。

      https://www.elastic.co/downloads/elasticsearch

      选择zip包下载,网速较慢,请耐心等待。


2. 修改配置文件

     刚开始入门,我们尽可能少改东西,就改个集群名称和节点名称。后期再解释各个参数什么意思。

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: mytest-master
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: mytest-node1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

3. 启动

    进入es根目录下bin, 点击elasticsearch.bat启动。

    成功如图:

    

    可以看到。

    127.0.0.1:9200 是es发布服务的地址和端口

    浏览器访问 如图:

    

    127.0.0.1:9300 是es客户端连接的地址和端口。

   

4. 客户端连接(java)

    4.1 pom文件
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.0.0.RELEASE</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>x-pack-transport</artifactId><version>${elasticsearch.version}</version></dependency><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${junit.version}</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.47</version></dependency></dependencies><repositories><!-- add the elasticsearch repo --><repository><id>elasticsearch-releases</id><url>https://artifacts.elastic.co/maven</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository></repositories>
      x-pack-transport这个包是可以创建带有x-pack连接因为后边要演示加上x-pack,就用这个包了。
      目前的话用下面这个包也可以,但是不支持x-pack连接。
       
<dependency><groupId>org.elasticsearch.client</groupId><artifactId>transport</artifactId><version>6.2.4</version>
</dependency>
4.2 创建连接
    
@Testpublic void testInfo() {Settings settings = Settings.builder().put("cluster.name","mytest-master").put("thread_pool.search.size", 20)// 增加线程池个数,暂时设为5.build();try {client = new PreBuiltTransportClient(settings).addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300));} catch (UnknownHostException e) {e.printStackTrace();}System.out.println(client);//查看节点List<DiscoveryNode> nodes = client.connectedNodes();for (DiscoveryNode node : nodes) {System.out.println(node.getHostAddress());}}
成功如图:
    

更多关于elasticsearch 6.x内容:

    

    1.   elasticsearch 6.x linux部署(二) kibana x-pack 安装

    2.   elasticsearch 6.x (三) linux 集群多节点部署

    3.   elasticsearch 6.x (四) 单一文档 API 介绍和使用 index和get API

    4.   elasticsearch 6.x (五) 单一文档 API 介绍和使用 update和delete API

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/412975.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Programming Assignment 5: Burrows–Wheeler Data Compression

Programming Assignment 5: Burrows–Wheeler Data Compression 1. 题目阅读 实现Burrows-Wheeler数据压缩算法。这个革命性的算法产生了gzip和pkzip&#xff0c;并且相对容易实现&#xff0c;还不受任何专利保护。它构成了unix压缩实用程序bzip2的基础。 这个算法由以下三种算…

hadoop Connection refused: no further information原因排查(Centos7)

一&#xff1a;排查防火墙&#xff0c;是否开放9000端口 firewall-cmd --list-ports查看防火墙是否有9000端口&#xff0c;如果没有&#xff0c;通过下面的命令添加端口&#xff1a; firewall-cmd --zonepublic --add-port9000/tcp --permanent systemctl restart firewalld…

[css]你有使用过preload、preconnect、prefetch这些属性吗?说说它们都有什么作用?

[css]你有使用过preload、preconnect、prefetch这些属性吗&#xff1f;说说它们都有什么作用&#xff1f; preload 元素的 rel 属性的属性值preload能够让你在你的HTML页面中元素内部书写一些声明式的资源获取请求&#xff0c;可以指明哪些资源是在页面加载完成后即刻需要的。…

elasticsearch 6.x (二) linux部署 kibana x-pack 安装

大家好&#xff0c;我是烤鸭&#xff1a; 环境&#xff1a;linux Cent OS 7.3elasticsearch-6.2.4 1. 下载elasticsearch https://www.elastic.co/downloads/elasticsearch 上面的网址直接下载的话&#xff0c;实在太慢了。官方还提供了另一种方式。 https://www.elastic.co…

Kali Linux ——在无网络情况下安装无线网卡驱动

1、背景&#xff1a; 今日刚刚开始学习kali linux&#xff0c;众所周知&#xff0c;安装完成后&#xff0c;系统是没有无线网卡驱动的&#xff0c;这就对学生党造成相当的困扰&#xff1a;校园网要连接有线是需要认证客户端的&#xff0c;而认证客户端只有windows端&#xff0c…

HADOOP_HOME and hadoop.home.dir are unset 报错处理

一般是windows才会出现这个问题 请看下面的解决方案&#xff1a; 第一步&#xff1a;下载winutils-master.zip Gitee地址&#xff1a;https://gitee.com/nkuhyx/winutils.git 蓝奏云&#xff1a;https://www.lanzoux.com/i55ccnc Github地址&#xff1a;https://github.com/cda…

[css] 你是怎样对css文件进行压缩合并的?

[css] 你是怎样对css文件进行压缩合并的&#xff1f; 使用在线网站进行压缩&#xff0c;如http://tool.lu/css如使用Gulp&#xff0c;可使用gulp-minify-css进行压缩如使用WebPack&#xff0c;可使用optimize-css-assets-webpack-plugin进行压缩个人简介 我是歌谣&#xff0c;…

elasticsearch 6.x (三) linux 集群多节点部署

大家好&#xff0c;我是烤鸭&#xff1a;关于集群内单个节点部署&#xff0c;请参考上一篇文章。elasticsearch 6.x linux部署(二) kibana x-pack 安装环境&#xff1a;linux Cent OS 7.3elasticsearch-6.2.41. 下载多个es安装每个安装步骤都是一样的。2. 修改配置文件(重…

ztree改变节点颜色

//找到节点对象 var node ztree.getNodesByParam("id",aaaaaaaaaabbbbbb, null)[0]; if(node!null){//找到span标签&#xff0c;并改变颜色$("#"node.tId"_span").css("color",red); }

版本下载地址

http://chromedriver.storage.googleapis.com/index.html转载于:https://www.cnblogs.com/nvhanzhi/p/9887999.html

[css] css3和css2的区别是什么?

[css] css3和css2的区别是什么&#xff1f; css3增加了更多特性&#xff1a;动画、过渡效果&#xff0c;圆角、文字特效等个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端…

springboot-devtools idea或eclipse 热加载

大家好&#xff0c;我是烤鸭&#xff1a;今天分享一下springboot项目的热加载。第二种方式在eclipse和idea中都可以。虽然会有一些小坑。 方式有两种&#xff1a; 1. springloaded(无效) <!-- https://mvnrepository.com/artifact/org.springframework/springloaded -->…

PostgreSQL创建数据库报错

ERROR:source database "template1"is being accessed by other users DETAIL:There are 2 other sessions using the database. 解决方案&#xff1a; CREATE DATABASE 数据库名称 WITH OWNER postgres ENCODING UTF8 TABLESPACE pg_default LC_COLLATE en_US.…

[css] 你知道什么是流体排版吗?说说它的原理是什么?

[css] 你知道什么是流体排版吗&#xff1f;说说它的原理是什么&#xff1f; 在文档流中&#xff0c;内联元素按内联方向显示&#xff0c;即词语在依据文件写作模式的句子中表示的方向。块元素则一个接一个地显示&#xff0c;就像该文档的写作模式中的段落一样。因此在流体排版…

java统计报表日期工具类

package com.test.common;import com.coyee.core.util.DateUtil;import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.*;/*** 时间工具类*/ public class DateUtils {/*<option value"today">今天</option><option valu…

springboot mybatis 热加载mapper.xml文件(最简单)

大家好&#xff0c;我是烤鸭: 今天介绍一下springboot mybatis 热加载mapper.xml文件。 本来不打算写的&#xff0c;看到网上比较流行的方式都比较麻烦&#xff0c;想着简化一下。 网上流行的版本。 https://www.cnblogs.com/oskyhg/p/8587701.html 总结一下需要&#xff1a;my…

vue cli vue 3.x

vue cli & vue 3.x https://cli.vuejs.org/dev-guide/ui-api.html#ui-api https://cli.vuejs.org/zh/guide/#cli vue cli & how to select the option in cmd ? vue cli & 选中 option a select all & i select all 1,2,3,4,5,6,7,8,9,0 分别对应 order 转载…

[css] 如果css文件过大时,如何异步加载它?

[css] 如果css文件过大时&#xff0c;如何异步加载它&#xff1f; 分割成多个CSS文件进行Gzip压缩link preload个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录 与歌谣一起通关前端面试题

jenkins svn/git sonarqube scanner 代码集成测试

大家好&#xff0c;我是烤鸭&#xff1a;今天分享一个代码检测工具sonar&#xff0c;在jenkins集成的时候使用。 环境:sonarqube 7.1jenkins 2.12xsonarqube scanner &#xff08;官网最新版3.2.0.1227&#xff09;1. jenkins svn/git 搭建项目https://blog.csdn.net/Angry…

[css] 你有使用过字体图标吗?它有什么好处?

[css] 你有使用过字体图标吗&#xff1f;它有什么好处&#xff1f; 代替图片&#xff0c;可以减少http请求次数&#xff0c;提高页面加载性能。个人简介 我是歌谣&#xff0c;欢迎和大家一起交流前后端知识。放弃很容易&#xff0c; 但坚持一定很酷。欢迎大家一起讨论 主目录…