M2.4开始,产品的搜索强制使用Elasticsearch,所以需要先安装Elasticsearch7.x。 **安装** ``` vim /etc/yum.repos.d/elasticsearch.repo ``` ``` [elasticsearch] name=Elasticsearch repository for 7.x packages baseurl=https://artifacts.elastic.co/packages/7.x/yum gpgcheck=1 gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch enabled=0 autorefresh=1 type=rpm-md ``` ``` yum install --enablerepo=elasticsearch elasticsearch ``` **配置** ``` vim /etc/elasticsearch/elasticsearch.yml ``` ``` [cluster.name](http://cluster.name/): my-application [node.name](http://node.name/): node-1 path.data: /var/lib/elasticsearch path.logs: /var/log/elasticsearch network.host: 127.0.0.1 http.port: 9200 ``` Elasticsearch不允许root用户执行,新建分组es和用户es,用于执行Elasticsearch。 ``` groupadd es useradd -g es es ``` 修改owner ``` chown -R es.es /usr/share/elasticsearch /var/lib/elasticsearch /var/log/elasticsearch /etc/sysconfig/elasticsearch /etc/elasticsearch ``` 切换到es用户,然后启动Elasticsearch ``` su es /usr/share/elasticsearch/bin/elasticsearch -d ``` 验证 ``` curl -XGET '127.0.0.1:9200/_cat/health?v&pretty' ``` 出现类似的内容,说明成功了。 ![](https://img.kancloud.cn/47/15/4715545bc2f6f2b4148c09cb536dc6ae_1051x114.png)