1. Elasticsearch下载地址:
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz
2. 解压elasticsearch-7.3.0-linux-x86_64.tar.gz
tar -avxf elasticsearch-7.3.0-linux-x86_64.tar.gz
3 进入解压后的elasticsearch目录:
3.1. 新建data目录
在elasticsearch下建立data
mkdir data
3.2. 修改config/elasticsearch.yml:
vim config/elasticsearch.yml
取消下列项注释并修改:
cluster.name: my-cluster #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /opt/elasticsearch-7.3.0/data
path.logs: /opt/elasticsearch-7.3.0/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]
修改完后保存
4 准备启动es
./bin/elasticsearch
elasticsearch启动常见的几个报错
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
切换到root用户,编辑limits.conf添加如下内容
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
[2]: max number of threads [3818] for user [es] is too low, increase to at least [4096]
最大线程个数太低。修改配置文件etc/security/limits.conf,增加配置
* soft nproc 4096
* hard nproc 4096
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增加配置vm.max_map_count=262144
vi /etc/sysctl.conf
sysctl -p
执行命令sysctl -p生效
[4]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
问题原因:因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动
解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
测试一下:http://10.202.202.36:9200/
{
"name": "node-1",
"cluster_name": "elasticsearch",
"cluster_uuid": "M-JTUQ9QTt6aCPjX4C9-UQ",
"version": {
"number": "7.3.0",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "de777fa",
"build_date": "2019-07-24T18:30:11.767338Z",
"build_snapshot": false,
"lucene_version": "8.1.0",
"minimum_wire_compatibility_version": "6.8.0",
"minimum_index_compatibility_version": "6.0.0-beta1"
},
"tagline": "You Know, for Search"
}
5.后台启动:
./bin/elasticsearch -d
查看进程:
ps -ef|grep java