Elasticsearch安装部署在linux上

右边侧栏第二个是目录

1,把ES压缩包上传至服务器


在这里插入图片描述

=================================================

2,解压

#创建文件夹
	mkdir /usr/local/elasticsearch
# 上传到/usr/local/es目录下,执行解压命令
	tar -zxvf elasticsearch-7.8.0.tar.gz -C /usr/local/elasticsearch

==============================================

3,创建新用户

#
	sudo useradd es
#
	sudo passwd es

==============================================

4,修改用户权限

	chown -R es /usr/local/elast

=================================================

5,修改elasticsearch.yml配置文件

#编辑文件
vi usr/local/elast/elasticsearch-7.8.0/config/elasticsearch.yml
#设置参数
node.name: node-1
path.data: ./data #数据存放路径
path.log: ./log #日志存放路径
network.host: 0.0.0.0 #本机IP地址(设置可以访问的ip地址)
http.port: 9200 #es暴露对外的端口

==============================================

6,修改/etc/security/limits.conf配置文件


修改文件创建数量

#执行:
vi /etc/security/limits.conf
#在文件末尾插入
es soft nofile 65536
es hard nofile 65536

=======================================

7,修改/etc/security/limits.d/20-nproc.conf配置文件

设置文件的大小参数

#执行
vi /etc/security/limits.d/20-nproc.conf
#在文件末尾添加
es soft nofile 65536
es hard nofile 65536
*  hard nproc  4096   #注:* 带表 Linux 所有用户名称

==========================================

8,修改/etc/sysctl.conf配置文件


设置最大内存的分配

#执行
vi /etc/sysctl.conf
#在文件末尾添加
vm.max_map_count=655360
#保存并退出文档
:wq!
#再执行
sysctl -p 
#以上:将参数写到文件中并重新加载 这种方式可以永久保存参数修改/etc/sysctl.conf文件,然后sysctl -p 刷新到内存中。格式:sysctl -p [file] //如果没有指定file,则默认从/etc/sysctl中加载变量

========================================

9,启动

#跳转到bin目录下
cd /usr/local/elast/elasticsearch-7.8.0/bin
#执行
./elasticsearch -d #-d 后台执行程序

启动的时候,我报错了,我直接用网上的图吧。
在这里插入图片描述
修改办法:

#打开文件
	vi /usr/local/elast/elasticsearch-7.8.0/bin/elasticsearch-env

在这里插入图片描述
蓝框里是默认的,我把它注释掉了,意思是不让它使用本地JDK,直接用它自带的JDK。
ES自带的有JDK,和我本地安装的JDK8冲突了,默认会先去找本地的JDK,如果本地没有再使用自带的,但是我它和我本地的不匹配,所以报错了。我这里直接让它用ES自带的

=================================================

10,又重新启动,但是又报错了。


在这里插入图片描述
我上网查了查,说是生产环境需要配置一个默认节点(只是本机访问无所谓)
解决办法

#打开文件
	vi /usr/local/elast/elasticsearch-7.8.0/config/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
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.data: ./data  		 #数据存放路径
#
# Path to log files:	
#
#path.logs: /path/to/logs
path.logs: ./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
network.host: 0.0.0.0 #本机IP地址(设置可以访问的ip地址)
#
# Set a custom port for HTTP:
#
http.port: 9200      #es暴露对外的端口
#
# 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", "node-2"]
cluster.initial_master_nodes: ["node-1"] #本机的节点
#
# For more information, consult the discovery and cluster formation 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
http.cors.enabled: true       #跨域配置
http.cors.allow-origin: "*"   #跨域配置

=================================================

11,重新启动,又又出错了


es启动报错:OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed;

从报错内容上来看是Not enough space,是es默认配置的内存较大,而本机内存较小导致的

解决办法
打开文件

 vi  /usr/local/elast/elasticsearch-7.8.0/config/jvm.options

在这里插入图片描述
我把1g改为256m了。Xms初始堆大小,Xmx最大堆大小。内存够大你可以改为512m

=================================================

12,继续再启动一次,又又又失败了

