首先在官网找到下载地址
https://www.elastic.co/cn/downloads/elasticsearch
一、安装es
1.使用命令下载文件:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.8.tar.gz
2.解压:
tar -zxf elasticsearch-5.6.8.tar.gz
3.创建用户
useradd esuser
passwd esuser
4.赋予权限
chown -R es /usr/local/elasticsearch-5.6.8
5.使用esuser去文件夹启动es
./elasticsearch
6.测试成功访问
curl 127.0.0.1:9200
二、设置可被外部访问
1.修改es项目下config目录下的elasticsearch.yml。
找到下面内容:
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
Set a custom port for HTTP:
#
http.port: 9200
#
For more information, consult the network module documentation.
#
2.vim /etc/security/limits.conf添加
* hard nofile 65536
* soft nofile 65536
3.修改vim /etc/sysctl.conf添加
vm.max_map_count=655360
执行[root@localhost ~]# sysctl -p
4.重启虚拟机
5.centos7关闭防火墙
查看防火墙状态
firewall-cmd --state
临时关闭防火墙
systemctl stop firewalld.service
永久关闭防火墙
systemctl disable firewalld
成功:
[root@localhost ~]# curl 127.0.0.1:9200
{
“name” : “Uv9QLs6”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “O9NNmTNaQQ-oODpYJ61GeQ”,
“version” : {
“number” : “5.6.8”,
“build_hash” : “688ecce”,
“build_date” : “2018-02-16T16:46:30.010Z”,
“build_snapshot” : false,
“lucene_version” : “6.6.1”
},
“tagline” : “You Know, for Search”
}
☆设置防火墙访问可参考:https://www.jianshu.com/p/1f0d55733591