---
title: 编译和安装
description: "1. 下载Elasticsearch 8.10.1版本。"
url: https://www.hikunpeng.com/document/detail/zh/SRA/ecosystemEnable/elasticsearch/kunpeng_elasticsearch_02_0005.html
sourcePath: /source/zh/SRA/ecosystemEnable/elasticsearch/kunpeng_elasticsearch_02_0005.html
indexId: 61fb4c344da18b706e77a1ee1e1e958c088a35a86052f4cf758e2aaf1d984d0579
---
# 编译和安装

1. 下载Elasticsearch 8.10.1版本。

```
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.10.1-linux-aarch64.tar.gz --no-check-certificate
```


2. 将安装包上传到服务器，并解压。假设代码存放于“/path/to/”。

```
tar -zxvf elasticsearch-8.10.1-linux-aarch64.tar.gz
```


3. 修改elasticsearch.yml配置文件。

  a. 进入配置文件的目录，打开elasticsearch.yml配置文件。

```
cd /path/to/elasticsearch-8.10.1/config
vim elasticsearch.yml
```


  b. 按“i”进入编辑模式，添加以下配置信息。

```
cluster.initial_master_nodes: ["localhost"]
node.name: localhost
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
discovery.seed_hosts: ["localhost"]
xpack.security.enabled: false
xpack.security.enrollment.enabled: false
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/elastic-certificates.p12
truststore.path: certs/elastic-certificates.p12
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
4. 配置SSL证书。

  a. 进入Elasticsearch安装目录。

```
cd /path/to/elasticsearch-8.10.1
```


  b. 执行以下命令。

```
./bin/elasticsearch-certutil http
```


  c. 按照下述指导进行配置。

```
Generate a CSR 选择 N
Use an existing CA 选择 N
Do you wish to change any of these options 选择 N
For how long should your certificate be valid 填 5Y
Generate a certificate per node 选择 N
Enter all the hostnames that you need, one per line 填入具体的服务器IP地址
IP地址填入具体的服务器IP地址
不需要配置CA密码，直接按回车
```


  d. 创建certs文件夹。

```
mkdir /path/to/elasticsearch-8.10.1/config/certs
```


  e. 配置证书可得到elasticsearch-ssl-http.zip压缩包，解压后，在“elasticsearch”文件夹中得到http.p12证书，将证书复制到“/path/to/elasticsearch-8.10.1/config/certs”文件夹中。

```
unzip elasticsearch-ssl-http.zip
cp ./elasticsearch/http.p12 /path/to/elasticsearch-8.10.1/config/certs
```


5. 开启认证xpack.security.transport.ssl。

  a. 进入Elasticsearch安装目录下的“bin”目录。

```
cd /path/to/elasticsearch-8.10.1/bin
```


  b. 执行以下命令。

```
echo 'export PATH=/path/to/elasticsearch-8.10.1/bin:$PATH' >>
~
/.bashrc
source
~
/.bashrc
elasticsearch-certutil ca
elasticsearch-certutil cert --ca elastic-stack-ca.p12
```


    在出现“Please enter the desired output file [elastic-certificates.p12]:”后面输入下面的路径。

```
/path/to/elasticsearch-8.10.1/config/certs/elastic-certificates.p12
```


6. 修改limits.conf配置。

  a. 打开limits.conf配置文件。

```
vim /etc/security/limits.conf
```


  b. 按“i”进入编辑模式，添加以下四行配置。

```
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 65536
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
7. 修改sysctl.conf配置。

  a. 打开sysctl.conf配置文件。

```
vim /etc/sysctl.conf
```


  b. 按“i”进入编辑模式，添加以下配置。

```
vm.max_map_count=655360
```


  c. 按“Esc”键，输入:wq!，按“Enter”保存并退出编辑。
  d. 执行以下命令。

```
sysctl -p
```