启动报错 uncaught exception in thread [main]org.elasticsearch.bootstrap.Startup
查明ES可能已经起了两个进程,把进程kill掉之后重新启动就可以了。

 #通过命令关闭此进程。
 kill -9 进程号 
#重新启动进程es。
  ./bin/elasticsearch

或者

#重启服务器命令。我是直接重启服务器的
	reboot
#重新启动进程es。
  /usr/local/elast/elasticsearch-7.8.0/bin/elasticsearch -d

=================================================

13,启动成功!

#检查服务是否正常启动:
	netstat -anlp|grep 9200

在这里插入图片描述

#在服务器内部执行
 curl http://127.0.0.1:9200

在这里插入图片描述
说明已经成功了

=================================================

14,使用外网访问云服务器


这里需要打开防火墙,我用的是腾讯云服务器。我直接设置全部TCP
在这里插入图片描述
在这里插入图片描述
你要是觉得不安全可以只配两个端口,以下,我是改了,腾讯云官方发短信给我说受到来自美国的攻击…你打毛子,胡塞去啊,你攻击我干嘛!
在这里插入图片描述

参考文章:
https://blog.csdn.net/weixin_44838075/article/details/135130568

========================================================
配置规则后外网可以访问!
在这里插入图片描述
OK,结束。

==================================================

15,安装Kibana


后续安装Kibana简单记录一下
第一,把包倒到云服务器里面 …此处省略了,懒得写了。

第二,以下

#编辑
vi /usr/local/kibana/kibana-7.8.0/config/kibana.yml

改一下kibana.yml配置就行

# Kibana is served by a back end server. This setting specifies the port to use.
server.port: 5601

# Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values.
# The default is 'localhost', which usually means remote machines will not be able to connect.
# To allow connections from remote users, set this parameter to a non-loopback address.
#server.host: "localhost"
server.host: "0.0.0.0"

# Enables you to specify a path to mount Kibana at if you are running behind a proxy.
# Use the `server.rewriteBasePath` setting to tell Kibana if it should remove the basePath
# from requests it receives, and to prevent a deprecation warning at startup.
# This setting cannot end in a slash.
#server.basePath: ""

# Specifies whether Kibana should rewrite requests that are prefixed with
# `server.basePath` or require that they are rewritten by your reverse proxy.
# This setting was effectively always `false` before Kibana 6.3 and will
# default to `true` starting in Kibana 7.0.
#server.rewriteBasePath: false

# The maximum payload size in bytes for incoming server requests.
#server.maxPayloadBytes: 1048576

# The Kibana server's name.  This is used for display purposes.
#server.name: "your-hostname"

# The URLs of the Elasticsearch instances to use for all your queries.
#elasticsearch.hosts: ["http://localhost:9200"]
elasticsearch.hosts: ["http://0.0.0.0:9200"]

# When this setting's value is true Kibana uses the hostname specified in the server.host
# setting. When the value of this setting is false, Kibana uses the hostname of the host
# that connects to this Kibana instance.
#elasticsearch.preserveHost: true

# Kibana uses an index in Elasticsearch to store saved searches, visualizations and
# dashboards. Kibana creates a new index if the index doesn't already exist.
#kibana.index: ".kibana"
kibana.index: ".kibana"

# The default application to load.
#kibana.defaultAppId: "home"

# If your Elasticsearch is protected with basic authentication, these settings provide
# the username and password that the Kibana server uses to perform maintenance on the Kibana
# index at startup. Your Kibana users still need to authenticate with Elasticsearch, which
# is proxied through the Kibana server.
#elasticsearch.username: "kibana_system"
#elasticsearch.password: "pass"

# Enables SSL and paths to the PEM-format SSL certificate and SSL key files, respectively.
# These settings enable SSL for outgoing requests from the Kibana server to the browser.
#server.ssl.enabled: false
#server.ssl.certificate: /path/to/your/server.crt
#server.ssl.key: /path/to/your/server.key

# Optional settings that provide the paths to the PEM-format SSL certificate and key files.
# These files are used to verify the identity of Kibana to Elasticsearch and are required when
# xpack.security.http.ssl.client_authentication in Elasticsearch is set to required.
#elasticsearch.ssl.certificate: /path/to/your/client.crt
#elasticsearch.ssl.key: /path/to/your/client.key

