ElasticSearch 配置
单实例安装
下载 :https://www.elastic.co/downloads/elasticsearch
解压命令:
tar -vxf elasticsearch-6.2.2.tar.gz
启动命令:
./bin/elasticsearch
验证启动 :访问:http://localhost:9200/
{
"name": "EbJYm-O",
"cluster_name": "elasticsearch",
"cluster_uuid": "ViVy1WUpQlmM68z8vBGNUQ",
"version": {
"number": "6.2.4",
"build_hash": "ccec39f",
"build_date": "2018-04-12T20:37:28.497551Z",
"build_snapshot": false,
"lucene_version": "7.2.1",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}
可视化插件安装
安装 elasticsearch-head
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
- 访问 http://localhost:9100/
设置可跨域
vim ./config/elasticsearch.yml
添加:
http.cors.enabled: true http.cors.allow-origin: "*"
启动 elasticsearch
启动 elasticsearch-head
分布式安装
拷贝安装文件,分别命名为
master
、slave1
和slave2
执行:
vim master/config/elasticsearch.yml
配置master
cluster.name: xwine node.name: master node.master: true network.host: 127.0.0.1
配置slave1
执行:
vim slave1/config/elasticsearch.yml
cluster.name: xwine node.name: slave1 network.host: 127.0.0.1 http.port: 9201 discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
配置slave2
cluster.name: xwine node.name: slave2 network.host: 127.0.0.1 http.port: 9202 discovery.zen.ping.unicast.hosts: ["127.0.0.1"]
启动es集群
./master/bin/elasticsearch -d
./slave1/bin/elasticsearch -d
./slave2/bin/elasticsearch -d
es 对比 mysql
es 天生支持分片 mysql不行 数据存储结构 查询方式的区别