Ubuntu 20.04 手动安装ElasticSearch 7.14

该教程将会教您手动安装elasticsearch最新版本

  1. 导入Elasticserach PGP Key

wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

  1. 安装APT依赖

sudo apt-get install apt-transport-https

  1. 增加Elasticsearch官方源
  • 使用该命令之前建议先备份源文件

echo “deb https://artifacts.elastic.co/packages/7.x/apt stable main” | sudo tee /etc/apt/sources.list.d/elastic-7.x.list

  1. 使用APT安装Elasticsearch

sudo apt-get update && sudo apt-get install elasticsearch

4.1 或者使用deb包安装(可选)

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-amd64.deb
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.14.1-amd64.deb.sha512
shasum -a 512 -c elasticsearch-7.14.1-amd64.deb.sha512 
sudo dpkg -i elasticsearch-7.14.1-amd64.deb
  1. 启动elasticsearch

sudo -i service elasticsearch start

  1. 增加elasticsearch自启

sudo /bin/systemctl enable elasticsearch.service

  1. 验证elasticsearch安装是否成功

curl localhost:9200

  1. 增加elasticsearch密码

curl localhost:9200/_nodes/reload_secure_settings -X POST -d “{ "secure_settings_password": "magenTOch!na-es-PWD" }” -H “Content-Type: application/json”

  • 该行命令是将elasticsearch的密码修改为 magenTOch!na-es-PWD
  • 请根据自身条件修改较为复杂的密码,如果您的9200端口是对公网开放
  1. 启动ElasticSearch的xpack
"Security must be explicitly enabled when using a [basic] license. Enable security by setting [xpack.security.enabled] to [true] in the elasticsearch.yml file and restart the node."

如果未启用xpack某些kibana功能会不正常,解决办法是按照报错编辑 elasticsearch.yml 文件。
直接在该文件最后一行输入:

xpack.security.enabled: true

然后重启elasticsearch:

service elasticsearch restart