一周一个中间件-ES搜索引擎 (2)

> es面向文档,意味着他可以存储整个对象和文档(document).并且索引每个文档内容使其可以被搜索到。你可以对文档进行索引,搜索,排序,过滤。这就是es可以执行复杂的全文搜索的原因。


## 参考文献
Elasticsearch权威指南(中文版).pdf [提取码:c4th](https://pan.baidu.com/s/1bq5fAqju8ZElULt4jBHSKw)

阮一峰的网络日志 [全文搜索引擎 Elasticsearch 入门教程]()

Elasticsearch linux安装包 elasticsearch-7.2.0-linux-x86_64.tar.gz [提取码:ya9s](https://pan.baidu.com/s/1HPEMzaBcmdaiYxnYtY2FPw)

Elasticsearch 中文分词器 elasticsearch-analysis-ik-master [提取码:o2ih](https://pan.baidu.com/s/1kx79pepNSvT9EP3AQZvMtw)

Elasticsearch 拼音分词器 elasticsearch-analysis-pinyin-master [提取码:qsd1](https://pan.baidu.com/s/1_V7ZiaxQBwRlMUgtTotXUw)

Logstash中文文档[Logstash简介](https://www.kancloud.cn/aiyinsi-tan/logstash/849518)

Logstash linux安装包 logstash-7.2.0.tar.gz [提取码:se1s](https://pan.baidu.com/s/1eblvZ9n_t4RnwGQ2AedziQ)

阿里云Elasticsearch产品文档介绍 [阿里云Elasticsearch](https://help.aliyun.com/product/57736.html?spm=a2c4g.11186623.6.540.2ad8731ct6WbSY)

Es为什么比MYSQL快 [博客链接](https://blog.csdn.net/u011635492/article/details/81023158)
<!-- more -->

如果无法下载请联系我 zhangdelei000@gmail.com ,或者评论下留下邮箱百度云账号,我会私发给您。


## 安装es

通过参考文献下载对应的es插件.通过xshell软件和Xftp插件传递到指定得linux服务器。
tar解压文件.进入bin文件内,因为es无法使用root权限去启动,所以创建一个用户和用户组。去启动es。
如要修改配置需要进去config文件内,修改主配置elasticsearch.yml

```json
# ======================== Elasticsearch Configuration =========================

# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"]

http.cors.enabled: true
http.cors.allow-origin: "*"
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
```

上面是默认的配置,不修改配置的默认使用9200端口。
切换到非root用户,使用vim console.out 建立文件。
使用nohup ./elasticsearch > console.out & 启动es,并将输出指向console.out文件。

如图

![Image text]()

## es的可视化

我们一般使用elasticsearch-head这个插件来连接es服务器来可视化es的索引和数据。
git地址 https://github.com/mobz/elasticsearch-head
在linux中 git clone https://github.com/mobz/elasticsearch-head

```
cd elasticsearch-head
npm install
npm run start
```

open :9100/
如图

![Image text]()

## es客户端操作

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wssyds.html