一:安装JDK
yum install -y java
检测是否安装成功,java -version
二:下载和安装Elasticsearch
先选择好要下载到的文件夹
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.rpm
使用rpm命令安装软件
rpm -ivh elasticsearch-5.5.0.rpm
使用service命令启动elasticsearch服务
service elasticsearch start
测试elasticsearch服务
curl localhost:9200
在我们输入 curl localhost:9200 后发现报错了,我们再看看9200端口有没有被监听(9200是elasticsearch的默认端口)
端口没有被监听,说明elasticsearch的服务没有启动成功
输入service elasticsearch status后发现有错误,错误解决在后面附录
测试成功是这样的
如果想要外网能访问elasticsearch,就要修改配置。
将 /etc/elasticsearch/elasticsearch.yml中的 #network.host: 192.168.0.1 修改成 network.host: 0.0.0.0,重启 elasticsearch
这里有一个坑:network.host: 0.0.0.0 的冒号后面要有一个空格,这里我被坑了很长时间
上面的就算是安装好了
其他elasticsearch命令:
1.查找ES进程
ps -ef | grep elastic
2.杀掉ES进程
kill -9 2382(进程号)
三.安装中文分词
安装中文分词插件ik (安装完需要重启es)
先查找 elasticsearch-plugin 文件的路径
find / -name elasticsearch-plugin
再执行(/xxx/xxx/elasticsearch-plugin替换成你自己的路径)
/xxx/xxx/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.5.4/elasticsearch-analysis-ik-6.5.4.zip
四.安装 elasticsearch-php
如果要在php中使用再接着安装elasticsearch-php
composer require elasticsearch/elasticsearch
会自动加载合适的版本!我的php是5.6的,它会自动加载5.3的elasticsearch版本!
五.elasticsearch-php的使用
查看另一篇博客:https://blog.csdn.net/dabao87/article/details/106803523
附录:
错误1:
Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory,内存不足
解决:
修改jvm.options文件中关于内存的配置(根据服务器实际内存大小调整)
-Xms256m
-Xmx256m
错误2:
OpenJDK 64-Bit Server VM warning:If the number of processors is expected to increase from one,then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCTheads=Need矩阵的内容是怎样的
解决办法:添加配置
-XX:-AssumeMP 到jvm.options