Jump to content

9.安装Elasticsearch 中文搜尋/中文搜索


Jack

Recommended Posts

当你安装 LNMP一键安装包 或 宝塔面板,配置Nginx、MySQL/MariaDB、PHP之后

就来安装Elasticsearch

 

------------------------------------------------------------
安装 Java Runtime 1.8
------------------------------------------------------------

命令
yum -y install java-1.8.0

 

命令
yum -y  install java-1.8.0-openjdk-devel

 


------------------------------------------------------------
安装 Elasticsearch
------------------------------------------------------------

下载 rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.6.2-x86_64.rpm

 

安装 rpm
sudo rpm --install elasticsearch-7.6.2-x86_64.rpm

 

命令
sudo systemctl daemon-reload

 

命令
sudo systemctl enable elasticsearch.service

 

 

修改文件
vi /etc/elasticsearch/elasticsearch.yml

 

#network.host: 192.168.0.1
修改为
network.host: 127.0.0.1

 

# http.port: 9200
修改为
http.port: 9200

 

保存并离开
:wq

 

 

 

 

 

修改文件
vi /etc/elasticsearch/jvm.options
 

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

会看到这两个,默认内存 1GB
-Xms1g
-Xmx1g

修改为 (可调低)
-Xms256m
-Xmx256m

 

保存并离开
:wq

 

 

启动命令
sudo systemctl start elasticsearch.service

 

状态命令
service elasticsearch status

 

需要运行
Active: active (running)

 

测试Elasticsearch是否成功运行
curl http://127.0.0.1:9200

 

成功的话,会有讯息,例如 You Know, for Search

Edited by Jack
Link to comment

Elasticsearch的中文搜索,此处只是本地 localhost 使用

所以Elasticsearch使用的 9200 Port 不要外连

 

你最好再确保

大厂的WAF防火墙,若你开启 9200 Port,那就关闭

你云主机Linux的防火墙,若你开启 9200 Port,那就关闭

Link to comment

若你安装的elasticsearch版本太旧或太新,就要卸载,重新安装IPS论坛支持的elasticsearch版本

elasticsearch1.png

 

 

-------------------------------------------------------------
卸载Elasticsearch命令
-------------------------------------------------------------

这个卸载方法,限rpm安装的elasticsearch


查询命令
rpm -qa | grep elasticsearch


得知你安装 elasticsearch-7.10.2-1.x86_64


因为用rpm安装的elasticsearch,所以卸载也用rpm命令
rpm --erase elasticsearch-7.10.2-1.x86_64

 

删除目录,有文件要删掉
rm -f -r /etc/elasticsearch

 

删除目录,有文件要删掉
rm -f -r /var/lib/elasticsearch

 

重启
sudo reboot

 


回到上面的教程 安装Elasticsearch

wget https://artifacts.elastic.co/downloads/elasticsearch/某版本.rpm

重新安装IPS论坛支持的elasticsearch版本

elasticsearch1.png

 

Edited by Jack
Link to comment
Posted (edited)
7小時前,Jack說:

? !

从论坛直接黏贴到SSH软件,真的前面自动有空格

我不是在这个论坛复制的,我前几个月的时候碰到这种错误,顺便提醒大家一下。

Edited by 二戒
Link to comment
Posted (edited)

这发生在独服 CentOS 64bit,安装elasticsearch-7.6.2-x86_64.rpm,在 启动命令/状态命令 就报错,于是我安装更旧的版本

启动命令 sudo systemctl start elasticsearch.service
状态命令 service elasticsearch status

 

 

下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.17.rpm


安装
sudo rpm --install elasticsearch-6.8.17.rpm

命令
sudo systemctl daemon-reload

命令
sudo systemctl enable elasticsearch.service

 

 

修改文件
vi /etc/elasticsearch/elasticsearch.yml


#network.host: 192.168.0.1
修改为
network.host: 127.0.0.1

# http.port: 9200
修改为
http.port: 9200


:wq
保存并离开

 

 

 

修改文件
vi /etc/elasticsearch/jvm.options


# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

会看到这两个,默认内存1GB
-Xms1g
-Xmx1g


修改为
-Xms256m
-Xmx256m

 

:wq
保存并离开

 

 

 

启动命令
sudo systemctl start elasticsearch.service


状态命令
service elasticsearch status

 

测试 Elasticsearch 是否安装成功
curl http://127.0.0.1:9200


成功的话,会有讯息,例如 You Know, for Search

Edited by Jack
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...