Elasticsearch 安装

安装:
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.1-linux-x86_64.tar.gz
tar -xvf elasticsearch-7.7.1-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/elasticsearch-7.7.1/bin
./elasticsearch -d

curl 127.0.0.1:9200
出现json信息则表示启动成功

开更多实例:
./elasticsearch -Epath.data=data2 -Epath.logs=log2
./elasticsearch -Epath.data=data3 -Epath.logs=log3

问题:
1.can not run elasticsearch as root
es5之后的都不能使用添加启动参数或者修改配置文件等方法启动了,必须要创建用户

adduser elasticsearch
passwd elasticsearch
chown -R elasticsearch:elasticsearch elasticsearch-7.7.1

2.启动后访问ip:9200没有显示json,提示连接被拒绝或the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
修改elasticsearch.yml文件
修改或后期以下信息
network.host: 0.0.0.0
node.name: node-1
cluster.initial_master_nodes: [“node-1”]
保存重新启动

3.max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
vim /etc/sysctl.conf
添加下面配置
vm.max_map_count=655360
保存退出
sysctl -p

其它异常:
https://blog.csdn.net/happyzxs/article/details/89156068

es初级使用例子

https://www.jianshu.com/p/3873a6290c65

PHP使用

在 composer.json 文件中引入 elasticsearch-php
{
“require”: {
“elasticsearch/elasticsearch”: “~6.0″//此时版本请根据es版本进行修改。
}
}
github地址:
https://github.com/elastic/elasticsearch-php
更新composer包:
composer update elasticsearch/elasticsearch

如果更新出错可以执行
composer update –lock
重新安装

PHP ES快速开始
https://www.elastic.co/guide/cn/elasticsearch/php/current/_quickstart.html