Linux系統(tǒng)下centos7怎么搭建ElasticSearch中間件

這篇“Linux系統(tǒng)下centos7怎么搭建ElasticSearch中間件”文章的知識(shí)點(diǎn)大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來(lái)看看這篇“Linux系統(tǒng)下centos7怎么搭建ElasticSearch中間件”文章吧。

左貢網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)公司!從網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、APP開(kāi)發(fā)、響應(yīng)式網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開(kāi)發(fā),運(yùn)營(yíng)維護(hù)。創(chuàng)新互聯(lián)公司于2013年創(chuàng)立到現(xiàn)在10年的時(shí)間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來(lái)保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)公司。

一、中間件簡(jiǎn)介

1、基礎(chǔ)概念

elasticsearch是一個(gè)基于lucene的搜索服務(wù)器。它提供了一個(gè)分布式多用戶能力的全文搜索引擎,基于restful web接口。elasticsearch是用java開(kāi)發(fā)的,并作為apache許可條款下的開(kāi)放源碼發(fā)布,是當(dāng)前流行的企業(yè)級(jí)搜索引擎。

2、分布式數(shù)據(jù)庫(kù)

分布式數(shù)據(jù)庫(kù)系統(tǒng)通常使用較小的計(jì)算機(jī)系統(tǒng),每臺(tái)計(jì)算機(jī)可單獨(dú)放在一個(gè)地方,每臺(tái)計(jì)算機(jī)中都可能有dbms的一份完整拷貝副本,或者部分拷貝副本,并具有自己局部的數(shù)據(jù)庫(kù),位于不同地點(diǎn)的許多計(jì)算機(jī)通過(guò)網(wǎng)絡(luò)互相連接,共同組成一個(gè)完整的、全局的邏輯上集中、物理上分布的大型數(shù)據(jù)庫(kù)。

3、核心角色

1)節(jié)點(diǎn)和集群

cluster代表一個(gè)集群,集群中有多個(gè)節(jié)點(diǎn),其中有一個(gè)為主節(jié)點(diǎn),這個(gè)主節(jié)點(diǎn)是可以通過(guò)選舉產(chǎn)生的,主從節(jié)點(diǎn)是對(duì)于集群內(nèi)部來(lái)說(shuō)的。es的一個(gè)概念就是去中心化,字面上理解就是無(wú)中心節(jié)點(diǎn),這是對(duì)于集群外部來(lái)說(shuō)的,因?yàn)閺耐獠縼?lái)看es集群,在邏輯上是個(gè)整體。單個(gè) elastic 實(shí)例稱為一個(gè)節(jié)點(diǎn)(node)。一組節(jié)點(diǎn)構(gòu)成一個(gè)集群(cluster)。

2)shards分片

代表索引分片,es可以把一個(gè)完整的索引分成多個(gè)分片,這樣的好處是可以把一個(gè)大的索引拆分成多個(gè),分布到不同的節(jié)點(diǎn)上。構(gòu)成分布式搜索。分片的數(shù)量只能在索引創(chuàng)建前指定,并且索引創(chuàng)建后不能更改。

3)document文檔
index 里面單條的記錄稱為 document(文檔)。許多條 document 構(gòu)成了一個(gè) index。document 使用 json 格式表示。

4)index索引

elastic 會(huì)索引所有字段,查找數(shù)據(jù)的時(shí)候,直接查找該索引。每個(gè) index (即理解為數(shù)據(jù)庫(kù)名稱)的名字必須是小寫(xiě)。

5)type類型

document 可以根據(jù)type進(jìn)行虛擬的邏輯分組,用來(lái)過(guò)濾 document,即理解為數(shù)據(jù)庫(kù)表名稱。

二、中間件安裝

1、安裝環(huán)境和版本

centos7
jdk1.8
elasticsearch-6.3.2

2、下載解壓

下載的路徑,當(dāng)前目錄的文件夾下,也可以指定下載路徑。wget -p 目錄 網(wǎng)址。

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.2.zip
[root@localhost roo]# mv elasticsearch-6.3.2.zip /usr/local/mysoft/
[root@localhost mysoft]# unzip elasticsearch-6.3.2.zip

3、啟動(dòng)軟件

