Windows上ElasticSearch集群(上篇)

1.下载ES压缩包
2.修改elasticsearch配置文件:config/elasticsearch.yml,增加以下两句命令
http.cors.enabled: true
http.cors.allow-origin: "*"
3 启动ES服务
点击ElasticSearch下的bin目录下的elasticsearch.bat启动,控制台显示的日志信息如下:
4 安装ES的图形化界面插件
   1)下载head插件:https://github.com/mobz/elasticsearch-head
   2)将elasticsearch-head-master压缩包解压到任意目录,但是要和elasticsearch的安装目录区别开
   3)下载nodejs:https://nodejs.org/en/download/ 在资料中已经提供了nodejs安装程序:
   安装完毕,可以通过cmd控制台输入:node -v 查看版本号
   4)将grunt安装为全局命令 ,Grunt是基于Node.js的项目构建工具 在cmd控制台中输入如下执行命令: 
   > npm install ‐g grunt‐cli
   5)进入elasticsearch-head-master目录启动head,在命令提示符下输入命令:
   > npm install 
   > grunt server
   6)打开浏览器,输入 http://localhost:9100,看到如下页面:
5.ElasticSearch集成IK分词器
1)下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases
2)解压,将解压后的elasticsearch文件夹拷贝到elasticsearch-5.6.8\plugins下,并重命名文件夹为analysis-ik
3)重新启动ElasticSearch,即可加载IK分词器

5.1 IK分词器测试 
IK提供了两个分词算法ik_smart 和 ik_max_word 
其中 ik_smart 为最少切分,ik_max_word为最细粒度划分

1)最小切分:在浏览器地址栏输入地址 
输出的结果为: http://127.0.0.1:9200/_analyze?analyzer=ik_smart&pretty=true&text=我是程序员
2)最细切分:在浏览器地址栏输入地址 http://127.0.0.1:9200/_analyze?analyzer=ik_max_word&pretty=true&text=我是程序员


(二)windows上安装ElasticSearch集群

1)在内部复制三个elasticsearch服务
2)修改elasticsearch-cluster\node*\config\elasticsearch.yml配置文件 

node1节点:

http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.name: my-esLearn
node.name: node-1
network.host: 127.0.0.1
http.port: 9201
transport.tcp.port: 9301
#设置集群自动发现机器ip集合
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]

node2节点:

http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.name: my-esLearn
node.name: node-2
network.host: 127.0.0.1
http.port: 9202
transport.tcp.port: 9302
#设置集群自动发现机器ip集合
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]

node3节点:

http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.name: my-esLearn
node.name: node-3
network.host: 127.0.0.1
http.port: 9203
transport.tcp.port: 9303
#设置集群自动发现机器ip集合
discovery.zen.ping.unicast.hosts: ["127.0.0.1:9301", "127.0.0.1:9302", "127.0.0.1:9303"]

创建索引


put  htttp://127.0.0.1:9201/blog
{
    "mappings": {
        "article": {
            "properties": {
                "id": {
                    "type": "long",
                    "store": true
                },
                "title": {
                    "type": "text",
                    "store": true,
                    "analyzer": "ik_smart"
                },
                "content": {
                    "type": "text",
                    "store": true,
                    "analyzer": "ik_smart"
                }
            }
        }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值