Linux使用 RPM 安装 Elasticsearch
参考网站:https://www.elastic.co/guide/en/elasticsearch/reference/8.5/rpm.html#rpm-repo
1.导入Elasticsearch GPG签名密钥
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
2.创建软件源
cat > /etc/yum.repos.d/elasticsearch.repo << EOF [elasticsearch] name=Elasticsearch repository for 8.x packages baseurl=https://artifacts.elastic.co/packages/8.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=0 autorefresh=1 type=rpm-md EOF
3.安装
1.使用上面的软件源进行安装
yum install --enablerepo=elasticsearch elasticsearch
2.离线RPM包安装【离线环境】
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.5.2-x86_64.rpm rpm --install elasticsearch-8.5.2-x86_64.rpm
4.配置开机自启
systemctl daemon-reload
systemctl enable elasticsearch.service
5.查看运行是否正常
curl --cacert /etc/elasticsearch/certs/http_ca.crt -u elastic https://localhost:9200
安装过程提示:
Creating elasticsearch group... OK Creating elasticsearch user... OK 安装 : elasticsearch-8.5.2-1.x86_64 1/1 运行脚本: elasticsearch-8.5.2-1.x86_64 1/1 warning: ignoring JAVA_HOME=/usr/java/jdk8u352-b08; using bundled JDK warning: ignoring JAVA_HOME=/usr/java/jdk8u352-b08; using bundled JDK --------------------------- Security autoconfiguration information ------------------------------ Authentication and authorization are enabled. TLS for the transport and HTTP layers is enabled and configured. The generated password for the elastic built-in superuser is : 9sjk2gycpTPJugiUUHii If this node should join an existing cluster, you can reconfigure this with '/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here>' after creating an enrollment token on your existing cluster. You can complete the following actions at any time: Reset the password of the elastic built-in superuser with '/usr/share/elasticsearch/bin/elasticsearch-reset-password -u elastic'. Generate an enrollment token for Kibana instances with '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana'. Generate an enrollment token for Elasticsearch nodes with '/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node'. ------------------------------------------------------------------------------------------------- ### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd sudo systemctl daemon-reload sudo systemctl enable elasticsearch.service ### You can start elasticsearch service by executing sudo systemctl start elasticsearch.service warning: ignoring JAVA_HOME=/usr/java/jdk8u352-b08; using bundled JDK warning: ignoring JAVA_HOME=/usr/java/jdk8u352-b08; using bundled JDK [/usr/lib/tmpfiles.d/elasticsearch.conf:1] Line references path below legacy directory /var/run/, updating /var/run/elasticsearch → /run/elasticsearch; please update the tmpfiles.d/ drop-in file accordingly. 验证 : elasticsearch-8.5.2-1.x86_64 1/1 已安装: elasticsearch-8.5.2-1.x86_64
6.配置外网访问
vi /etc/elasticsearch/elasticsearch.yml
cluster.name: my-application node.name: node-1 path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: 127.0.0.1 http.host: 0.0.0.0 http.port: 9200 http.cors.enabled: true http.cors.allow-origin: "*" discovery.seed_hosts: ["127.0.0.1","[::1]"] cluster.initial_master_nodes: ["node-1"] #以前有的配置有则修改剩下的不要动
7.配置防火墙
firewall-cmd --zone=public --add-port=9300/tcp --permanent firewall-cmd --zone=public --add-port=9200/tcp --permanent systemctl restart firewalld.service
8.访问 https://ip:9200/【注意是https】
账号: elastic
密码:安装过程中提示的那个密码