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访问等。

相关推荐
Elasticsearch2 天前
如何使用 Agent Builder 排查 Kubernetes Pod 重启和 OOMKilled 事件
elasticsearch
Elasticsearch3 天前
通用表达式语言 ( CEL ): CEL 输入如何改进 Elastic Agent 集成中的数据收集
elasticsearch
欧云服务器5 天前
怎么让脚本命令可以同时在centos、debian、ubuntu执行?
ubuntu·centos·debian
智渊AI5 天前
Ubuntu 20.04/22.04 下通过 NVM 安装 Node.js 22(LTS 稳定版)
ubuntu·node.js·vim
海兰5 天前
离线合同结构化提取与检索:LangExtract + 本地DeepSeek + Elasticsearch 9.x
大数据·elasticsearch·django
yumgpkpm5 天前
AI视频生成:Wan 2.2(阿里通义万相)在华为昇腾下的部署?
人工智能·hadoop·elasticsearch·zookeeper·flink·kafka·cloudera
The️5 天前
Linux驱动开发之Read_Write函数
linux·运维·服务器·驱动开发·ubuntu·交互
再战300年5 天前
Samba在ubuntu上安装部署
linux·运维·ubuntu
qwfys2005 天前
How to install golang 1.26.0 to Ubuntu 24.04
ubuntu·golang·install