Jump to content

9.安装Elasticsearch


Recommended Posts

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

就来安装Elasticsearch

 

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

命令
yum install java-1.8.0

Installed size: 138 M
Is this ok [y/d/N]:

按 y 开始安装

 

 


命令
yum install java-1.8.0-openjdk-devel

Installed size: 40 M
Is this ok [y/d/N]:

按 y 开始安装

 

 

 


------------------------------------------------------------
安装 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

会看到这两个,表示默认 RAM 1 GB
-Xms1g
-Xmx1g

修改为 (如果Elasticsearch无效用,可调低)
-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 post
Share on other sites

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

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

 

你最好再确保

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

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

Link to post
Share on other sites

若你安装的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 post
Share on other sites

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...