通过一个半月的不懈努力, 小说项目已经完成了一大半, 前端界面以及api对接所有完成, 后台系统完成一小部分功能。前端
记得当初作这个项目的初衷是由于感受本身所学太杂, 并且本身对一些技术如Kafka, ES很感兴趣,因此想经过这个项目对这些东西进行融合,加深对其印象linux
在项目中, 我采用ElasticSearch来处理项目中的小说搜索git
Elasticsearch是一个基于Apache Lucene(TM)的实时分布式搜索和分析引擎,可是若是要直接使用lucene, 却很是困难。 由于Lucene只是一个库, 想要使用它,你必须使用Java来做为开发语言并将其直接集成到你的应用中,更糟糕的是,Lucene很是复杂,你须要深刻了解检索的相关知识来理解它是如何工做的。。。github
Elasticsearch也使用Java开发并使用Lucene做为其核心来实现全部索引和搜索的功能,可是它的目的是经过简单的RESTful API来隐藏Lucene的复杂性,从而让全文搜索变得简单apache
Elasticsearch能够很轻松的横向扩展, 可支持PB级的结构和非结构数据处理npm
加深对ES的理解的最好方式就是运行它, 那么咱们先来安装bootstrap
安装环境centos
CentOS 7api
JDK 1.8 (必须)跨域
ES-6.8.2 和JDK的版本是对应关系
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.2.tar.gz
tar -zxvf elasticsearch-6.8.2.tar.gz
ES不能使用root用户来启动
groupadd elasticsearch
useradd -r -g elasticsearch elasticsearch
chown -Rf elasticsearch:elasticsearch elasticsearch-6.8.2
复制代码
./bin/elasticsearch
network.host: 0.0.0.0
nohup ./bin/elasticsearch &
./bin/elasticsearch -d
ES默认监听9200端口
curl 'http://localhost:9200/'
{
"name" : "7J76WwT",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "Wsfbm6vLS2uOyoDqWVppdw",
"version" : {
"number" : "5.5.2",
"build_hash" : "b2f0c09",
"build_date" : "2017-08-14T12:33:14.154Z",
"build_snapshot" : false,
"lucene_version" : "6.6.0"
},
"tagline" : "You Know, for Search"
}
复制代码
可以输出相似的内容说明已经启动成功
到此, 关于ES的简介和单机版安装就完成了
按照上述的安装方式, 在远程链接ES的时候会出现出现如下问题, 咱们来解决下
network.host: 0.0.0.0
在启动过程当中会出现如下问题max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
这里错误是每一个进程最大同时打开文件数过小
修改/etc/security/limits.conf文件,增长配置, 须要从新进行登陆才能生效
* soft nofile 65536
* hard nofile 65536
复制代码
能够经过如下命令来查看
ulimit -Hn
ulimit -Sn
复制代码
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
修改/etc/sysctl.conf文件,增长配置
vm.max_map_count=262144
sysctl -p 查看是否生效
复制代码
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own ris
这个问题是因为centos的版本问题引发的, 在elasticsearch配置中配置
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
复制代码
在ES中的配置容许跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
复制代码
下载head项目 推荐采用Git下载, 点击下载
这里须要安装Node, 你们另行baidu查询
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
//安装依赖插件
npm install
//运行
npm run start
复制代码
经过 http://localhost:9100/ 访问