右边侧栏第二个是目录
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