溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Elasticsearch-1.7.0安裝部署

發(fā)布時間:2020-08-03 17:23:27 來源:網(wǎng)絡(luò) 閱讀:799 作者:青衫解衣 欄目:建站服務(wù)器

1、首先去elasticsearch官網(wǎng)下載軟件包版本1.7.0版本.

#wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.0.tar.gz

2、解壓elasticsearch-1.7.0.tar.gz 軟件包.

#tar zxf elasticsearch-1.7.0.tar.gz

3、es配置文件參數(shù)解釋(真正配置不全用的到):

#集群名稱標(biāo)識了你的集群,自動探查會用到它。

#如果你在同一個網(wǎng)絡(luò)中運(yùn)行多個集群,那就要確保你的集群名稱是獨(dú)一無二的.

cluster.name: test-elasticsearch

#節(jié)點(diǎn)名稱會在啟動的時候自動生成,所以你可以不用手動配置。你也可以給節(jié)點(diǎn)指定一個特定的名稱.

node.name: "elsearch2"

#允許這個節(jié)點(diǎn)被選舉為一個主節(jié)點(diǎn)(默認(rèn)為允許)

#node.master: true

#允許這個節(jié)點(diǎn)存儲數(shù)據(jù)(默認(rèn)為允許)

# node.data: true

#You can exploit these settings to design advanced cluster topologies.

# 你可以利用這些設(shè)置設(shè)計高級的集群拓?fù)?/span>

#

# 1. You want this node to never become a master node, only to hold data.

#    This will be the "workhorse" of your cluster.

# 1. 你不想讓這個節(jié)點(diǎn)成為一個主節(jié)點(diǎn),只想用來存儲數(shù)據(jù)。

#    這個節(jié)點(diǎn)會成為你的集群的“負(fù)載器”

#

# node.master: false
# node.data: true

#You want this node to only serve as a master: to not store any data and

#    to have free resources. This will be the "coordinator" of your cluster.

# 2. 你想讓這個節(jié)點(diǎn)成為一個主節(jié)點(diǎn),并且不用來存儲任何數(shù)據(jù),并且擁有空閑資源。

#    這個節(jié)點(diǎn)會成為你集群中的“協(xié)調(diào)器”

# node.master: true
# node.data: false

# Use the Cluster Health API [http://localhost:9200/_cluster/health], the

# Node Info API [http://localhost:9200/_nodes] or GUI tools

#使用集群體檢API[http://localhost:9200/_cluster/health] ,

# 節(jié)點(diǎn)信息API[http://localhost:9200/_cluster/nodes] 或者GUI工具例如:


# A node can have generic attributes associated with it, which can later be used

# for customized shard allocation filtering, or allocation awareness. An attribute

# is a simple key value pair, similar to node.key: value, here is an example:

# 一個節(jié)點(diǎn)可以附帶一些普通的屬性,這些屬性可以在后面的自定義分片分配過濾或者allocation awareness中使用。

# 一個屬性就是一個簡單的鍵值對,類似于node.key: value, 這里有一個例子:

# node.rack: rack314

# By default, multiple nodes are allowed to start from the same installation location

# to disable it, set the following:

# 默認(rèn)的,多個節(jié)點(diǎn)允許從同一個安裝位置啟動。若想禁止這個特性,按照下面所示配置:

# node.max_local_storage_nodes: 1

# Set the number of shards (splits) of an index (5 by default):

# 設(shè)置一個索引的分片數(shù)量(默認(rèn)為5)

# index.number_of_shards: 5

# Set the number of replicas (additional copies) of an index (1 by default):

# 設(shè)置一個索引的副本數(shù)量(默認(rèn)為1)

# index.number_of_replicas: 1

# Note, that for development on a local machine, with small indices, it usually

# makes sense to "disable" the distributed features:

# 注意,為了使用小的索引在本地機(jī)器上開發(fā),禁用分布式特性是合理的做法。

# index.number_of_shards: 1
# index.number_of_replicas: 0

# Path to directory containing configuration (this file and logging.yml):

# 包含配置(這個文件和logging.yml)的目錄的路徑

# path.conf: /path/to/conf

# Path to directory where to store index data allocated for this node.

# 存儲這個節(jié)點(diǎn)的索引數(shù)據(jù)的目錄的路徑

# path.data: /path/to/data

# Can optionally include more than one location, causing data to be striped across

# the locations (a la RAID 0) on a file level, favouring locations with most free

# space on creation. For example:

# 可以隨意的包含不止一個位置,這樣數(shù)據(jù)會在文件層跨越多個位置(a la RAID 0),創(chuàng)建時會

# 優(yōu)先選擇大的剩余空間的位置