# Optional setting that enables you to specify a path to the PEM file for the certificate
# authority for your Elasticsearch instance.
#elasticsearch.ssl.certificateAuthorities: [ "/path/to/your/CA.pem" ]

# To disregard the validity of SSL certificates, change this setting's value to 'none'.
#elasticsearch.ssl.verificationMode: full

# Time in milliseconds to wait for Elasticsearch to respond to pings. Defaults to the value of
# the elasticsearch.requestTimeout setting.
#elasticsearch.pingTimeout: 1500

# Time in milliseconds to wait for responses from the back end or Elasticsearch. This value
# must be a positive integer.
#elasticsearch.requestTimeout: 30000

# List of Kibana client-side headers to send to Elasticsearch. To send *no* client-side
# headers, set this value to [] (an empty list).
#elasticsearch.requestHeadersWhitelist: [ authorization ]

# Header names and values that are sent to Elasticsearch. Any custom headers cannot be overwritten
# by client-side headers, regardless of the elasticsearch.requestHeadersWhitelist configuration.
#elasticsearch.customHeaders: {}

# Time in milliseconds for Elasticsearch to wait for responses from shards. Set to 0 to disable.
#elasticsearch.shardTimeout: 30000

# Time in milliseconds to wait for Elasticsearch at Kibana startup before retrying.
#elasticsearch.startupTimeout: 5000

# Logs queries sent to Elasticsearch. Requires logging.verbose set to true.
#elasticsearch.logQueries: false

# Specifies the path where Kibana creates the process ID file.
#pid.file: /var/run/kibana.pid

# Enables you specify a file where Kibana stores log output.
#logging.dest: stdout

# Set the value of this setting to true to suppress all logging output.
#logging.silent: false

# Set the value of this setting to true to suppress all logging output other than error messages.
#logging.quiet: false

# Set the value of this setting to true to log all events, including system usage information
# and all requests.
#logging.verbose: false

# Set the interval in milliseconds to sample system and process performance
# metrics. Minimum is 100ms. Defaults to 5000.
#ops.interval: 5000

# Specifies locale to be used for all localizable strings, dates and number formats.
# Supported languages are the following: English - en , by default , Chinese - zh-CN .
#i18n.locale: "en"
#赋权限
# 在root下为es用户赋kibana权限
chown -R es /usr/local/kibana/kibana-7.8.0

使用es用户直接启动

#跳转
	cd /usr/local/kibana/kibana-7.8.0/bin
#执行
	./kibana

这个后面也报错了
错误:
Unable to connect to Elasticsearch. Error: Request Timeout after 30000ms
Unable to connect to Elasticsearch. Error: [master_not_discovered_exception] null

原因是因为elasticsearch.yml的配置未配置正确引起的
后面我又在elasticsearch.yml里加上。(上面第十步里面已经修改过了。)

node.name: node-1

处理问题参考文章
https://stackoverflow.com/questions/64080428/kibana-server-is-not-ready-yet-and-logs-shows-unable-to-connect-to-elasticsearc
后面就成功了
在这里插入图片描述
外网访问成功!
127.XXX.XX.XX:5601 输入你部署的服务器ip
在这里插入图片描述

安装kibana参考文章
https://blog.csdn.net/Bobdragery/article/details/106842984
https://blog.csdn.net/weixin_42109200/article/details/125402338
https://blog.csdn.net/m0_50287279/article/details/131819482
https://blog.csdn.net/weiguang102/article/details/117132190
https://blog.csdn.net/qq_33716026/article/details/122193301
https://blog.51cto.com/u_15585699/5179638#2Elasticsearch_46

网上ELK下载资源要么连不上外网,要么收费,恶心的一批,可以从这里直接免费下载

华为云的镜像网站-elasticsearch
https://repo.huaweicloud.com/elasticsearch/

华为云的镜像网站-kibana
https://repo.huaweicloud.com/kibana/

github-ik分词器
https://gitcode.com/medcl/elasticsearch-analysis-ik/releases?utm_source=csdn_github_accelerator&isLogin=1

  • 13
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 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、付费专栏及课程。

余额充值