Teng's blog Teng's blog
首页
Java
H5前端
GitHub (opens new window)
首页
Java
H5前端
GitHub (opens new window)
  • 认知

  • 入门

  • 环境

    • 概念
    • windows集群
    • linux单机
      • 安装
      • 启动
      • 测试
    • linux集群
  • 进阶

  • 框架集成

  • 优化

  • 面试题

  • Database-Elasticsearch
  • 环境
Shetengteng
2022-01-29

linux单机

# 安装

下载

下载Linux版的Elasticsearch (opens new window)

解压软件

# 解压缩
tar -zxvf elasticsearch-7.8.0-linux-x86_64.tar.gz -C /opt/module
# 改名
mv elasticsearch-7.8.0 es
1
2
3
4

创建用户,因为安全问题, Elasticsearch 不允许 root 用户直接运行,所以要创建新用户,在 root 用户中创建新用户

useradd es #新增 es 用户
passwd es #为 es 用户设置密码
userdel -r es #如果错了,可以删除再加
chown -R es:es /opt/module/es #文件夹所有者
1
2
3
4

修改/opt/module/es/config/elasticsearch.yml文件

# 加入如下配置
cluster.name: elasticsearch
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["node-1"]
1
2
3
4
5
6

修改/etc/security/limits.conf

# 在文件末尾中增加下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
1
2
3
4

修改/etc/security/limits.d/20-nproc.conf

# 在文件末尾中增加下面内容
# 每个进程可以打开的文件数的限制
es soft nofile 65536
es hard nofile 65536
# 操作系统级别对每个用户创建的进程数的限制
* hard nproc 4096
# 注: * 带表 Linux 所有用户名称
1
2
3
4
5
6
7

修改/etc/sysctl.conf

# 在文件中增加下面内容
# 一个进程可以拥有的 VMA(虚拟内存区域)的数量,默认值为 65536
vm.max_map_count=655360
1
2
3

重新加载

sysctl -p
1

# 启动

使用 ES 用户启动

cd /opt/module/es/
#启动
bin/elasticsearch
#后台启动
bin/elasticsearch -d
1
2
3
4
5

启动时,会动态生成文件,如果文件所属用户不匹配,会发生错误,需要重新进行修改用户和用户组

关闭防火墙

#暂时关闭防火墙
systemctl stop firewalld
#永久关闭防火墙
systemctl enable firewalld.service #打开放货抢永久性生效,重启后不会复原
systemctl disable firewalld.service #关闭防火墙,永久性生效,重启后不会复原
1
2
3
4
5

# 测试

浏览器中输入地址: http://ip:9200/

  • ip是访问虚拟机使用的地址
Last Updated: 2022/02/05, 15:58:51
windows集群
linux集群

← windows集群 linux集群→

Theme by Vdoing | Copyright © 2021-2022 Shetengteng | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式