#前言

博客的搜索有点难用,经常找不到东西,因为现在还是基于字符串匹配的,也没有办法进行模糊搜索,所以折腾一下,顺便学习一下Elasticsearch,记录之。

#安装OpenJDK

Elasticsearch is built using Java, and includes a bundled version of OpenJDK from the JDK maintainers (GPLv2+CE) within each distribution. The bundled JVM is the recommended JVM and is located within the jdk directory of the Elasticsearch home directory.

官网的描述如上,所以跟着官网去 https://jdk.java.net/ 下了OpenJDK

1
2
wget https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz
wget https://download.java.net/java/GA/jdk16.0.1/7147401fd7354114ac51ef3e1328291f/9/GPL/openjdk-16.0.1_linux-x64_bin.tar.gz.sha256

本来还想皮一下,结果发现验证不了。。。。只能手动验证了:

1
2
3
4
onns@onns:~$ shasum -a 256 openjdk-16.0.1_linux-x64_bin.tar.gz
b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235 openjdk-16.0.1_linux-x64_bin.tar.gz
onns@onns:~$ cat openjdk-16.0.1_linux-x64_bin.tar.gz.sha256
b1198ffffb7d26a3fdedc0fa599f60a0d12aa60da1714b56c1defbce95d8b235

然后解压安装:

1
2
3
tar xvf openjdk-16.0.1_linux-x64_bin.tar.gz
vi .bashrc
source .bashrc

添加的内容是:

1
2
export JAVA_HOME=/home/onns/jdk-16.0.1
export PATH=$PATH:${JAVA_HOME}/bin

测试一下:

1
2
onns@onns:~$ javac -version
javac 16.0.1

#安装Elasticsearch

1
2
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.13.1-linux-x86_64.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.13.1-linux-x86_64.tar.gz.sha512

这个就能验证成功 😂 :

1
2
onns@onns:~$ shasum -a 512 -c elasticsearch-7.13.1-linux-x86_64.tar.gz.sha512
elasticsearch-7.13.1-linux-x86_64.tar.gz: OK

然后正常解压即可:

1
2
tar -xvf elasticsearch-7.13.1-linux-x86_64.tar.gz
cd elasticsearch-7.13.1/

然后运行:

1
./bin/elasticsearch

尴尬,我的云服务器居然内存不够开启这个服务。。。换了个服务器:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(base) hs@hs-Z390-AORUS-PRO:~$ curl localhost:9200
{
"name" : "hs-Z390-AORUS-PRO",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "b6FAZNuyRxG1dVoY6Gbtog",
"version" : {
"number" : "7.13.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "9a7758028e4ea59bcab41c12004603c5a7dd84a9",
"build_date" : "2021-05-28T17:40:59.346932922Z",
"build_snapshot" : false,
"lucene_version" : "8.8.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}

还是我太天真了,这个东西啥也不干就2G内存没了,害。

#相关链接