在centos7 安装Elasticsearch7.7.0。 安装过程中遇到了一些问题,记录了下
Elasticsearch7.7.0
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.0-linux-x86_64.tar.gz
- Elasticsearch7 自带jdk11,如果没有安装jdk, es7使用缺省jdk11
- 如果已安装,使用已安装的jdk,低于11有警告,但不影响使用。
- 安装过程省略
es 使用root 无法启动
[root@localhost config]# adduser es
[root@localhost config]# passwd es
[root@localhost config]# chown -R es:es /usr/local/elasticsearch
#查看状态
[root@localhost local]# systemctl stop firewalld.service
[root@localhost local]# systemctl status firewalld.service
安装目录:/usr/local
[root@localhost local]# tar -xzf elasticsearch-7.7.0-linux-x86_64.tar.gz
[root@localhost local]# mv elasticsearch-7.7.0 elasticsearch
主要修改下jvm 内存,默认是 1g, 根据机器内存修改
[root@localhost config]# cd /usr/local/elasticsearch/bin
[root@localhost bin]# ./elasticsearch
curl 访问
[root@localhost ~]# curl -X GET http://localhost:9200
{
"name" : "localhost.localdomain",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "deFlcT79QFunCWs3rHsfKA",
"version" : {
"number" : "7.6.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "aa751e09be0a5072e8570670309b1f12348f023b",
"build_date" : "2020-02-29T00: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"
}
安装成功。
浏览器访问
http://192.168.1.105:9200/
可能无法访问,需要修改配置: vim elasticsearch.yml
network.host: 0.0.0.0
http.port: 9200
重启
可以看到服务器名称,elasticsearch 版本号等信息
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
es 为了安全,不能使用root 启动,新建普通用户,用普通用户启动
[root@localhost config]# adduser es
[root@localhost config]# passwd es
[root@localhost config]# chown -R es:es /usr/local/elasticsearch
[root@localhost config]# cd /usr/local/elasticsearch/bin
[root@localhost bin]# ./elasticsearch
initial heap size [67108864] not equal to maximum heap size [134217728]; this can cause resize pauses and prevents mlockall from locking the entire heap
jvm内存不够,修改es 的jvm 配置 vim elasticsearch/config/jvm.options
-Xms64m #默认1g, 根据自己机器内存修改
-Xmx64m
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
查看配置
[root@localhost config]# ulimit -Hn
4096
用户打开文件数:4096,有限制,修改配置。切换root 用户,配置文件添加如下配置: vim /etc/security/limits.conf
es soft nofile 65536
es hard nofile 65536
退出重新登陆
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
修改es 配置:vim elasticsearch.yml
cluster.initial_master_nodes: ["node-1"]
重启