linux安装部署Elasticsearch6.6

啥都不管,先安装ES

学什么东西都先二话不说的先来一个hello world
																	——鲁迅

本教程仅做个人工作笔记,可能不适用于他人的工作/学习

几个注意的点

  • 需要在linux中创建新用户,不能直接使用root启动ES
  • elasticsearch.yml中的配置,尤其是network.host
  • 需要另外配置etc下的配置文件

tar包下载地址 https://www.elastic.co/cn/downloads/elasticsearch
博主是下载之后用ftp将tar包传输到服务器上的;
也可以使用weget的方式直接在linux上下载;

下载之后解压
tar -xzvf xxxx.tar
解压后需要做改动的地方是config文件夹下的elasticsearch.yml

vi一下丫的
vi elasticsearch.yml

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/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 -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

需要注意的几个配置cluster.namenode.namenetwork.hosthttp.port,其中前两个是自定义的名字,network.host设置为“0.0.0.0”,这样你的浏览器才能连接上,http.port默认为9200,结果如下

cluster.name="elastic_demo"
node.name="elastic_demo_node"
network.host="0.0.0.0"
http.port=9200

简单配置后就是尝试启动,那么我们的问题就踏着轻快的脚步来了

1、can not run elasticsearch as root
为了安全,elasticsearch不允许使用root用户直接启动,解决方案如下

新建用户:
useradd elasticUser
给用户添加密码:
passwd elasticUser
系统会提示你输入密码并确认密码
在root的环境下给新建的用户赋予elastic文件夹的权限:
chown -R elasticUser elastic/
切换到新用户 :
su elasticUser
然后再进到bin目录下启动脚本:
./elasticsearch

2、你以为这样就启动成功了吗?MD不可能

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] 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]

问题[1]的解决方案

编辑 /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
记得要切换回root账户去修改,修改后启动,发现只剩一个问题,修改生效

问题[2]的解决方案

编辑 /etc/sysctl.conf,追加以下内容:
vm.max_map_count=655360
保存后,执行:
sysctl -p

最后为了能测试访问es,还需要再elasticsearch.yml文件中追加配置

http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true

然后重启,访问ip:9200,如果浏览器出现以下信息

{
  "name" : "XXX",
  "cluster_name" : "XXX",
  "cluster_uuid" : "XXXXXXXX",
  "version" : {
    "number" : "6.6.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "a9861f4",
    "build_date" : "2019-01-24T11:27:09.439740Z",
    "build_snapshot" : false,
    "lucene_version" : "7.6.0",
    "minimum_wire_compatibility_version" : "5.6.0",
    "minimum_index_compatibility_version" : "5.0.0"
  },
  "tagline" : "You Know, for Search"
}

这是最简单的启动成功了


2020/4/8补充

  • swapping性能问题

elasticsearch.yml配置文件中有这么一行配置#bootstrap.memory_lock: true默认是屏蔽掉的,也就是false属性,官网的解释 是:发生系统swapping的时候ES节点的性能会非常差,也会影响节点的稳定性。所以要不惜一切代价来避免swapping。swapping会导致Java GC的周期延迟从毫秒级恶化到分钟,更严重的是会引起节点响应延迟甚至脱离集群。

通常我们的做法只是限制es进程所占用的内存,在VM的相关文件中进行限制即可,保险期间,还是将该配置设置为true,但是设置之后无法直接重启

memory locking requested for elasticsearch process but memory is not locked

