elasticsearch 6.x (一) 部署 windows入门 spingboot连接
大家好,我是烤鴨:
? ? 今天分享的是 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é)點名稱。后期再解釋各個參數(shù)什么意思。
3.?啟動
????進入es根目錄下bin, 點擊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é)點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é)點部署
????3.? ?elasticsearch 6.x (四) 單一文檔 API 介紹和使用 index和get API
? ? 4.? ?elasticsearch 6.x (五) 單一文檔 API 介紹和使用 update和delete API
總結(jié)
以上是生活随笔為你收集整理的elasticsearch 6.x (一) 部署 windows入门 spingboot连接的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 数据帧,数据包,报文段,报文,分组,数据
- 下一篇: 配置svn 报错E200002解决办法