1. 安装jdk

 jdk1.8 windows + Linux

链接: https://pan.baidu.com/s/1uFAUbBthJ2H5Lrp1B6rGFg 提取码: 7vyp 复制这段内容后打开百度网盘手机App,操作更方便哦

设置环境变量

JAVA_HOME="D:\Java\jdk1.8.0_211"
JAVA_BIN=%JAVA_HOME%\bin
CLASSPATH=.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar
PATH=%PATH%:%JAVA_BIN%
  • 1.
  • 2.
  • 3.
  • 4.

 jdk environment path

Linux系统同理

%变量名% 换成 ${变量名} 前面加export 空格

追加到 ~/.bash_profile

source  ~/.bash_profile

2. 安装ElasticSearch

官方网站:

 Download Elasticsearch | Elastic

Elastic search安装

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-windows-x86_64.zip
  • 1.

解压

设定环境变量 ES_HOME

Elastic search安装 (windows) JDK安装配置_JAVA

Run bin/elasticsearch (or bin\elasticsearch.bat on Windows)

Run curl http://localhost:9200/ or Invoke-RestMethod http://localhost:9200 with PowerShell

对于centos系统

下载速度慢 丢到后台运行, 等下载完了再安装rpm包

nohup wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-x86_64.rpm > ./wget.log 2>&1 &
sudo rpm -ivh elasticsearch-7.3.1-x86_64.rpm
  • 1.
  • 2.

[sudo] password for mzh: 
warning: elasticsearch-7.3.1-x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID d88e42b4: NOKEY
Preparing...                          ################################# [100%]
Creating elasticsearch group... OK
Creating elasticsearch user... OK
Updating / installing...
   1:elasticsearch-0:7.3.1-1          ################################# [100%]
### 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
Created elasticsearch keystore in /etc/elasticsearch

启用服务

sudo systemctl enable elasticsearch.service
  • 1.

Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service.

启动服务

sudo systemctl start elasticsearch.service
  • 1.

$ sudo lsof -i:9200
COMMAND   PID          USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
java    19911 elasticsearch  215u  IPv4 16574917      0t0  TCP localhost:wap-wsp (LISTEN)

$ curl http://127.0.0.1:9200
{
  "name" : "iz2ze5rptd09gfzl0jpc3gz",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "2JYYeBQlTL6EmPAbeBkN_w",
  "version" : {
    "number" : "7.3.1",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "4749ba6",
    "build_date" : "2019-08-19T20:19:25.651794Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

修改配置文件之后重新加载

sudo systemctl daemon-reload
  • 1.

停掉服务 service elasticsearch stop

可以不用rpm安装包安装

Download the Elasticsearch archive for your OS:

Linux:  elasticsearch-7.3.1-linux-x86_64.tar.gz

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-linux-x86_64.tar.gz
  • 1.

macOS:  elasticsearch-7.3.1-darwin-x86_64.tar.gz

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.1-darwin-x86_64.tar.gz
  • 1.

Windows:  elasticsearch-7.3.1-windows-x86_64.zip

Extract the archive:

Linux:

tar -xvf elasticsearch-7.3.1-linux-x86_64.tar.gz
  • 1.

macOS:

tar -xvf elasticsearch-7.3.1-darwin-x86_64.tar.gz
  • 1.

Windows PowerShell:

Expand-Archive elasticsearch-7.3.1-windows-x86_64.zip
  • 1.

解压之后放到 /opt/elasticsearch/7.3.1

创建data目录并让当前用户可以读写

sudo mkdir /opt/elasticsearch/7.3.1/data
sudo chown mzh:staff /opt/elasticsearch/7.3.1/data
  • 1.
  • 2.

Start two more instances of Elasticsearch so you can see how a typical multi-node cluster behaves. You need to specify unique data and log paths for each node.

Linux and macOS:

cd /opt/elasticsearch/7.3.1/
sudo mkdir data2 log2 data3 log3
sudo chown mzh:staff data2
sudo chown mzh:staff log2
sudo chown mzh:staff log3
sudo chown mzh:staff data3

/opt/elasticsearch/7.3.1/bin/elasticsearch -Epath.data=data2 -Epath.logs=log2 
/opt/elasticsearch/7.3.1/bin/elasticsearch -Epath.data=data3 -Epath.logs=log3
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

查看服务启动:

$ curl http://127.0.0.1:9200
{
  "name" : "iz2ze5rptd09gfzl0jpc3gz",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "qD209wn-SNaG5saFoERMMw",
  "version" : {
    "number" : "7.3.1",
    "build_flavor" : "default",
    "build_type" : "tar",               // 不是用的rpm包
    "build_hash" : "4749ba6",
    "build_date" : "2019-08-19T20:19:25.651794Z",
    "build_snapshot" : false,
    "lucene_version" : "8.1.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

$ curl http://127.0.0.1:9200/_cat/health?v
epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1567049951 03:39:11  elasticsearch green           3         3      0   0    0    0        0             0                  -                100.0%
 

官方介绍文档:

 What is Elasticsearch? | Elasticsearch Guide [8.12] | Elastic

腾讯云实验室

腾讯云 - 值得信赖