日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

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

發(fā)布時間:2023/12/10 windows 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 elasticsearch 6.x (一) 部署 windows入门 spingboot连接 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

大家好,我是烤鴨:

? ? 今天分享的是 elasticsearch 6.x 部署 windows服務(wù)器。

? ? 環(huán)境:

????? ? win10

????????elasticsearch-6.2.4

????? ? springboot?2.0.0.RELEASE

????? ?

1. 官網(wǎng)下載elasticsearch

? ? 這個是最新版本的es下載地址。

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

????? 選擇zip包下載,網(wǎng)速較慢,請耐心等待。


2. 修改配置文件

? ? ?剛開始入門,我們盡可能少改東西,就改個集群名稱和節(jié)點(diǎn)名稱。后期再解釋各個參數(shù)什么意思。

# ---------------------------------- 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.?啟動

????進(jìn)入es根目錄下bin, 點(diǎn)擊elasticsearch.bat啟動。

????成功如圖:

????

? ? 可以看到。

? ? 127.0.0.1:9200?是es發(fā)布服務(wù)的地址和端口

? ? 瀏覽器訪問 如圖:

????

????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這個包是可以創(chuàng)建帶有x-pack連接因為后邊要演示加上x-pack,就用這個包了。
? ? ? 目前的話用下面這個包也可以,但是不支持x-pack連接。
????? ? <dependency><groupId>org.elasticsearch.client</groupId><artifactId>transport</artifactId><version>6.2.4</version> </dependency>
4.2 創(chuàng)建連接
? ??@Testpublic void testInfo() {Settings settings = Settings.builder().put("cluster.name","mytest-master").put("thread_pool.search.size", 20)// 增加線程池個數(shù),暫時設(shè)為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);//查看節(jié)點(diǎn)List<DiscoveryNode> nodes = client.connectedNodes();for (DiscoveryNode node : nodes) {System.out.println(node.getHostAddress());}}成功如圖: ????

更多關(guān)于elasticsearch 6.x內(nèi)容:

? ??

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

? ? 2.? ?elasticsearch 6.x (三) linux 集群多節(jié)點(diǎn)部署

????3.? ?elasticsearch 6.x (四) 單一文檔 API 介紹和使用 index和get API

? ? 4.? ?elasticsearch 6.x (五) 單一文檔 API 介紹和使用 update和delete API

總結(jié)

以上是生活随笔為你收集整理的elasticsearch 6.x (一) 部署 windows入门 spingboot连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。