Elasticsearch是什么? Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。
下载安装
本文只讲linux环境下的es搭建
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz
tar -zxvf elasticsearch-5.1.1.tar.gz
cd elasticsearch-5.1.1
修改limit限制
vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
echo 'vm.max_map_count=262144'>> /etc/sysctl.conf
sysctl -p
vi /etc/security/limits.d/90-nproc.conf
soft nproc 2048
设置配置文件
vim config/elasticsearch.yml
node.name: node-1
path.data: /tmp/elasticsearch/data
path.logs: /tmp/elasticsearch/logs
network.host: 192.168.x.x
http.port: 9200
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
创建用户
groupadd elasticsearch
useradd elasticsearch -g elasticsearch -p elasticsearch
# 赋权限
chown elasticsearch:elasticsearch -R /usr/local/elasticsearch-5.1.1
启动
su - elasticsearch -c "nohup /usr/local/elasticsearch-5.1.1/bin/elasticsearch >/dev/null 2>&1 &"
具体路径大家根据自己实际情况更改。
Window
:点击ElasticSearch下的bin目录下的elasticsearch.bat启动
linux : 直接执行 bin下的 ./elasticsearch
如图就是启动成功了
默认端口为9200
安装图形化插件(linux)
//如果没有npm,则需安装npm ,nodejs
yum install -y nodejs
curl https://npmjs.org/install.sh | sh
sh install.sh
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install grunt --save
npm install
//启动服务
/usr/local/elasticsearch-head/node_modules/grunt/bin/grunt server
进入head插件目录,打开cmd,输入: npm install grunt server 打开浏览器,输入http://localhost:9100即可
接下来就可以用Restful接口直接访问,具体看我下一篇文章~~~