Contos8安装elasticseach7.17.0
下载
官网(https://www.elastic.co/cn/downloads/past-releases#elasticsearch)选择下载你需要的版本,这里我选择的是7.17.0的版本。
注意:如果需要安装kibana管理es,则kibana版本需要与es的对应
下载好后,上传到你需要部署的服务器(可以参考scp指令上传文件).
上传后,使用下面指令解压得到解压包
tar -zxvf java.tar.gz
# tar -zxvf java.tar.gz -C /data/es #可以指定解压路径
编辑配置文件
在配置文件config/elasticsearch.yam文件中添加以下内容
cluster.name: my-application
node.name: node-1 #节点名称
cluster.initial_master_nodes: ["node-1"] #指定主节点
path.data: /data/es/elasticsearch/elasticsearch-7.17.0/data
path.logs: /data/es/elasticsearch/elasticsearch-7.17.0/logs
network.host: 0.0.0.0
http.port: 9200
踩坑记录: 1、network.host配置为127.0.0.1启动后,本地curl 127.0.0.1:9200可以获取到es数据信息,但是在端口开放的前提下外网无法访问到9200的端口; 2、没有配置cluster.initial_master_nodes: ["node-1"],运行时报错:bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch;
启动elasticsearch
在Contos系统上,不允许使用root用户运行elastic search,所以需要创建一个用户用来运行elasticsearch程序。
sudo useradd elastic #创建用户
chown -R elastic /data/es/elasticsearch-7.17.1/ #用户授权
su elastic # 切换elastic 用户
踩坑记录:创建用户后不授权直接运行时会报错
进入elasticsearch目录下,运行bin/elasticsearc脚本即可运行成功。
./bin/elasticsearch -d #-d 为守护进程模式运行
启动后,本机终端输入curl localhost:9200可以看到
外网访问ip:9200可以看到
其他问题
启动时遇到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
ERROR: Elasticsearch did not exit normally - check the logs at /data/es/elasticsearch/elasticsearch-7.17.0/logs/my-application.log报错,在/etc/sysctl.conf文件中添加 vm.max_map_count=262144,添加后使用指令/sbin/sysctl -p
使配置生效。
集群模式
【后续学习。。。】