1. 程式人生 > >Linux安裝elasticsearch6.4

Linux安裝elasticsearch6.4

0.注意

我是基於Centos7安裝的,如果你是Centos6,需要額外的2項配置,如下

vim /etc/security/limits.d/90-nproc.conf
soft nproc 4096

vim config/elasticsearch.yml
bootstrap.memory_lock: false 
bootstrap.system_call_filter: false

1.新增使用者es

# 新增使用者es
useradd es

# 設定密碼
passwd es

# 新增使用者組gp
groupadd gp

# gp組新增使用者es
usermod -G gp es

2.下載解壓elasticsearch6.4

# 下載es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.0.tar.gz

# 解壓
tar -zvxf elasticsearch-6.4.0.tar.gz

# 將es移動到/usr/local下    
mv elasticsearch-6.4.0 /usr/local/elasticsearch

# 更改elasticsearch資料夾以及內部檔案的所屬使用者為es, 使用者組為gp, -R表示逐級
chown -R es:gp elasticsearch

3.修改配置

# 修改limits.conf
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096

# 修改sysctl.conf
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p (sysctl.conf生效)

# 修改配置檔案 config/application.yml
network.host: 172.17.9.30 (本機IP)

# 如果記憶體不夠 修改config/jvm.options
vim jvm.options
-Xms512m
-Xmx512m

4.啟動 (最好重新登入linux)

切換至使用者es (一定要做)
./bin/elasticsearch 啟動
./bin/elasticsearch -d 後臺啟動

注意:報logs/gc.log沒有許可權,應該是用root啟動過,要刪除elasticsearch下所有root生成的檔案(主要在config和logs資料夾下)

5.測試

訪問 http://127.0.0.1:9200
或者
    curl http://127.0.0.1:9200

出現如下json即啟動成功
{
  "name" : "tDkDMco",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "Uft6PQjGTH6OE7ya7T8qtQ",
  "version" : {
    "number" : "6.4.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "595516e",
    "build_date" : "2018-08-17T23:18:47.308994Z",
    "build_snapshot" : false,
    "lucene_version" : "7.4.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}