关于后端:记录在linux上单机elasticsearch8和kibana8

5次阅读

共计 4157 个字符,预计需要花费 11 分钟才能阅读完成。

1、背景

此处简略记录一下,elasticsearch8kibana8Centos7下的单机装置步骤。

2、es 对 jdk 和操作系统的要求等

不同版本的 esjdk 操作系统 的要求不等,咱们抉择适合的版本,能够通过如下 https://www.elastic.co/cn/support/matrix#matrix_kubernetes 进行确认。

3、装置步骤

3.1 下载对应版本的 es

下载地址:https://www.elastic.co/cn/downloads/elasticsearch

3.2 创立 es 账户

须要为 es 独自创立一个用户,应用 root 账户启动 es 会报错。

[[email protected] ~]# useradd es
[[email protected] ~]# passwd es
[[email protected] es]# tar -zxf elasticsearch-8.4.3-linux-aarch64.tar.gz
[[email protected] es]# chown es -R elasticsearch-8.4.3
[[email protected] es]# su - es
Last login: Sun Oct 30 11:13:55 CST 2022 from 192.168.121.1 on pts/1
[[email protected] ~]$ cd /usr/local/es/elasticsearch-8.4.3
[[email protected] elasticsearch-8.4.3]$ mkdir datas
[[email protected] elasticsearch-8.4.3]$

3.3 批改 es 配置

3.3.1 批改 es 配置

vim config/elasticsearch.yml

# 集群名
cluster.name: es-cluster
# 节点名
node.name: es-node01
# 数据目录
path.data: /usr/local/es/elasticsearch-8.4.3/datas
# 日志目录
path.logs: /usr/local/es/elasticsearch-8.4.3/logs
# es 绑定到的地址
network.host: 192.168.121.138
# es 启动后前端拜访的端口
http.port: 9200

http.cors.enabled: true
http.cors.allow-origin: "*"

3.3.3 批改 jvm 配置

vim config/jvm.options

能够依据理论状况 批改一下 -Xms 和 -Xmx 等参数

3.4 批改系统配置

3.4.1 批改用户关上的文件数限度

  1. 通过 ulimit -n 查看以后用户可关上的文件数
  2. 批改用户可关上的文件数限度

vim /etc/security/limits.conf

es               soft    nofile          65536
es               hard    nofile          65536

参考链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#ulimit

3.4.2 禁用 swap

/etc/fstab
正文掉所有行中存在 swap 的行。

# /dev/mapper/cl_fedora-swap none      swap    defaults        0 0

参考链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration-memory.html

3.4.3 批改虚拟内存

vim /etc/sysctl.conf

在此文件的最初一行减少 vm.max_map_count=262144

参考链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html

3.4.4 进步线程数

vim /etc/security/limits.conf

es               soft     nproc          65536
es               hard    nproc          65536

参考文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/max-number-of-threads.html

以上配置配置完之后,重启一下零碎,使系统配置失效。

3.5 放开 9200 端口

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload

4、启动 es

须要应用非 root 账户启动。

bin/elasticsearch 前台启动
bin/elasticsearch -d 后盾启动

5、重置 elastic 账户明码

[[email protected] elasticsearch-8.4.3]$ bin/elasticsearch-reset-password --username elastic -i
warning: ignoring JAVA_HOME=/usr/local/jdk8; using bundled JDK
WARNING: Group of file [/usr/local/es/elasticsearch-8.4.3/config/users] used to be [root], but now is [es]
WARNING: Group of file [/usr/local/es/elasticsearch-8.4.3/config/users_roles] used to be [root], but now is [es]
This tool will reset the password of the [elastic] user.
You will be prompted to enter the password.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]:
Re-enter password for [elastic]:
Password for the [elastic] user successfully reset.
[[email protected] elasticsearch-8.4.3]$

6、拜访 es

呈现如下信息,阐明拜访胜利。


  "name": "es-node01",
  "cluster_name": "es-cluster",
  "cluster_uuid": "OJsQ_w1ZTKWepM-u8-U-tg",
  "version": {
    "number": "8.4.3",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "42f05b9372a9a4a470db3b52817899b99a76ee73",
    "build_date": "2022-10-04T07:17:24.662462378Z",
    "build_snapshot": false,
    "lucene_version": "9.3.0",
    "minimum_wire_compatibility_version": "7.17.0",
    "minimum_index_compatibility_version": "7.0.0"
  },
  "tagline": "You Know, for Search"
}

7、kibana 连贯到 es

7.1 批改 kibana 配置

vim /usr/local/kibana/kibana-8.4.3/config/kibana.yml

server.port: 5601
server.host: "192.168.121.138"
# elasticsearch.hosts: ["https://192.168.121.138:9200"] 和 es 用户民明码都不必配置

留神:
如果上方的配置中减少了 如下配置 (elasticsearch.usernameelasticsearch.password) 或者 elasticsearch.hosts) 则可能呈现如下异样

`[2022-10-30T18:31:29.858+08:00][ERROR][elasticsearch-service] Unable to retrieve version information from Elasticsearch nodes. self signed certificate in certificate chain`

解决方案:
执行如下命令

bin/kibana-setup --enrollment-token <enrollment-token>

<enrollment-token>通过如下命令获取:bin/elasticsearch-create-enrollment-token --scope kibana

参考链接:https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-stack-security.html#stack-start-with-security

7.2 启动 kibana

bin/kibana

从上图中能够 拜访地址为 http://192.168.121.138:5601/?code=634917

7.3 配置 kibana

点击蓝色的按钮,就开始配置 elastic 了。

8、参考链接

  1. https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
  2. https://www.elastic.co/guide/en/elasticsearch/reference/current/system-config.html
  3. https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-stack-security.html#stack-start-with-security
正文完
 0