您好,登錄后才能下訂單哦!
1、首先去elasticsearch官網下載軟件包版本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配置文件參數解釋(真正配置不全用的到):
#集群名稱標識了你的集群,自動探查會用到它。
#如果你在同一個網絡中運行多個集群,那就要確保你的集群名稱是獨一無二的.
cluster.name: test-elasticsearch
#節點名稱會在啟動的時候自動生成,所以你可以不用手動配置。你也可以給節點指定一個特定的名稱.
node.name: "elsearch2"
#允許這個節點被選舉為一個主節點(默認為允許)
#node.master: true
#允許這個節點存儲數據(默認為允許)
# node.data: true
#You can exploit these settings to design advanced cluster topologies.
# 你可以利用這些設置設計高級的集群拓撲
#
# 1. You want this node to never become a master node, only to hold data.
# This will be the "workhorse" of your cluster.
# 1. 你不想讓這個節點成為一個主節點,只想用來存儲數據。
# 這個節點會成為你的集群的“負載器”
#
# 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. 你想讓這個節點成為一個主節點,并且不用來存儲任何數據,并且擁有空閑資源。
# 這個節點會成為你集群中的“協調器”
# 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] ,
# 節點信息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:
# 一個節點可以附帶一些普通的屬性,這些屬性可以在后面的自定義分片分配過濾或者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:
# 默認的,多個節點允許從同一個安裝位置啟動。若想禁止這個特性,按照下面所示配置:
# node.max_local_storage_nodes: 1
# Set the number of shards (splits) of an index (5 by default):
# 設置一個索引的分片數量(默認為5)
# index.number_of_shards: 5
# Set the number of replicas (additional copies) of an index (1 by default):
# 設置一個索引的副本數量(默認為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:
# 注意,為了使用小的索引在本地機器上開發,禁用分布式特性是合理的做法。
# 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.
# 存儲這個節點的索引數據的目錄的路徑
# 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:
# 可以隨意的包含不止一個位置,這樣數據會在文件層跨越多個位置(a la RAID 0),創建時會
# 優先選擇大的剩余空間的位置
# 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.
# 如果當前結點沒有安裝下面列出的插件,結點不會啟動
# plugin.mandatory: mapper-p_w_uploads,lang-groovy
# ElasticSearch performs poorly when JVM starts swapping: you should ensure that
# it _never_ swaps.
# 當JVM開始swapping(換頁)時ElasticSearch性能會低下,你應該保證它不會換頁
# Set this property to true to lock the memory:
# 設置這個屬性為true來鎖定內存
# 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環境變量設置成了同一個值,確保機器有足夠的內存來分配
# 給ElasticSearch,并且保留足夠的內存給操作系統
# You should also make sure that the ElasticSearch process is allowed to lock
# the memory, eg. by using `ulimit -l unlimited`.
# 你應該確保ElasticSearch的進程可以鎖定內存,例如:使用`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).
# 默認的ElasticSearch把自己和0.0.0.0地址綁定,HTTP傳輸的監聽端口在[9200-9300],節點之間
# 通信的端口在[9300-9400]。(范圍的意思是說如果一個端口已經被占用,它將會自動嘗試下一個端口)
# Set the bind address specifically (IPv4 or IPv6):
# 設置一個特定的綁定地址(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.
# 設置其他節點用來與這個節點通信的地址。如果沒有設定,會自動獲取。
# 必須是一個真實的IP地址。
# network.publish_host: 192.168.0.1
# Set both 'bind_host' and 'publish_host':
# 'bind_host'和'publish_host'都設置
# network.host: 192.168.0.1
# Set a custom port for the node to node communication (9300 by default):
# 為節點之間的通信設置一個自定義端口(默認為9300)
# transport.tcp.port: 9300
# Enable compression for all communication between nodes (disabled by default):
# 為所有的節點間的通信啟用壓縮(默認為禁用)
# transport.tcp.compress: true
# Set a custom port to listen for HTTP traffic:
# 設置一個監聽HTTP傳輸的自定義端口
# http.port: 9200
# Set a custom allowed content length:
# 設置一個自定義的允許的內容長度
# http.max_content_length: 100mb
# Disable HTTP completely:
# 完全禁用HTTP
# http.enabled: false
3、操作系統配置
1.文件描述符
vim /etc/security/limits.conf添加 * soft nofile 655350 * hard nofile 655350
退出當前用戶重新login就會生效,使用ulimit -n驗證下。
2.最大內存映射區數量,禁用swap交換分區
vim /etc/sysctl.conf增加 vm.max_map_count=262144 vm.swappiness=1 修改完成后sysctl -p
jvm參數配置
ES_HOME的bin目錄下有一個elasticsearch.in.sh文件,修改
ES_MIN_MEM=256m ES_MAX_MEM=1g
為合適的值
4、es的插件安裝:
Marvel是Elasticsearch的管理和監控工具,對于開發使用免費的。它配備了一個叫做Sense的交互式控制臺,方便通過瀏覽器直接與Elasticsearch交互。
Marvel是一個插件,在Elasticsearch目錄中運行以下代碼來下載和安裝:
./plugin -i elasticsearch/marvel/latest
elasticsearch-head是一個elasticsearch的集群管理工具,它是完全由html5編寫的獨立網頁程序,你可以通過插件把它集成到es。
#./plugin -install mobz/elasticsearch-head
地址:http://172.16.2.24:25556/_plugin/head/
elasticsearch插件bigdesk安裝:
bigdesk是elasticsearch的一個集群監控工具,可以通過它來查看es集群的各種狀態,如:cpu、內存使用情況,索引數據、搜索情況,http連接數等。
在cmd命令行中進入安裝目錄,再進入 bin目錄,運行以下命令:
#./plugin -install lukas-vlcek/bigdesk
在瀏覽器中輸入:http://172.16.2.24:25556/_plugin/bigdesk可以看到效果
注意:elasticsearch 分詞ik的安裝,如果不安裝分詞ik插件,根本建不了索引,并且讓訪問http://172.16.2.24:25556/_plugin/head/ 集群一片空白,點擊web 創建索引頁沒有反應。
注意:github https://github.com/medcl/elasticsearch-analysis-ik 給出了對應的es的ik版本,1.7.0的es對應的1.2.6的版本,開始我這塊裝了1.8的ik,創建索引失敗,后臺也是報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環境,apache 官網下載軟件包設置環境變量:
#export PATH=$PATH:/usr/local/maven/bin
因為是源代碼,此處需要使用maven打包,進入解壓文件夾中,執行命令:
#cd elasticsearch-analysis-ik-master #mvn clean package
#在es的plugin目錄下創建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至其他幾臺機器。
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服務:
[root@localhost bin]# pwd /data/elasticsearch-1.7.0/bin [root@localhost bin]# ./elasticsearch -d
三臺集群的機器中找其中一臺創建索引:
創建索引:
curl -X PUT 'http://172.16.2.24:25556/index' {"acknowledged":true}
注意:返回結果為acknowledged":true 為成功.
通過瀏覽器訪問:http://172.16.2.24:25556/_plugin/head/ 測試效果.
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。