新聞中心
1、首先去elasticsearch官網(wǎng)下載軟件包版本1.7.0版本.
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),錫山企業(yè)網(wǎng)站建設(shè),錫山品牌網(wǎng)站建設(shè),網(wǎng)站定制,錫山網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,錫山網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力。可充分滿足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
#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)識(shí)了你的集群,自動(dòng)探查會(huì)用到它。
#如果你在同一個(gè)網(wǎng)絡(luò)中運(yùn)行多個(gè)集群,那就要確保你的集群名稱是獨(dú)一無(wú)二的.
cluster.name: test-elasticsearch
#節(jié)點(diǎn)名稱會(huì)在啟動(dòng)的時(shí)候自動(dòng)生成,所以你可以不用手動(dòng)配置。你也可以給節(jié)點(diǎn)指定一個(gè)特定的名稱.
node.name: "elsearch2"
#允許這個(gè)節(jié)點(diǎn)被選舉為一個(gè)主節(jié)點(diǎn)(默認(rèn)為允許)
#node.master: true
#允許這個(gè)節(jié)點(diǎn)存儲(chǔ)數(shù)據(jù)(默認(rèn)為允許)
# node.data: true
#You can exploit these settings to design advanced cluster topologies.
# 你可以利用這些設(shè)置設(shè)計(jì)高級(jí)的集群拓?fù)?/p>
#
# 1. You want this node to never become a master node, only to hold data.
# This will be the "workhorse" of your cluster.
# 1. 你不想讓這個(gè)節(jié)點(diǎn)成為一個(gè)主節(jié)點(diǎn),只想用來(lái)存儲(chǔ)數(shù)據(jù)。
# 這個(gè)節(jié)點(diǎn)會(huì)成為你的集群的“負(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. 你想讓這個(gè)節(jié)點(diǎn)成為一個(gè)主節(jié)點(diǎn),并且不用來(lái)存儲(chǔ)任何數(shù)據(jù),并且擁有空閑資源。
# 這個(gè)節(jié)點(diǎn)會(huì)成為你集群中的“協(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:
# 一個(gè)節(jié)點(diǎn)可以附帶一些普通的屬性,這些屬性可以在后面的自定義分片分配過(guò)濾或者allocation awareness中使用。
# 一個(gè)屬性就是一個(gè)簡(jiǎn)單的鍵值對(duì),類似于node.key: value, 這里有一個(gè)例子:
# node.rack: rack314
# By default, multiple nodes are allowed to start from the same installation location
# to disable it, set the following:
# 默認(rèn)的,多個(gè)節(jié)點(diǎn)允許從同一個(gè)安裝位置啟動(dòng)。若想禁止這個(gè)特性,按照下面所示配置:
# node.max_local_storage_nodes: 1
# Set the number of shards (splits) of an index (5 by default):
# 設(shè)置一個(gè)索引的分片數(shù)量(默認(rèn)為5)
# index.number_of_shards: 5
# Set the number of replicas (additional copies) of an index (1 by default):
# 設(shè)置一個(gè)索引的副本數(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ī)器上開(kāi)發(fā),禁用分布式特性是合理的做法。
# index.number_of_shards: 1 # index.number_of_replicas: 0
# Path to directory containing configuration (this file and logging.yml):
# 包含配置(這個(gè)文件和logging.yml)的目錄的路徑
# path.conf: /path/to/conf
# Path to directory where to store index data allocated for this node.
# 存儲(chǔ)這個(gè)節(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:
# 可以隨意的包含不止一個(gè)位置,這樣數(shù)據(jù)會(huì)在文件層跨越多個(gè)位置(a la RAID 0),創(chuàng)建時(shí)會(huì)
# 優(yōu)先選擇大的剩余空間的位置
# path.data: /path/to/data1,/path/to/data2
# Path to temporary files:
# 臨時(shí)文件的路徑
# 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)沒(méi)有安裝下面列出的插件,結(jié)點(diǎn)不會(huì)啟動(dòng)
# 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開(kāi)始swapping(換頁(yè))時(shí)ElasticSearch性能會(huì)低下,你應(yīng)該保證它不會(huì)換頁(yè)
# Set this property to true to lock the memory:
# 設(shè)置這個(gè)屬性為true來(lái)鎖定內(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è)置成了同一個(gè)值,確保機(jī)器有足夠的內(nèi)存來(lá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)聽(tīng)端口在[9200-9300],節(jié)點(diǎn)之間
# 通信的端口在[9300-9400]。(范圍的意思是說(shuō)如果一個(gè)端口已經(jīng)被占用,它將會(huì)自動(dòng)嘗試下一個(gè)端口)
# Set the bind address specifically (IPv4 or IPv6):
# 設(shè)置一個(gè)特定的綁定地址(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)用來(lái)與這個(gè)節(jié)點(diǎn)通信的地址。如果沒(méi)有設(shè)定,會(huì)自動(dòng)獲取。
# 必須是一個(gè)真實(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è)置一個(gè)自定義端口(默認(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è)置一個(gè)監(jiān)聽(tīng)HTTP傳輸?shù)淖远x端口
# http.port: 9200
# Set a custom allowed content length:
# 設(shè)置一個(gè)自定義的允許的內(nèi)容長(zhǎng)度
# 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就會(huì)生效,使用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目錄下有一個(gè)elasticsearch.in.sh文件,修改
ES_MIN_MEM=256m ES_MAX_MEM=1g
為合適的值
4、es的插件安裝:
Marvel是Elasticsearch的管理和監(jiān)控工具,對(duì)于開(kāi)發(fā)使用免費(fèi)的。它配備了一個(gè)叫做Sense的交互式控制臺(tái),方便通過(guò)瀏覽器直接與Elasticsearch交互。
Marvel是一個(gè)插件,在Elasticsearch目錄中運(yùn)行以下代碼來(lái)下載和安裝:
./plugin -i elasticsearch/marvel/latest
elasticsearch-head是一個(gè)elasticsearch的集群管理工具,它是完全由html5編寫的獨(dú)立網(wǎng)頁(yè)程序,你可以通過(guò)插件把它集成到es。
#./plugin -install mobz/elasticsearch-head
地址:http://172.16.2.24:25556/_plugin/head/
elasticsearch插件bigdesk安裝:
bigdesk是elasticsearch的一個(gè)集群監(jiān)控工具,可以通過(guò)它來(lái)查看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插件,根本建不了索引,并且讓訪問(wèn)http://172.16.2.24:25556/_plugin/head/ 集群一片空白,點(diǎn)擊web 創(chuàng)建索引頁(yè)沒(méi)有反應(yīng)。
注意:github https://github.com/medcl/elasticsearch-analysis-ik 給出了對(duì)應(yīng)的es的ik版本,1.7.0的es對(duì)應(yīng)的1.2.6的版本,開(kāi)始我這塊裝了1.8的ik,創(chuàng)建索引失敗,后臺(tái)也是報(bào)ik的錯(cuò)誤。
ik:1.2.6版本的下載:https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v1.6.1
安裝操作:
下載zip包解壓到一個(gè)目錄解壓縮:
#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至其他幾臺(tái)機(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配置文件如下,三臺(tái)同樣的配置,除了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
后臺(tái)啟動(dòng)es服務(wù):
[root@localhost bin]# pwd /data/elasticsearch-1.7.0/bin [root@localhost bin]# ./elasticsearch -d
三臺(tái)集群的機(jī)器中找其中一臺(tái)創(chuàng)建索引:
創(chuàng)建索引:
curl -X PUT 'http://172.16.2.24:25556/index' {"acknowledged":true}
注意:返回結(jié)果為acknowledged":true 為成功.
通過(guò)瀏覽器訪問(wèn):http://172.16.2.24:25556/_plugin/head/ 測(cè)試效果.
新聞名稱:Elasticsearch-1.7.0安裝部署
文章源于:http://www.ef60e0e.cn/article/ipgced.html