elasticsearch-7.17.16阿里云部署

1、上传包到服务器

将下载好的 elasticsearch-7.17.16-linux-x86_64.tar.gz 文件放到 /usr/local/soft 目录下

bash 复制代码
tar -zxvf elasticsearch-7.17.16-linux-x86_64.tar.gz		# 解压

配置环境变量:

bash 复制代码
vim /etc/profile

# 如果/etc/bashrc文件不可编辑,需要修改为可编辑
chmod -v u+w /etc/environment

# 在最后一行加上
export ES_JAVA_HOME=/usr/local/soft/elasticsearch-7.17.16/jdk

source /etc/environment

注意事项:

  • 生效时间:新开终端生效,或者手动 source /etc/environment 生效

  • 生效期限:永久有效

  • 生效范围:对所有用户有效

2、修改主配置文件 elasticsearch.yml

bash 复制代码
cd /usr/local/soft/elasticsearch-7.17.16

vim config/elasticsearch.yml

# ES开启远程访问
network.host: 0.0.0.0

# 设置主节点(一个集群设一个就行)
node.master: true

# 配置发现设置
discovery.seed_hosts: ["127.0.0.1"]		# "127.0.0.1"可以改为外网ip
cluster.initial_master_nodes: ["node-1"]

# 跨域问题
http.cors.enabled: true
http.cors.allow-origin: "*"

# 允许请求头携带密码访问
http.cors.allow-headers: Authorization

# 开启密码访问
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true

为了方便直接复制下面这一块

bash 复制代码
network.host: 0.0.0.0
node.name: "node-1"
node.master: true
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: false
discovery.type: single-node

3、修改JVM配置:

修改config/jvm.options配置文件,调整JVM堆内存大小

bash 复制代码
vim config/jvm.options
-Xms1g
-Xmx1g
  • 注意:

启动 elasticsearch 不能使用 root 用户,所以先创建普通用户

bash 复制代码
sudo useradd -m -s /bin/bash username	# 创建

sudo passwd username	# 设置密码

sudo usermod -aG root username	# 添加该用户到管理员组

# 切换到root用户
chmod -R g+rwx /usr/local/soft/elasticsearch-7.17.16	# 赋予组对该目录及其子目录的读写权

4、启动(切换到创建的用户上启动):

bash 复制代码
# 在/usr/local/soft/elasticsearch-7.17.16目录下
bin/elasticsearch

# 后台启动
bin/elasticsearch -d

常见启动报错:

max virtual memory areas vm.max_map_count 65530 is too low, increase to at least 262144

bash 复制代码
# 编辑/etc/sysctl.conf文件,在最后添加一行
vim /etc/sysctl.conf
vm.max_map_count=262144

# 重启
sudo sysctl -p

设置密码:

执行设置用户名和密码的命令,这里需要为4个用户分别设置密码,elastic, kibana, logstash_system, beats_system

bash 复制代码
bin/elasticsearch-setup-passwords interactive 
bash 复制代码
[xunlu@xunlu-20231103 elasticsearch]$ bin/elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y
Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

4、分词插件安装

将zip压缩包上传到 plugins 目录

bash 复制代码
unzip elasticsearch-analysis-ik-7.17.16.zip -d analysis-ik		# 解压

rm elasticsearch-analysis-ik-7.17.16.zip		# 删除压缩包

测试分词:

bash 复制代码
GET _analyze
{
	"analyzer": "ik_max_word",
	"text": "原神生日会"
}
相关推荐
王码码20357 小时前
多台服务器怎么统一看状态?Beszel 轻量监控,搭起来不费事
运维·服务器·后端·安全·阿里云·接口·web
Mixtral7 小时前
职场录音转写工具投入产出比实测:随身鹿、通义听悟、阿里云与Trint该怎么选?
阿里云·云计算
INFINI Labs11 小时前
Elasticsearch 6/7/8 到 Easysearch 2.x 迁移指南
大数据·elasticsearch·mybatis·向量·snapshot
_codemonster11 小时前
Git 最常用操作和原理
大数据·git·elasticsearch
阿里云大数据AI技术11 小时前
Agentic Search + Memory:当企业研究遇上"会思考的搜索"
人工智能·elasticsearch
普通网友12 小时前
springboot之集成Elasticsearch
spring boot·后端·elasticsearch
Linlingu13 小时前
OpenClaw接入阿里云百炼模型配置教程(完整可落地)
人工智能·阿里云·云计算·办公自动化·数字员工·小龙虾
x_lrong21 小时前
Ubuntu下安装配置Claude Code
linux·ubuntu·elasticsearch
Geoffwo1 天前
Elasticsearch+IK+Kibana安装手册
大数据·elasticsearch·搜索引擎
Database_Cool_2 天前
AnalyticDB MySQL vs StarRocks/ByteHouse:云数仓选型指南——全托管 vs 自建方案
数据库·数据仓库·mysql·阿里云