安装JAVA SDK
sudo apt-get update
sudo apt-get install default-jdk
设置JAVA_HOME
环境变量
sudo vim /etc/environment
添加以下内容
JAVA_HOME="/usr/lib/jvm/[YOUR_JAVA_VERSION]"
刷新配置
source /etc/environment
官网下载deb包,建议用迅雷下载: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-amd64.deb
使用以下命令安装
sudo dpkg -i elasticsearch-7.6.2-amd64.deb
配置Elasticsearch
sudo vim /etc/elasticsearch/elasticsearch.yml
修改配置文件
cluster.name: YOUR_CLUSTER_NAME
node.name: YOUR_NODE_NAME
network.host: 0.0.0.0
http.port: 9200
cluster.initial_master_nodes: ["YOUR_NODE_NAME"]
配置服务自动启动
sudo systemctl enable elasticsearch.service
启动停止服务
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service
测试是否运行
curl -X GET "http://localhost:9200/?pretty"
官网下载deb包:https://artifacts.elastic.co/downloads/kibana/kibana-oss-7.6.2-amd64.deb
使用以下命令安装
sudo dpkg -i kibana-oss-7.6.2-amd64.deb
配置Elasticsearch
sudo vim /etc/kibana/kibana.yml
修改配置文件
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]
配置服务自动启动
sudo systemctl enable kibana.service
启动停止服务
sudo systemctl start kibana.service
sudo systemctl stop kibana.service
测试是否运行:http://localhost:5601
修改配置文件
server.basePath: "/kibana"
配置nginx代理
server {
listen 80;
listen [::]:80;
server_name _;
location /kibana/ {
auth_basic "authorization";
auth_basic_user_file /your/password/file;
rewrite ^/kibana/(.*)$ /$1 break;
proxy_pass http://localhost:5601/;
}
}
生成密码文件
openssl passwd -apr1 this-is-your-password
1.Elasticsearch启动失败,错误提示如下
Sep 25 20:40:56 elasticsearch systemd[1]: elasticsearch.service: Start operation timed out. Terminating.
Sep 25 20:40:57 elasticsearch systemd[1]: elasticsearch.service: Failed with result 'timeout'.
Sep 25 20:40:57 elasticsearch systemd[1]: Failed to start Elasticsearch.
修改启动超时时间
TimeoutStartSec=500
2.创建文档时报以下错误:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [logging] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"}],"type":"cluster_block_exception","reason":"index [logging] blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"},"status":403}
检查磁盘空间是否已满,清理空间