栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Elasticsearch搭建

Elasticsearch搭建

Elasticsearch 搭建
1.下载elasticsearch-7.16.0,下载地址:https://www.elastic.co/cn/downloads/elasticsearch

2.上传下载的压缩包到linux服务器,解压文件

tar -zxvf elasticsearch-7.16.0-linux-x86_64.tar.gz //解压压缩包
cd elasticsearch-7.16.0 //进入目录
mkdir data //创建data文件夹,保存数据
3.修改Elasticsearch配置:config/elasticsearch.yml

cluster.name: apm-application
node.name: node-1
path.data: /app/elasticsearch/elasticsearch-7.16.0/data
path.logs: /app/elasticsearch/elasticsearch-7.16.0/logs
# ES监听的ip地址
network.host: 0.0.0.0
cluster.initial_master_nodes: ["node-1"]
 
# 需要开启跨域才能给elasticsearch-head,kibana等连接
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
4.尝试启动Elasticsearch。

./bin/elasticsearch -d
5.启动失败报错:通过日志可以发现,es不允许linux通过root用户启动,原因是出于系统安全考虑设置的条件。由于Elasticsearch可以接收用户输入的脚本并且执行,为了系统安全考虑,直接使用root权限会带来很大风险,所以我们创建一个elsearch用户

Caused by: java.lang.RuntimeException: can not run elasticsearch as root
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-7.2.0.jar:7.2.0]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-7.2.0.jar:7.2.0]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-7.2.0.jar:7.2.0]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-7.2.0.jar:7.2.0]
    ... 6 more
6.创建Elasticsearch启动用户,并设置权限等

groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
chown -R elsearch:elsearch elasticsearch-7.2.0

linux最大连接数调整 参考

​https://blog.csdn.net/weixin_43490106/article/details/118058283

为新用户授权

chown -R abc:abc /opt/elasticsearch-7.4.0 #文件夹所有者


7.使用elsearch用户,再次尝试启动即可

设置环境变量 4G启动

ES_JAVA_OPTS="-Xms4g -Xmx4g" ./bin/elasticsearch

验证是否安装成功

http://ip:9200/

{
  "name" : "uH5mI6F",
  "cluster_name" : "my-application",
  "cluster_uuid" : "db4huJLZRnCcY_kfT5B6VA",
  "version" : {
    "number" : "6.2.4",
    "build_hash" : "ccec39f",
    "build_date" : "2018-04-12T20:37:28.497551Z",
    "build_snapshot" : false,
    "lucene_version" : "7.2.1",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/683269.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号