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