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

相关推荐
生活很暖很治愈7 分钟前
Linux——孤儿进程&进程调度&大O(1)调度
linux·服务器·ubuntu
Dxy123931021622 分钟前
Elasticsearch 索引与映射:为你的数据打造一个“智能仓库”
大数据·elasticsearch·搜索引擎
getapi2 小时前
注塑件的费用构成
linux·服务器·ubuntu
lucky-billy3 小时前
Ubuntu 下一键部署 ROS2
linux·ubuntu·ros2
阿梦Anmory4 小时前
Ubuntu配置代理最详细教程
linux·运维·ubuntu
getapi5 小时前
Ubuntu 22.04 服务器的系统架构是否为 amd64 x86_64
linux·服务器·ubuntu
小天源5 小时前
Cacti在Debian/Ubuntu中安装及其使用
运维·ubuntu·debian·cacti
倒流时光三十年5 小时前
SpringBoot 数据库同步 Elasticsearch 性能优化
数据库·spring boot·elasticsearch
人间打气筒(Ada)6 小时前
jenkins基于Pipeline发布项目
java·pipeline·jenkins·流水线·ci·cd·cicd
星辰_mya7 小时前
Elasticsearch更新了分词器之后
大数据·elasticsearch·搜索引擎