简介:
全文搜索属于最常见的需求,开源的 Elasticsearch (以下简称 es)是目前全文搜索引擎的首选。
它可以快速地储存、搜索和分析海量数据。维基百科、Stack Overflow、Github 都采用它。
Elasticsearch简称es,在企业内同样是一款应用非常广泛的搜索引擎服务。
很多服务中的搜索功能,都是基于es来实现的。
安装
添加yum仓库
# 导入仓库密钥
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
# 添加yum源
# 编辑文件
vim /etc/yum.repos.d/elasticsearch.repo
底线模式输入 :set paste 可以粘贴以下内容
[elasticsearch-7.x]
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=1
autorefresh=1
type=rpm-md
保存退出
:wq
更新yum缓存
yum makecache
安装es
yum install -y elasticsearch
配置es(注意把#去掉,底线模式 :set nu 可以显示行号)
vim /etc/elasticsearch/elasticsearch.yml
# 17行,设置集群名称
cluster.name: my-cluster# 23行,设置节点名称
node.name: node-1# 56行,允许外网访问
network.host: 0.0.0.0# 74行,配置集群master节点
cluster.initial_master_nodes: ["node-1"]
启动es
systemctl start elasticsearch # 启动
systemctl status elasticsearch # 查看状态
(下面根据需求选择,不需要管)
systemctl enable elasticsearch # 开机自启
systemctl disable elasticsearch # 关闭开机自启
systemctl stop elasticsearch # 关闭
关闭防火墙
#方法一(学习测试推荐)
systemctl stop firewalld
systemctl disable firewalld
#方法二 放行9200,9300端口
firewall-cmd --add-port=9200/tcp --permanent
firewall-cmd --add-port=9300/tcp --permanent
firewall-cmd --reload #永久生效
测试
http://centos ip地址:9200
完成!