安裝ElasticSearch
1、安裝java
yum install -y java
查看java安裝結果
java -version
2、下載ElasticSearch安裝包,並解壓
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.5.0.tar.gz
tar -zxvf elasticsearch-6.5.0.tar.gz -C /usr/local/
3、添加新賬戶,ES不能在root賬戶中啓動
adduser esuser
passwd esuser
4、對ElasticSearch文件授權
chown -R esuser /usr/local/elasticsearch-6.5.0/
5、切換賬戶
cd /usr/local/elasticsearch-6.5.0/
su esuser
6、修改ElasticSearch配置
vi /config/elasticsearch.yml
network.host: 192.168.0.129
http.port: 9200
注意,IP地址、端口號和冒號之間是有一個空格,一定要加上
7、啓動ES
bin/elasticsearch(加“ -d ”可以後臺運行)
訪問鏈接192.168.0.129:9200,出現下面內容
啓動時遇到的問題
1、“OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N”
解決方案:
在jvm.options中添加-XX:-AssumeMP,文件在ES安裝目錄下:/config/jvm.options
2、提示端口未打開
解決方案:
在iptables中放開9200,9300端口(9200是http服務端口,9300是tcp服務端口),配置文件(/etc/sysconfig/iptables)中添加
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9300 -j ACCEPT
或者直接打開9200-9400之間的所有端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9200:9400 -j ACCEPT
3、“max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]”
解決方案:
su root vim /etc/sysctl.conf
添加
vm.max_map_count=655360
保存退出,然後使配置生效
sysctl -p
4、“max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]”
解決方案:
su root vim /etc/security/limits.conf
添加下面的配置
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096