下载最新版
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.0-linux-x86_64.tar.gz
解压
tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz
移动目录
cd /usr/local/
mkdir elasticsearch
mv /data/elk/elasticsearch-7.0.0 /usr/local/elasticsearch/
修改配置
vim config/elasticsearch.yml
network.host: 0.0.0.0 //设置所有IP都能访问
http.port: 9200 //设置端口
#增加该配置,允许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
#不配置会出现 the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
cluster.initial_master_nodes: ["node-1"]
创建用户es,并赋权
useradd es
passwd es
chown -R es:es /usr/local/elasticsearch/elasticsearch-7.0.0/
切换用户,并启动elasticsearch
su es
cd /usr/local/elasticsearch/elasticsearch-7.0.0/
./bin/elasticsearch //前台启动
./bin/elasticsearch -d //后台启动
会出现以下错误
错误:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方法:
echo "vm.max_map_count=262144" > /etc/sysctl.conf
sysctl -p
错误:
the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
解决方法:
在上面配置文件的配置中已经说了,需要修改配置文件设置cluster.initial_master_nodes: ["node-1"]
访问IP:9200,出现下面内容启动成功
{
"name" : "clark-app2",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "ASWWjZi3RzqbMqXgZf9yEw",
"version" : {
"number" : "7.0.0",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "b7e28a7",
"build_date" : "2019-04-05T22:55:32.697037Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.7.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}