前提条件:Linux配置了java环境。
环境搭建:使用putty连接服务器,cd到/usr/local
下载压缩包: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.1.1-linux-x86_64.tar.gz
解压: tar -zxvf elasticsearch-7.1.1-linux-x86_64.tar.gz
修改elasticsearch.yml配置, 启动服务: ./bin/elasticsearch
理想情况下这几个步骤即可。但是在启动服务的时候会遇到一些问题,记录一下。
1: 不能使用root用户启动Elasticsearch.
- 创建新账号: adduser esuser
- 然后设置密码: passwd esuser, 根据提示输入密码即可。
- 给新用户授权: chown -R esuser /usr/local/elasticsearch-7.1.1
2:上面说到cd到/usr/local文件夹下,是因为不能在root文件夹下启动服务。
3: 启动时的error message:
unable to install syscall filter:
在elasticsearch.yml中新增配置bootstrap.system_call_filter,设为false。
4. elasticsearch.yml文件中默认配置path.data和path.logs的值未修改,启动时报错: Unable to create folder/directory /path/to/logs, 将两个配置的值修改为elasticsearch路径, /usr/local/elasticsearch-7.1.1/data
和 /usr/local/elasticsearch-7.1.1/logs。
5: 还有一些比较common的问题,error message:
bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
...
需要修改一些配置,可参考https://www.cnblogs.com/gentle-awen/p/10114759.html。其中有条错误max number of threads [1024] for user [hadoop] is too low, increase to at least [4096] 修改之后仍不生效,因为/etc/security/limits.d/90-nproc.conf的配置覆盖了/etc/security/limits.conf的值,修改为4096即可。
Elasticsearch启动成功后,浏览器访问http://ip:9200没有响应, 需要开放9200端口。修改/etc/sysconfig/iptable, 添加
-I INPUT -p tcp --dport 9200 -j ACCEPT, 再访问会返回
{
"name" : "node-1",
"cluster_name" : "my-es",
"cluster_uuid" : "GhUKtv3iSa-EAXN44UMZ_A",
"version" : {
"number" : "7.1.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "7a013de",
"build_date" : "2019-05-23T14:04:00.380842Z",
"build_snapshot" : false,
"lucene_version" : "8.0.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}