# path.data: /path/to/data1,/path/to/data2

# Path to temporary files:

# 臨時文件的路徑

# path.work: /path/to/work

# Path to log files:

# 日志文件的路徑

# path.logs: /path/to/logs

# Path to where plugins are installed:

# 插件安裝路徑

# path.plugins: /path/to/plugins

# If a plugin listed here is not installed for current node, the node will not start.

# 如果當(dāng)前結(jié)點(diǎn)沒有安裝下面列出的插件,結(jié)點(diǎn)不會啟動

# plugin.mandatory: mapper-p_w_uploads,lang-groovy

# ElasticSearch performs poorly when JVM starts swapping: you should ensure that

# it _never_ swaps.

# 當(dāng)JVM開始swapping(換頁)時ElasticSearch性能會低下,你應(yīng)該保證它不會換頁

# Set this property to true to lock the memory:

# 設(shè)置這個屬性為true來鎖定內(nèi)存

# bootstrap.mlockall: true

# Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set

# to the same value, and that the machine has enough memory to allocate

# for ElasticSearch, leaving enough memory for the operating system itself.

# 確保ES_MIN_MEM和ES_MAX_MEM環(huán)境變量設(shè)置成了同一個值,確保機(jī)器有足夠的內(nèi)存來分配

# 給ElasticSearch,并且保留足夠的內(nèi)存給操作系統(tǒng)

# You should also make sure that the ElasticSearch process is allowed to lock

# the memory, eg. by using `ulimit -l unlimited`.

# 你應(yīng)該確保ElasticSearch的進(jìn)程可以鎖定內(nèi)存,例如:使用`ulimit -l unlimited`


# ElasticSearch, by default, binds itself to the 0.0.0.0 address, and listens

# on port [9200-9300] for HTTP traffic and on port [9300-9400] for node-to-node

# communication. (the range means that if the port is busy, it will automatically

# try the next port).

# 默認(rèn)的ElasticSearch把自己和0.0.0.0地址綁定,HTTP傳輸?shù)谋O(jiān)聽端口在[9200-9300],節(jié)點(diǎn)之間

# 通信的端口在[9300-9400]。(范圍的意思是說如果一個端口已經(jīng)被占用,它將會自動嘗試下一個端口)


# Set the bind address specifically (IPv4 or IPv6):

# 設(shè)置一個特定的綁定地址(IPv4 or IPv6):

# network.bind_host: 192.168.0.1

# Set the address other nodes will use to communicate with this node. If not

# set, it is automatically derived. It must point to an actual IP address.

# 設(shè)置其他節(jié)點(diǎn)用來與這個節(jié)點(diǎn)通信的地址。如果沒有設(shè)定,會自動獲取。

# 必須是一個真實(shí)的IP地址。

# network.publish_host: 192.168.0.1

# Set both 'bind_host' and 'publish_host':

# 'bind_host'和'publish_host'都設(shè)置

# network.host: 192.168.0.1

# Set a custom port for the node to node communication (9300 by default):

# 為節(jié)點(diǎn)之間的通信設(shè)置一個自定義端口(默認(rèn)為9300)

# transport.tcp.port: 9300

# Enable compression for all communication between nodes (disabled by default):

# 為所有的節(jié)點(diǎn)間的通信啟用壓縮(默認(rèn)為禁用)

# transport.tcp.compress: true

# Set a custom port to listen for HTTP traffic:

# 設(shè)置一個監(jiān)聽HTTP傳輸?shù)淖远x端口

# http.port: 9200

# Set a custom allowed content length:

# 設(shè)置一個自定義的允許的內(nèi)容長度

# http.max_content_length: 100mb

# Disable HTTP completely:

# 完全禁用HTTP

# http.enabled: false


3、操作系統(tǒng)配置

1.文件描述符

vim /etc/security/limits.conf添加
*  soft nofile 655350
*  hard nofile 655350

退出當(dāng)前用戶重新login就會生效,使用ulimit -n驗(yàn)證下。


2.最大內(nèi)存映射區(qū)數(shù)量,禁用swap交換分區(qū)

vim /etc/sysctl.conf增加
vm.max_map_count=262144
vm.swappiness=1

修改完成后sysctl -p

jvm參數(shù)配置

ES_HOME的bin目錄下有一個elasticsearch.in.sh文件,修改

    ES_MIN_MEM=256m
    ES_MAX_MEM=1g

為合適的值


4、es的插件安裝:


Marvel是Elasticsearch的管理和監(jiān)控工具,對于開發(fā)使用免費(fèi)的。它配備了一個叫做Sense的交互式控制臺,方便通過瀏覽器直接與Elasticsearch交互。

