环境说明
- redhat
- java 8
安装elasticsearch
es安装默认不支持使用root用户安装,否则会提示java.lang.RuntimeException: can not run elasticsearch as root
新建用户组
groupadd es
useradd es -g es
passwd es
es2020
chown -R es:es elasticsearch-7.6.1
su - es
从官网下载elasticsearch,然后执行以下命令。
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-linux-x86_64.tar.gz
//解压
tar-xzvf elasticsearch-7.6.2-linux-x86_64.tar.gz
//进入解压目录
./bin/elasticsearch
执行成功后,es会使用9200端口运行
curl localhost:9200
//返回一个 JSON 对象,包含当前节点、集群、版本等信息。
{
"name" : "node74",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "OUU4f0tiQnazkiQOlExfFw",
"version" : {
"number" : "7.6.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
"build_date" : "2020-03-01T00:15:25.529771Z",
"build_snapshot" : false,
"lucene_version" : "8.4.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
参数 | 说明 |
---|---|
cluster.name | 集群名称,相同名称为一个集群 |
node.name | 节点名称,集群模式下每个节点名称唯一 |
node.master | 当前节点是否可以被选举为master节点,是:true、否:false |
node.data | 当前节点是否用于存储数据,是:true、否:false |
path.data | 索引数据存放的位置 |
path.logs | 日志文件存放的位置 |
bootstrap.memory_lock | 需求锁住物理内存,是:true、否:false |
network.host | 监听地址,用于访问该es, 0.0.0.0允许任务服务器访问 |
network.publish_host | 可设置成内网ip,用于集群内各机器间通信 |
http.port | es对外提供的http端口,默认 9200 |
transport.tcp.port | TCP的默认监听端口,默认 9300 |
discovery.seed_hosts | es7.x 之后新增的配置,写入候选主节点的设备地址,在开启服务后可以被选为主节点 |
cluster.initial_master_nodes | es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举master |
http.cors.enabled | 是否支持跨域,是:true,在使用head插件时需要此配置 |
http.cors.allow-origin | “*” 表示支持所有域名 |