Ubuntu 23.04 安装es

在Ubuntu 23.04上安装Elasticsearch的过程可能与之前版本类似,以下是基于最新稳定版Elasticsearch的一般安装步骤:

  1. 准备工作:

    • 确保系统已更新至最新版本:

      bash 复制代码
      sudo apt update && sudo apt upgrade
    • 安装Java Development Kit (JDK)。Elasticsearch至少需要Java 11。可以通过官方apt仓库安装Adoptium OpenJDK(或者其他你喜欢的Java版本):

      bash 复制代码
      sudo apt install openjdk-11-jdk-headless
  2. 下载并解压Elasticsearch:

    访问Elasticsearch官方网站(https://www.elastic.co/cn/downloads/past-releases#elasticsearch)下载适合Ubuntu的tar.gz包。假设你下载了名为`elasticsearch-8.12.0.tar.gz`的压缩包,将其解压到适当的目录,例如 /usr/local

    bash 复制代码
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.12.0-linux-x86_64.tar.gz
    sudo mkdir -p /usr/local/elasticsearch
    sudo tar -xzvf elasticsearch-8.12.0-linux-x86_64.tar.gz -C /usr/local/elasticsearch --strip-components=1
  3. 创建Elasticsearch系统用户和组:

    bash 复制代码
    sudo groupadd elastic
    sudo useradd -r -g elastic -s /bin/bash elastic
    sudo chown -R elastic:elastic /usr/local/elasticsearch
  4. 配置Elasticsearch:

    • 编辑 /usr/local/elasticsearch/config/elasticsearch.yml 文件,根据您的环境调整配置。关键配置可能包括:
bash 复制代码
cluster.name: my-application
node.name: node-1
network.host: 0.0.0.0
xpack.security.enabled: false
path.data: /usr/local/elasticsearch/data
path.logs: /usr/local/elasticsearch/logs

xpack.security.enrollment.enabled: false
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12
xpack.security.transport.ssl:
  enabled: false
  verification_mode: certificate
  keystore.path: certs/transport.p12
  truststore.path: certs/transport.p12
复制代码
 - `cluster.name`: 设置集群名称。
 - `node.name`: 设置节点名称。
 - `network.host`: 指定节点监听的主机地址(如 `localhost` 或特定IP)。
 - `path.data`: 数据存储路径。
 - `path.logs`: 日志文件存放路径。
 - 可能需要开启或配置安全功能(如X-Pack Security)。

编辑配置文件 /etc/security/limits.conf 或者在目录 /etc/security/limits.d/ 创建配置文件 (e.g., /etc/security/limits.d/elasticsearch.conf) 添加正面的内容

bash 复制代码
elasticsearch soft nofile 65536
elasticsearch hard nofile 65536

执行以下命令

bash 复制代码
sudo systemctl daemon-reload

在目录 /etc/sysctl.d/创建文件/etc/sysctl.d/elasticsearch.conf,添加以下内容:

bash 复制代码
vm.max_map_count=262144

执行以下命令

bash 复制代码
sudo sysctl --system
  1. 启动Elasticsearch:

    bash 复制代码
    sudo su elastic
    cd /usr/local/elasticsearch
    ./bin/elasticsearch

    如果你希望以守护进程方式运行Elasticsearch并设置为开机启动,你需要创建一个systemd服务单元文件,例如 /etc/systemd/system/elasticsearch.service,并定义正确的启动参数。

  2. 创建systemd服务(可选):

    创建一个elasticsearch.service文件,并添加相应的启动脚本。以下是一个基本示例:

    ini 复制代码
    [Unit]
    Description=Elasticsearch Service
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    Type=notify
    User=elastic
    Group=elastic
    ExecStart=/usr/local/elasticsearch/bin/elasticsearch
    Restart=on-failure
    LimitMEMLOCK=infinity
    LimitNOFILE=65536
    
    [Install]
    WantedBy=multi-user.target

    然后启用并启动服务:

    bash 复制代码
    sudo systemctl daemon-reload
    sudo systemctl enable elasticsearch.service
    sudo systemctl start elasticsearch.service

在生产环境中,还应考虑对Elasticsearch进行安全配置,例如设置密码认证、禁用HTTP访问等。

相关推荐
神筆&『馬良』1 小时前
Foundation_pose在自己的物体上复现指南:实现任意物体6D位姿检测(利用realsense_D435i和iphone_16pro手机)
目标检测·ubuntu·机器人·视觉检测
闲人编程2 小时前
Elasticsearch搜索引擎集成指南
python·elasticsearch·搜索引擎·jenkins·索引·副本·分片
先跑起来再说2 小时前
Git 入门到实战:一篇搞懂安装、命令、远程仓库与 IDEA 集成
ide·git·后端·elasticsearch·golang·intellij-idea
liuniu08182 小时前
VMware虚拟机安装ubuntu2022
ubuntu·ros
Dxy12393102163 小时前
深度解析 Elasticsearch:从倒排索引到 DSL 查询的实战突围
大数据·elasticsearch·搜索引擎
xfddlm3 小时前
边缘计算_ubuntu环境下使用瑞芯微RK3576NPU推理LLM
人工智能·ubuntu·边缘计算
EHagSJVNpTY4 小时前
MATLAB 中基于最大重叠离散小波变换的心电信号处理探索
ubuntu
.小墨迹5 小时前
apollo学习之借道超车的速度规划
linux·c++·学习·算法·ubuntu
技术路上的探险家5 小时前
Ubuntu下Docker与NVIDIA Container Toolkit完整安装教程(含国内源适配)
linux·ubuntu·docker
Dxy12393102166 小时前
别再让 ES 把你拖垮!5 个实战技巧让搜索性能提升 10 倍
大数据·elasticsearch·搜索引擎