【es-01】CentOS7.6安裝Elasticsearch 6.2.2

1、環境

  • centos7.6
[root@localhost soft]# lsb_release -a
LSB Version:    :core-4.1-amd64...
Distributor ID: CentOS
Description:    CentOS Linux release 7.6.1810 (Core) 
Release:        7.6.1810
Codename:       Core
  • jdk1.8
[root@localhost soft]# java -version
java version "1.8.0_211"
Java(TM) SE Runtime Environment (build 1.8.0_211-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.211-b12, mixed mode)

2、下載 elasticsearch-6.2.2.tar.gz

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.2.tar.gz

3、解壓到你喜歡的目錄

 tar zxvf elasticsearch-6.2.2.tar.gz -C /usr/local/develop/elasticsearch/

4、修改config/elasticsearch.yml配置

#數據目錄
path.data: /usr/local/develop/elasticsearch/elasticsearch-6.2.2/data
#日誌目錄
path.logs: /usr/local/develop/elasticsearch/elasticsearch-6.2.2/logs
#支持外網訪問
network.host: 0.0.0.0

4.進入目錄elasticsearch-6.2.2,並啓動elasticsearch

cd elasticsearch-6.2.2/bin

./elasticsearch

# 報錯:
java.lang.RuntimeException: can not runelasticsearch as root

5、解決不可以用root用戶啓動es

#增加用戶組
sudo groupadd es

#增加用戶,並規定所屬用戶組和密碼
sudo useradd es -g es -p es -M

# 遞歸更改文件的擁有者
sudo chown -R es:es /usr/local/elasticsearch6.2.2

6、修改max_map_count太小

錯誤信息:max virtual memory areas vm.max_map_count [65530] is too low
max_map_count:允許一個進程在VMAs(虛擬內存區域)擁有最大數量。

解決:
sudo vim /etc/sysctl.conf

#增加以下內容:
vm.max_map_count=262144

#保存退出vim後使sysctl.conf生效:
sysctl -p

7、最大文件數、最大進程數、 最大鎖定內存地址空間。

錯誤信息:Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
memory locking requested for elasticsearch process but memory is not locked12345

解決:修改limits.conf配置
sudo vim /etc/security/limits.conf

# 添加如下內容:
es soft nofile 65536
es hard nofile 65536
es soft nproc 65536
es hard nproc 65536 
es soft memlock unlimited
es hard memlock unlimited 

8、啓動elasticsearch

# 切換到es用戶,在bin下執行./elasticsearch
su es
./elasticsearch

10、成功後退出再後臺啓動。

./elasticsearch -d

11、查看狀態

linux命令行:
#查看可以監測的參數
curl localhost:9200/_cat

#查看健康信息
curl localhost:9200/_cat/health

瀏覽器:
#查看elasticsearch是否啓動成功
http://ip:9200/

#查看elasticsearch健康狀態
http://ip:9200/_cat/health?v



作者:境與界
鏈接:https://www.jianshu.com/p/98f9dbda53ca
來源:簡書
著作權歸作者所有。商業轉載請聯繫作者獲得授權,非商業轉載請註明出處。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章