ubuntu搭建Elasticsearch过程与问题
创始人
2024-01-30 09:26:15

目录

一.下载Elasticsearh

二.解压 创建需要的文件目录

三.修改配置文件

四.遇到的问题

1.root账号启动问题

2.创建文件不授权切换到非root用户test的时候报错

3.启动最后还是报错

4.浏览器请求http://localhost:9200 报错:received plaintext http traffic on an https channel, closing connection Netty4HttpChannel


一.下载Elasticsearh

Download Elasticsearch | Elastic

自己下载的 8.0.0 https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.0.0-linux-x86_64.tar.gz

 wget https://artifacts.elastic.co/downloads/logstash/logstash-8.0.0-linux-x86_64.tar.gz

二.解压 创建需要的文件目录

tar -zxvf elasticsearch-8.0.0-linux-x86_64.tar.gz 
mkdir /data/elasticsearch/data /data/elasticsearch/logschmod 777 /data/elasticsearch

三.修改配置文件

jvm.options 具体要不要添加不知道,看网上说要加就加,用的虚拟机所有用的1g,其他根据实际情况修改


################################################################
-Xms1g
-Xmx1g################################################################

elasticsearch.yml 下面的地址用的是第二点创建的地址,修改xpack.security.enabled: false,修改enabled: false 否则访问的时候时候报错,文章最后会列出来遇到的报错

# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /data/elasticsearch/data
#
# Path to log files:
#
path.logs: /data/elasticsearch/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
network.host: 192.168.208.112
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1"]
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: false#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
#
# The following settings, TLS certificates, and keys have been automatically      
# generated to configure Elasticsearch security features on 18-11-2022 06:54:11
#
# --------------------------------------------------------------------------------# Enable security features
xpack.security.enabled: falsexpack.security.enrollment.enabled: true# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:enabled: falsekeystore.path: certs/http.p12# Enable encryption and mutual authentication between cluster nodes
xpack.security.transport.ssl:enabled: trueverification_mode: certificatekeystore.path: certs/transport.p12truststore.path: certs/transport.p12
# Create a new cluster with the current node only
# Additional nodes can still join the cluster later
cluster.initial_master_nodes: ["ubuntu"]

以上配置还不能正常请求

四.遇到的问题

1.root账号启动问题

[2022-11-18T14:57:35,662][ERROR][o.e.b.ElasticsearchUncaughtExceptionHandler] [ubuntu] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:170) ~[elasticsearch-8.0.0.jar:8.0.0]
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:157) ~[elasticsearch-8.0.0.jar:8.0.0]

解决办法:

adduser test
passwd test
chown -R test:test elasticsearch-8.0.0/
chmod 770 elasticsearch-8.0.0/

参考了:java.lang.RuntimeException: can not run elasticsearch as root_wkCaeser_的博客-CSDN博客

注意里面的第一种方法./elasticsearch -Des.insecure.allow.root=true

试过了不行报错如下,最后还是改成了切换用户启动 :

ERROR: D is not a recognized option

2.创建文件不授权切换到非root用户test的时候报错

 2022-11-18 15:04:53,121 main ERROR RollingFileManager (/data/elasticsearch/logs/elasticsearch_server.json) java.io.FileNotFoundException: 
 /data/elasticsearch/logs/elasticsearch_server.json (Permission denied) java.io.FileNotFoundException: /data/elasticsearch/logs/elasticsearch_server.json (Permission denied)

3.启动最后还是报错

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
ERROR: Elasticsearch did not exit normally - check the logs at /data/elasticsearch/logs/elasticsearch.log
[2022-11-18T15:08:24,009][INFO ][o.e.n.Node               ] [ubuntu] stopping ...
[2022-11-18T15:08:24,047][INFO ][o.e.n.Node               ] [ubuntu] stopped
[2022-11-18T15:08:24,047][INFO ][o.e.n.Node               ] [ubuntu] closing ...
[2022-11-18T15:08:24,058][INFO ][o.e.n.Node               ] [ubuntu] closed
[2022-11-18T15:08:24,060][INFO ][o.e.x.m.p.NativeController] [ubuntu] Native controller process has stopped - no new native processes can be started

解决办法:

vi /etc/security/limits.conf追加以下内容:
* soft    nofile  65536
* hard    nofile  65536
* soft    nproc   4096
* hard    nproc   4096

注意:此文件修改后需要重新登录用户,才会生效

4.浏览器请求http://localhost:9200 报错:received plaintext http traffic on an https channel, closing connection Netty4HttpChannel

received plaintext http traffic on an https channel, closing connection Netty4HttpChannel{localAddress=/[0:0:0:0:0:0:0:1]:9200

解决办法, 修改两个如下:

# Enable security features
xpack.security.enabled: falsexpack.security.enrollment.enabled: true# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
xpack.security.http.ssl:enabled: falsekeystore.path: certs/http.p12

最后输入locahost:9200出现如下表示OK

 

 报错参考:Elasticsearch报错: received plaintext http traffic on an https channel, closing connection ..._zhangphil的博客-CSDN博客

Elasticsearch报错: received plaintext http traffic on an https channel, closing connection ..._zhangphil的博客-CSDN博客

 

相关内容

热门资讯

埃菲尔铁塔在哪 中国仿建埃菲尔... 2019年4月26日,广西南宁市,街头惊现一座巨型山寨版埃菲尔铁塔,高约20米,白色塔身,造型逼真,...
苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
最安全的匿名举报方式 匿名12... 来源:中安在线8月9日,河北邢台小伙张钊(化名)在河北政务服务网12345平台举报楼上邻居涉嫌非法开...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...
应用未安装解决办法 平板应用未... ---IT小技术,每天Get一个小技能!一、前言描述苹果IPad2居然不能安装怎么办?与此IPad不...
脚上的穴位图 脚面经络图对应的... 人体穴位作用图解大全更清晰直观的标注了各个人体穴位的作用,包括头部穴位图、胸部穴位图、背部穴位图、胳...
长白山自助游攻略 吉林长白山游... 昨天介绍了西坡的景点详细请看链接:一个人的旅行,据说能看到长白山天池全凭运气,您的运气如何?今日介绍...
猫咪吃了塑料袋怎么办 猫咪误食... 你知道吗?塑料袋放久了会长猫哦!要说猫咪对塑料袋的喜爱程度完完全全可以媲美纸箱家里只要一有塑料袋的响...
世界上最漂亮的人 世界上最漂亮... 此前在某网上,选出了全球265万颜值姣好的女性。从这些数量庞大的女性群体中,人们投票选出了心目中最美...
中国光棍有多少人 2020年9... 我国是世界上人口最多的国家,庞大的人口基数为我国的发展带来了许多的益处。但是同时,我国也是出生人口性...
埃菲尔铁塔在哪 中国仿建埃菲尔... 2019年4月26日,广西南宁市,街头惊现一座巨型山寨版埃菲尔铁塔,高约20米,白色塔身,造型逼真,...
苗族的传统节日 贵州苗族节日有... 【岜沙苗族芦笙节】岜沙,苗语叫“分送”,距从江县城7.5公里,是世界上最崇拜树木并以树为神的枪手部落...
北京的名胜古迹 北京最著名的景... 北京从元代开始,逐渐走上帝国首都的道路,先是成为大辽朝五大首都之一的南京城,随着金灭辽,金代从海陵王...