ElasticSearch记录
安装
ElasticSearch 安装&运行
-
下载
- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.3-windows-x86_64.zip
- https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.15.3-linux-x86_64.tar.gz
- https://artifacts.elastic.co/downloads/kibana/kibana-8.15.3-windows-x86_64.zip
- https://artifacts.elastic.co/downloads/kibana/kibana-8.15.3-linux-x86_64.tar.gz
-
linux下必须使用非root用户运行
adduser elastic passwd elastic su elastic # 修改目录拥有者 -R 遍历子目录 chown -R [/opt/elasticsearch] elastic # 修改配置文件,支持http访问 vi /opt/elasticsearch/config/elasticsearch.yml # xpack.security.enabled: false # http.cors.enabled: true # http.cors.allow-origin: "*" # http.cors.allow-headers: "*" # 安全访问 # xpack.security.enabled: true # xpack.security.enrollment.enabled: true
-
服务方式运行,配置
/etc/systemd/system/elasticsearch.service
[Unit] Description=Elasticsearch Documentation=https://www.elastic.co Wants=network-online.target After=network-online.target [Service] Type=notify RuntimeDirectory=elasticsearch PrivateTmp=true Environment=ES_HOME=/usr/share/elasticsearch Environment=ES_PATH_CONF=/etc/elasticsearch Environment=PID_DIR=/var/run/elasticsearch Environment=ES_SD_NOTIFY=true EnvironmentFile=-/etc/sysconfig/elasticsearch WorkingDirectory=/usr/share/elasticsearch User=elasticsearch Group=elasticsearch ExecStart=/usr/share/elasticsearch/bin/systemd-entrypoint -p ${PID_DIR}/elasticsearch.pid --quiet # StandardOutput is configured to redirect to journalctl since # some error messages may be logged in standard output before # elasticsearch logging system is initialized. Elasticsearch # stores its logs in /var/log/elasticsearch and does not use # journalctl by default. If you also want to enable journalctl # logging, you can simply remove the "quiet" option from ExecStart. StandardOutput=journal StandardError=inherit # Specifies the maximum file descriptor number that can be opened by this process LimitNOFILE=65535 # Specifies the maximum number of processes LimitNPROC=4096 # Specifies the maximum size of virtual memory LimitAS=infinity # Specifies the maximum file size LimitFSIZE=infinity # Disable timeout logic and wait until process is stopped TimeoutStopSec=0 # SIGTERM signal is used to stop the Java process KillSignal=SIGTERM # Send the signal only to the JVM rather than its control group KillMode=process # Java process is never killed SendSIGKILL=no # When a JVM receives a SIGTERM signal it exits with code 143 SuccessExitStatus=143 # Allow a slow startup before the systemd notifier module kicks in to extend the timeout TimeoutStartSec=900 [Install] WantedBy=multi-user.target # Built for packages-7.17.25 (packages)
-
启动运行服务:
systemctl enable elasticsearch systemctl start elasticsearch
-
修改kibana配置:
# 修改地址为0.0.0.0 server.host: "0.0.0.0" # 修改语言 i18n.locale: "zh-CN"