解决:Hellxz技术小筑的博客

  • 设置用户密码
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 要在Linux安装部署Elasticsearch和Kibana,您需要执行以下步骤: 1. 首先,您需要下载和安装Java运行时环境(JRE)或Java开发工具包(JDK)。 2. 接下来,您需要下载和安装Elasticsearch和Kibana的软件包。您可以从官方网站下载这些软件包。 3. 安装Elasticsearch和Kibana之前,您需要创建一个新的用户和组,以便这些应用程序可以在其自己的安全上下文中运行。 4. 然后,您需要编辑Elasticsearch和Kibana的配置文件,以便它们可以与您的系统和其他应用程序进行交互。 5. 最后,您需要启动Elasticsearch和Kibana,并确保它们正在运行,并且可以通过Web浏览器访问。 这些是在Linux安装部署Elasticsearch和Kibana的基本步骤。但是,具体的步骤可能会因您的Linux发行版和版本而有所不同。因此,建议您查看官方文档或参考其他可靠的资源,以确保正确地安装部署这些应用程序。 ### 回答2: Elasticsearch和Kibana是一对不可分割的开源软件,用于进行数据分析和可视化。在Linux安装部署这两个软件需要一些技巧和步骤,以下是一个基本的指南: 步骤1:安装JDK Elasticsearch和Kibana都需要Java JDK才能运行。安装OpenJDK 11,以Ubuntu为例可以通过以下命令进行安装: sudo apt update sudo apt install openjdk-11-jdk 步骤2:安装Elasticsearch安装Elasticsearch之前,请确保您的Linux系统有足够的RAM和硬盘空间。 下载最新版Elasticsearch到本地,使用以下命令: curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-linux-x86_64.tar.gz 解压下载的文件: tar -xvf elasticsearch-7.12.0-linux-x86_64.tar.gz 进入解压后的目录: cd elasticsearch-7.12.0/ 在终端中运行Elasticsearch,使用以下命令: ./bin/elasticsearch 默认情况下,Elasticsearch将在localhost:9200处运行。可以通过访问 http://localhost:9200/测试它是否运行正常。如果可以看到Elasticsearch的JSON响应,就表示它已经成功地安装和运行。 步骤3:安装Kibana 下载最新版Kibana到本地,使用以下命令: curl -L -O https://artifacts.elastic.co/downloads/kibana/kibana-7.12.0-linux-x86_64.tar.gz 解压下载的文件: tar -xvf kibana-7.12.0-linux-x86_64.tar.gz 进入解压后的目录: cd kibana-7.12.0-linux-x86_64/ 在终端中运行Kibana,使用以下命令: ./bin/kibana 默认情况下,Kibana将在localhost:5601处运行。可以通过访问 http://localhost:5601/ 测试是否运行正常。如果可以看到Kibana的登录页面,就表示它已经成功地安装和运行。 步骤4:配置Kibana 打开Kibana客户端,并在浏览器中访问 http://localhost:5601/app/kibana#/management/kibana/index_patterns 创建一个kibana上的索引模式,Elasticsearch中必须存在相应名称的索引名,刚才已经运行的Elasticsearch应该已经创建好了对应的索引名。 步骤5:配置ElasticsearchElasticsearch服务器上,打开elasticsearch.yml文件: nano /etc/elasticsearch/elasticsearch.yml 将以下内容添加到底部: # 在任何IP地址上启动 network.host: 0.0.0.0 保存并关闭文件。 步骤6:配置Kibana和Elasticsearch之间的安全连接 打开kibana.yml文件: nano /etc/kibana/kibana.yml 将以下内容添加到底部: # 目标Elasticsearch主机的URL elasticsearch.hosts: ["http://localhost:9200"] # 检查Elasticsearch证书 elasticsearch.ssl.certificateAuthorities: [ "/path/to/ca.pem" ] 保存并关闭文件。 重启Kibana和Elasticsearch服务器,使用以下命令: sudo service elasticsearch restart sudo service kibana restart 最后,访问 https://localhost:5601 测试是否能够安全地访问Kibana。 总之,在Linux根据以上步骤安装Elasticsearch和Kibana,并进行配置可以在收到数据或日志时提供一个功能强大的工具,帮助用户对数据进行深入的分析和可视化。 ### 回答3: 要安装部署Elasticsearch(ES)和Kibana(Kibana)在Linux上,可以遵循以下步骤: 1.首先,在Linux服务器上安装Java。要安装Java,请打开终端并输入以下命令: sudo apt install default-jre 2.使用wget命令从Elasticsearch官方网站下载最新版本的Elasticsearch。例如,要下载版本6.7.1,请在终端中输入以下命令: wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.7.1.tar.gz 3.命令执行后,您会在当前工作目录中看到一个名为elasticsearch-6.7.1.tar.gz 的文件。然后,您可以使用以下命令解压该文件: tar -zxvf elasticsearch-6.7.1.tar.gz 4.安装完成后,cd到解压的ELasticsearch目录并将config文件中的cluster.name和node.name设置为您的首选选项。 5.将Elasticsearch用作守护进程。要以守护进程模式运行Elasticsearch,请输入以下命令: ./bin/elasticsearch -d 6.接下来,您需要下载和安装Kibana。从Kibana官方网站下载最新版本的Kibana。例如,要下载版本6.7.1,请在终端中输入以下命令: wget https://artifacts.elastic.co/downloads/kibana/kibana-6.7.1-linux-x86_64.tar.gz 7.下载完成后,使用以下命令解压Kibana: tar -zxvf kibana-6.7.1-linux-x86_64.tar.gz 8.修改Kibana配置文件,将其设置为Elasticsearch连接。要这样做,请打开kibana.yml文件并找到以下行: #elasticsearch.hosts: ["http://localhost:9200"] 取消注释该行并将其设置为您的Elasticsearch主机和端口。 9.然后,您可以使用以下命令启动Kibana: ./bin/kibana 10.现在,您可以在浏览器中访问Kibana的Web界面。打开浏览器并导航到http://localhost:5601。 至此,您已经成功安装部署Elasticsearch和Kibana!现在,您可以使用Kibana界面来查看和分析Elasticsearch索引中的数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值