Marvel是一個插件,在Elasticsearch目錄中運(yùn)行以下代碼來下載和安裝:

./plugin -i elasticsearch/marvel/latest

elasticsearch-head是一個elasticsearch的集群管理工具,它是完全由html5編寫的獨(dú)立網(wǎng)頁程序,你可以通過插件把它集成到es。

#./plugin -install mobz/elasticsearch-head

地址:http://172.16.2.24:25556/_plugin/head/


elasticsearch插件bigdesk安裝:


bigdesk是elasticsearch的一個集群監(jiān)控工具,可以通過它來查看es集群的各種狀態(tài),如:cpu、內(nèi)存使用情況,索引數(shù)據(jù)、搜索情況,http連接數(shù)等。

在cmd命令行中進(jìn)入安裝目錄,再進(jìn)入 bin目錄,運(yùn)行以下命令:

#./plugin -install lukas-vlcek/bigdesk

在瀏覽器中輸入:http://172.16.2.24:25556/_plugin/bigdesk可以看到效果


注意:elasticsearch 分詞ik的安裝,如果不安裝分詞ik插件,根本建不了索引,并且讓訪問http://172.16.2.24:25556/_plugin/head/ 集群一片空白,點(diǎn)擊web 創(chuàng)建索引頁沒有反應(yīng)。


注意:github https://github.com/medcl/elasticsearch-analysis-ik 給出了對應(yīng)的es的ik版本,1.7.0的es對應(yīng)的1.2.6的版本,開始我這塊裝了1.8的ik,創(chuàng)建索引失敗,后臺也是報ik的錯誤。


ik:1.2.6版本的下載:https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v1.6.1

安裝操作:

下載zip包解壓到一個目錄解壓縮:

#unzip elasticsearch-analysis-ik-master.zip

安裝mavne環(huán)境,apache 官網(wǎng)下載軟件包設(shè)置環(huán)境變量:

#export PATH=$PATH:/usr/local/maven/bin

因?yàn)槭窃创a,此處需要使用maven打包,進(jìn)入解壓文件夾中,執(zhí)行命令:

#cd elasticsearch-analysis-ik-master
#mvn clean package


#在es的plugin目錄下創(chuàng)建ik目錄,并將target目錄下的elasticsearch-analysis-ik-1.2.6.jar copy 到ik目錄下。

[root@localhost target]# cd /data/elasticsearch-1.7.0
[root@localhost elasticsearch-1.7.0]# ls
bin  config  data  lib  LICENSE.txt  logs  NOTICE.txt  plugins  README.textile
[root@localhost elasticsearch-1.7.0]# cd plugins/
[root@localhost plugins]# ls
bigdesk  head  ik  marvel
[root@localhost plugins]# cd ik/
[root@localhost ik]# ls
elasticsearch-analysis-ik-1.2.6.jar

注意:如果是集群,可以將jar分別copy至其他幾臺機(jī)器。


es配置文件需要添加入下行:

index:
  analysis:                   
    analyzer:     
      ik:
          alias: [ik_analyzer]
          type: org.elasticsearch.index.analysis.IkAnalyzerProvider
      ik_max_word:
          type: ik
          use_smart: false
      ik_smart:
          type: ik
          use_smart: true
marvel.agent.enabled: false


完整的es配置文件如下,三臺同樣的配置,除了hostip和node.name外.

# cat elasticsearch.yml
cluster.name: test-es-cluster
network.host: 172.16.2.24
node.name: "node24"
discovery.zen.ping.unicast.hosts: ["172.16.2.24:25555","172.16.2.21:25555","172.16.2.23:25555"]
index.number_of_shards: 5
discovery.zen.minimum_master_nodes: 2
script.groovy.sandbox.enabled: false
transport.tcp.port: 25555
http.port: 25556
script.inline: off
script.indexed: off
script.file: off
index:
  analysis:                   
    analyzer:     
      ik:
          alias: [ik_analyzer]
          type: org.elasticsearch.index.analysis.IkAnalyzerProvider
      ik_max_word:
          type: ik
          use_smart: false
      ik_smart:
          type: ik
          use_smart: true
marvel.agent.enabled: false


后臺啟動es服務(wù):

[root@localhost bin]# pwd
/data/elasticsearch-1.7.0/bin
[root@localhost bin]# ./elasticsearch -d


三臺集群的機(jī)器中找其中一臺創(chuàng)建索引:

創(chuàng)建索引:

curl -X PUT 'http://172.16.2.24:25556/index'
{"acknowledged":true}


注意:返回結(jié)果為acknowledged":true 為成功.


通過瀏覽器訪問:http://172.16.2.24:25556/_plugin/head/ 測試效果.

Elasticsearch-1.7.0安裝部署

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI