OS:Centos7x虛擬機 1H2G
jdk:1.8
elasticsearch:5.6.0
1、下載“elasticsearch-5.6.0.tar.gz”解壓到/usr/local/elasticsearch目錄下。
2、啟動elasticSearch
這里需要注意的是,es
規定 root
用戶不能啟動 es
,所以需要創建一個用戶來啟動 es
# 創建用戶名為 es 的用戶 useradd es # 設置 es 用戶的密碼 passwd es # 創建 es 的 data 和 logs 目錄 mkdir elasticsearch-5.6.0/data mkdir elasticsearch-5.6.0/logs # 將 /usr/local/elasticsearch/elasticsearch-5.6.0 的擁有者設置為 es chown -R es:es /usr/local/elasticsearch/elasticsearch-5.6.0
編輯配置文件config/elasticsearch.yml
network.host: 你自己的服務器ip http.port: 9200
切換到 es
用戶,啟動 es
su es # -d是后台啟動,第一次不建議后台啟動,前台啟動可以直觀的看到日志信息 bin/elasticsearch -d
可能遇到的錯誤:
問題:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
解決方法:
#切換到root用戶修改 vim /etc/security/limits.conf # 在最后面追加下面內容 es hard nofile 65536 es soft nofile 65536
修改后重新登錄 es
用戶,使用如下命令查看是否修改成功
ulimit -Hn 65536
問題:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解決方法 提高vm.max_map_count 的大小
# 切換到root用戶 vim /etc/sysctl.conf # 在最后面追加下面內容 vm.max_map_count=262144 # 使用 sysctl -p 查看修改后的結果 sysctl -p
問題:
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
解決方法:
# 由於elasticsearch5.0默認分配jvm空間大小為2g,修改jvm空間分配 # 如果使用虛擬機安裝,內存最好不小於2G # vim config/jvm.options -Xms512m -Xmx512m
在阿里雲上可能出現的問題:
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解決方法:在es配置中加入下面命令即可
bootstrap.system_call_filter: false
在確定服務器端口(9200)開啟,elasticsearch啟動的情況下(ps -ef | grep elasticsearch)可以在瀏覽器中訪問
3、關閉elasticSearch
# 找到elasticsearch的進程號 jps | grep Elasticsearch 3673 Elasticsearch kill -9 3673
技術交流群:576269252
------------------------------------------
聲明: 原創文章,未經允許,禁止轉載!
------------------------------------------