ElasticSearch安裝部署,基本配置(Ubuntu14.04)
阿新 • • 發佈:2019-03-17
安裝部署 中修改 tab variable upd expect ret change 說明
ElasticSearch部署文檔(Ubuntu 14.04)
安裝java
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
java -version
whereis java
which java (java執行路徑)
echo $JAVA_HOME
echo $PATH
安裝ElasticSearch
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elastic.co/elasticsearch/1.6/debian stable main" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get install elasticsearch
sudo update-rc.d elasticsearch defaults 95 10
ElasticSearch各個目錄說明
type | description | location |
---|---|---|
home | Home of elasticsearch installation | /usr/share/elasticsearch |
bin | Binary scripts including elasticsearch to start a node | /usr/share/elasticsearch/bin |
conf | Configuration files elasticsearch.yml and logging.yml | /etc/elasticsearch |
conf | Environment variables including heap size,file descriptors | /etc/default/elasticsearch |
data | The location of the data files | /var/lib/elasticsearch/ |
logs | Log files location | /var/log/elasticsearch |
plugins | Plugin files location | /usr/share/elasticsearch/plugins |
配置
ES_HEAP_SIZE
# 在/etc/default/elasticsearch中修改:
ES_HEAP_SIZE=4g #不要超過32g,如果整臺機器只部署ES,一半內存用於Java heap,另一半給Lucene
File Descriptors
cat <<EOF>> /etc/security/limits.conf
elasticsearch - nofile 65535
EOF
# 在/etc/default/elasticsearch中修改:
MAX_OPEN_FILES=65535
Virtual memory
cat <<EOF>> /etc/sysctl.conf
vm.max_map_count=262144
EOF
sysctl -p
Memory Settings
# 在/etc/elasticsearch/elasticsearch.yml中修改:
bootstrap.mlockall: true
# 在/etc/default/elasticsearch中修改:
MAX_LOCKED_MEMORY=unlimited
其他
在/etc/elasticsearch/elasticsearch.yml中修改:
# 集群名稱,同一集群,名稱要設置相同
cluster.name: elasticsearch_production
# 節點名稱
node.name: elasticsearch_001_data
# 數據路徑,可配置多個,英文逗號分開,註意目錄的權限,保證elasticsearch用戶可寫
path.data: /path/to/data1,/path/to/data2
# 日誌路徑,註意目錄的權限,保證elasticsearch用戶可寫
path.logs: /path/to/logs
# 插件路徑
path.plugins: /path/to/plugins
# 該屬性是為了形成一個集群,有主節點資格並互相連接的節點的最小數目
# (number of master-eligible nodes / 2) + 1。 下面的值是在3個有主節點資格的情況下設定
# 因為節點數,以後可以增加,或者減少,故該配置可以動態修改
discovery.zen.minimum_master_nodes: 2
# 恢復控制
gateway.recover_after_nodes: 2
gateway.expected_nodes: 3
gateway.recover_after_time: 5m
#關閉多播,用單播。並指定至少一個能接受單播的主機
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["192.168.2.1:9300", "192.168.2.2:9300", "192.168.2.3:9300"]
啟動
sudo /etc/init.d/elasticsearch start
# 驗證上面一些配置是否配置成功
curl localhost:9200/_nodes/process?pretty
參考鏈接
- https://www.elastic.co/guide/en/elasticsearch/guide/current/heap-sizing.html
- https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html#setup-configuration
- https://www.elastic.co/guide/en/elasticsearch/guide/current/_file_descriptors_and_mmap.html
- https://www.elastic.co/guide/en/elasticsearch/guide/current/_important_configuration_changes.html
- https://github.com/grigorescu/Brownian/wiki/ElasticSearch-Configuration
ElasticSearch安裝部署,基本配置(Ubuntu14.04)