avatar
童琦杰
向死而生
githubmusic
2019-10-13编辑

Ubuntu下安装Elasticsearch

JAVA安装

安装JAVA SDK

bash
sudo apt-get update
sudo apt-get install default-jdk

设置JAVA_HOME环境变量

bash
sudo vim /etc/environment

添加以下内容

/etc/environment
JAVA_HOME="/usr/lib/jvm/[YOUR_JAVA_VERSION]"

刷新配置

bash
source /etc/environment

Elasticsearch安装

官网下载deb包,建议用迅雷下载: https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-amd64.deb

使用以下命令安装

bash
sudo dpkg -i elasticsearch-7.6.2-amd64.deb

配置Elasticsearch

bash
sudo vim /etc/elasticsearch/elasticsearch.yml

修改配置文件

/etc/elasticsearch/elasticsearch.yml
yml
cluster.name: YOUR_CLUSTER_NAME
node.name: YOUR_NODE_NAME
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["YOUR_IP"]
cluster.initial_master_nodes: ["YOUR_NODE_NAME"]

配置服务自动启动

bash
sudo systemctl enable elasticsearch.service

启动停止服务

bash
sudo systemctl start elasticsearch.service
sudo systemctl stop elasticsearch.service

测试是否运行

bash
curl -X GET "http://localhost:9200/?pretty"

kibana安装

官网下载deb包:https://artifacts.elastic.co/downloads/kibana/kibana-oss-7.6.2-amd64.deb

使用以下命令安装

bash
sudo dpkg -i kibana-oss-7.6.2-amd64.deb

配置Elasticsearch

bash
sudo vim /etc/kibana/kibana.yml

修改配置文件

/etc/kibana/kibana.yml
yml
server.port: 5601
server.host: "0.0.0.0"
elasticsearch.hosts: ["http://localhost:9200"]

配置服务自动启动

bash
sudo systemctl enable kibana.service

启动停止服务

bash
sudo systemctl start kibana.service
sudo systemctl stop kibana.service

测试是否运行:http://localhost:5601