下elasticsearch,地址:
https://www.elastic.co/downloads/elasticsearch
下载完,后解压,到bin目录下运行./elasticsearch
因为我下载的是7.9.2版本的,但是系统安装的是jdk8,而这个版本的es要求的jdk版本最低是11,否则会提示如下错误,
future versions of Elasticsearch will require Java 11; your Java version from [/home/parallels/program/jdk1.8.0_261/jre] does not meet this requirement
只好重新安装jdk11
https://www.oracle.com/java/technologies/javase-jdk11-downloads.html
安装好了后,重新运行es
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[3]: 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
又有问题。一一解决
显示每个进程打开文件数太小,查看系统环境。
[parallels@10 bin]$ ulimit -Hn
4096
[parallels@10 bin]$ ulimit -Sn
1024
解决【1】修改文件 /etc/security/limits.conf 在文件末尾增加两行
* soft nofile 65535
* hard nofile 65537
解决【2】修改配置文件vim /etc/sysctl.conf ,在文件末尾增加一行
vm.max_map_count=655360
执行命令生效
[parallels@10 bin]$ sudo sysctl -p
修改配置文件后重新登录
解决【3】修改config/elasticsearch.yml配置文件
一并修改其他配置
cluster.initial_master_nodes: ["node-1"]
network.host: 10.211.55.14
http.port: 9200
path.logs: /path/to/logs
path.data: /path/to/data
node.name: node-1
cluster.name: my-elasticsearch
创建/path/to/logs|data目录,并复制权限
重新启动es
启动成功,访问成功
van@van Downloads$ curl http://10.211.55.14:9200/
{
"name" : "node-1",
"cluster_name" : "my-elasticsearch",
"cluster_uuid" : "daqaM63CTmaPVtkgzYFF3A",
"version" : {
"number" : "7.9.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "d34da0ea4a966c4e49417f2da2f244e3e97b4e6e",
"build_date" : "2020-09-23T00:45:33.626720Z",
"build_snapshot" : false,
"lucene_version" : "8.6.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
值得注意的是:es不允许以root身份启动,否则会提示错误
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root