前瞻
记录一下elasticsearch
centos8.2下的安装,同时配置ik
分词,本文安装如下:
名称 | 版本 |
---|---|
elasticsearch | 8.8.1 官网下载 |
ikanalysis-ik | 8.8.1 github下载 |
解压
#解压elasticsearch
$ tar -zxvf elasticsearch-8.8.1-linux-x86_64.tar.gz
#解压ikanalysis-ik到es的plugins下
$ unzip elasticsearch-analysis-ik-8.8.1.zip -d ./elasticsearch-8.8.1/plugins/ik/
# 将elasticsearch移动到usr/local目录下,个人习惯问题,可以不移动
$ mv elasticsearch-8.8.1 /usr/local
添加es用户和分组
## 添加分组
$ groupadd es
## 添加用户并指定分组
$ useradd -G es es
将目录权限给到es
$ chown es:es -R /usr/local/elasticsearch-8.8.1
修改配置文件
直接在线面添加即可,注意日志和数据文件的权限
vim /usr/local/elasticsearch-8.8.1/config/elasticsearch.yml
#集群名称
cluster.name: elasticsearch
#数据存放路径
path.data: /data/elasticsearch
#日志存放路径
path.logs: /data/logs/elasticsearch
node.name: node-1
#本机IP地址(设置可以访问的ip地址)
network.host: 0.0.0.0
#es暴露对外的端口
http.port: 9200
#节点名称
cluster.initial_master_nodes: ["node-1"]
启动es
尽量先通过同步启动,成功后终止在执行后台执行或开启守护进程
# 同步
$ /usr/local/elasticsearch-8.8.1/bin/elasticsearch
# 后台执行
$ /usr/local/elasticsearch-8.8.1/bin/elasticsearch -d
守护进程移步:elasticsearch守护进程&开机自启
启动成功后要看一下token和密码
Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):<==重置的命令
NVw-5asbbjA
ℹ️ HTTP CA certificate SHA-256 fingerprint:
405423cd5a4f72cf9875644bd79
ℹ️ Configure Kibana to use this cluster:(配置Kibana以使用此集群)
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
YzZWFkOTVkNzkiLCJrZXkiOiJCSzc2UEpJQjM2MlJkMndnRjhOQjozM19DalVrYVFJRzJaSXVDVHJvTElnIn0= <==kibana的token
ℹ️ Configure other nodes to join this cluster:(配置其他节点以加入此群集)
• Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes):<==重置的命令,可以加入集群
eyJ2ZXIiOiI4LjguMSIsImFkciI6WyIxOTIu
If you're running in Docker, copy the enrollment token and run:
`docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.8.1`
问题
-
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
原因:vm.max_map_count 参数设置的值太低了。这个参数定义了一个进程可以拥有的最大虚拟内存区域数量
解决:
$ vim /etc/sysctl.conf
#添加`vm.max_map_count=262144`后保存
#执行生效
$ sysctl -p
修改密码
#重置密码
$ bin/elasticsearch-reset-password -u elastic
#修改密码
$ bin/elasticsearch-reset-password -u elastic -i