[root@localhost mysoft]# cd elasticsearch-6.3.2/
[root@localhost elasticsearch-6.3.2]# ./bin/elasticsearch

1)報(bào)錯(cuò)一

org.elasticsearch.bootstrap.startupexception: 
java.lang.runtimeexception: can not run elasticsearch as root

新建用戶組和用戶

[root@localhost]# useradd esroot
[root@localhost]# passwd esroot
[root@localhost]# groupadd esgroup
[root@localhost]# usermod -g esgroup esroot

esroot用戶授權(quán)

chown esroot /usr/local/mysoft/elasticsearch-6.3.2 -r

切換到esroot用戶

[root@localhost mysoft]# su - esroot
[esroot@localhost ~]$ su #回到root用戶

2)報(bào)錯(cuò)二

max file descriptors [4096] for elasticsearch process is too low, 
increase to at least [65536]

執(zhí)行如下命名,該操作在root權(quán)限下操作。

[root@localhost roo]# vim /etc/security/limits.conf

添加內(nèi)容

* soft nofile 65536
* hard nofile 65536

切回esroot用戶

 再次啟動(dòng),沒(méi)有報(bào)錯(cuò)信息。

4、打開(kāi)命令行測(cè)試

curl localhost:9200
[roo@localhost ~]$ curl localhost:9200
{
 "name" : "yms44oi",
 "cluster_name" : "elasticsearch",
 "cluster_uuid" : "2zxjbnkjsjiev_k1iwmzrq",
 "version" : {
 "number" : "6.3.2",
 "build_flavor" : "default",
 "build_type" : "zip",
 "build_hash" : "053779d",
 "build_date" : "2018-07-20t05:20:23.451332z",
 "build_snapshot" : false,
 "lucene_version" : "7.3.1",
 "minimum_wire_compatibility_version" : "5.6.0",
 "minimum_index_compatibility_version" : "5.0.0"
 },
 "tagline" : "you know, for search"
}

這樣elasticsearch-6.3.2環(huán)境搭建成功。

 請(qǐng)求9200端口,elastic 返回一個(gè) json 對(duì)象,包含當(dāng)前節(jié)點(diǎn)、集群、版本等信息。
 按下 ctrl + c,elastic 就會(huì)停止運(yùn)行。

5、配置外部訪問(wèn)

默認(rèn)情況下,elastic 只允許本機(jī)訪問(wèn),如果需要遠(yuǎn)程訪問(wèn),可以修改 elastic 安裝目錄的config/elasticsearch.yml文件,去掉network.host的注釋,將它的值改成0.0.0.0,然后重新啟動(dòng) elastic。

[esroot@localhost config]$ cd /usr/local/mysoft/elasticsearch-6.3.2/config
[esroot@localhost config]$ vim elasticsearch.yml 
network.host: 0.0.0.0

6、安裝ik中文分詞器

切換到root用戶

[root@localhost elasticsearch-6.3.2]$ ./bin/elasticsearch-plugin 
install 
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.2/elasticsearch-analysis-ik-6.3.2.zip

三、入門(mén)操作

索引創(chuàng)建和刪除

1、創(chuàng)建索引

[esroot@localhost ~]$ curl -x put 'localhost:9200/esindex01'
# 返回?cái)?shù)據(jù)
{
 "acknowledged": true,
 "shards_acknowledged": true,
 "index": "esindex01"
}

服務(wù)器返回一個(gè) json 對(duì)象,acknowledged:true字段表示操作成功。

2、刪除索引

[esroot@localhost ~]$ curl -x delete 'localhost:9200/esindex01'
{"acknowledged":true}

acknowledged:true字段表示操作成功。

以上就是關(guān)于“Linux系統(tǒng)下centos7怎么搭建ElasticSearch中間件”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。

新聞標(biāo)題:Linux系統(tǒng)下centos7怎么搭建ElasticSearch中間件
轉(zhuǎn)載來(lái)源:http://www.muchs.cn/article38/gehepp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)公司、營(yíng)銷型網(wǎng)站建設(shè)軟件開(kāi)發(fā)、企業(yè)網(wǎng)站制作、ChatGPT、網(wǎng)站制作

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)