elasticsearch5.2.1安装

版权声明:本文为博主原创文章,未经博主允许不得转载。否则切鸡鸡~~ https://blog.csdn.net/kang5789/article/details/71730146

3台机器部署:192.168.1.201、192.168.1.202、192.168.1.203

jdk8、es5.2.1、kibana5.2.1、x-pack、ik

jdk安装参考:点击打开链接

1.es、kibana下载:https://www.elastic.co/downloads

2.解压es
tar -zxvf es.gz
注意:解压过程中每个es会生成一个uuid,所以不要scp拷贝,这样uuid一样会出问题,每台机器要分开解压
每个es安装配置都是一样的,除了elastic.yml里边name、ip
修改config/elastic.yml


cluster.name: es-cluster
#此机器elasticsearch节点名称,各机器不能重复 
node.name: node1
#数据存放目录(可修改)  
path.data: /usr/local/apps/elasticsearch-5.2.1/data
#日志存放目录(可修改)  
path.logs: /usr/local/apps/elasticsearch-5.2.1/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.1.201
#设置集群中master节点的初始列表,可以通过这些节点来自动发现新加入集群的节点 
discovery.zen.ping.unicast.hosts: ["192.168.1.201", "192.168.1.202"]
#设置这个参数来保证集群中的节点可以知道其它N个有master资格的节点。默认为1,对于大的集群来说,可以设置大一点的值(2-4)  
discovery.zen.minimum_master_nodes: 2
action.auto_create_index: .security,.monitoring*,.watches,.triggered_watches,.watcher-history*

3.修改config/jvm.options ,看机器配置,越大越好,默认为2g

-Xms256m
-Xmx256m

4.修改部分参数值
vi /etc/security/limits.conf  添加如下内容:  

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

vi /etc/security/limits.d/90-nproc.conf  
修改 * soft nproc 1024 为 soft nproc 2048 

vi /etc/sysctl.conf  添加下面配置:  
vm.max_map_count=655360
sysctl -p 

es不能以root用户启动
adduser es
chown es -R ./eshome
启动
./eshome/bin/elasticsearch
访问ip:9200  集群完成!
 

插件安装

x-pack安全组件、Kibana图形化界面、ik中文分词器
x-pack默认用户名密码:elastic、changeme
 

1.x-pack: 
在线安装:执行 eshome/bin/elasticsearch-plugin install x-pack
离线安装:
下载插件  https://artifacts.elastic.co/downloads/packs/x-pack/x-pack-5.2.1.zip
执行   ./elasticsearch-5.2.1/bin/elasticsearch-plugin install file:///path/x-pack-5.2.1.zip

插件破解:http://www.cnblogs.com/benwu/articles/6648471.html
 

2.kibana:
解压kibana.gz
vi kibana-5.2.1-linux-x86_64/config/kibana.yml
修改:

server.host: "192.168.1.201"
elasticsearch.url: "http://192.168.1.201:9200"
elasticsearch.username: "elastic"
elasticsearch.password: "changeme"

验证:在浏览器上输入:http://localhost:5601/ 

3.ik分词器:
下载地址:https://github.com/medcl/elasticsearch-analysis-ik 
在windows下解压到当前文件夹,在文件夹内右键此处打开命令窗口,输出命令 mvn package
打包成功以后,会生成一个target文件夹,releases目录下,找到elasticsearch-analysis-ik-5.2.1.zip,这就是我们需要的安装文件
将zip解压重命名为ik,最后将ik上传到eshome/plugins目录下即可!!
重启es

测试:http://localhost:9200/_plugin/head/

创建一个索引:

curl -XPUT "http://192.168.1.201:9200/testindex"

打开kibana  devtools,测试

PUT testindex
{
  "settings": {
    "number_of_shards": 3,
    "number_of_replicas": 1
  },
  "mappings": {
    "goods": {
      "_all": {
        "enabled": true
      },
      "properties": {
        "name": {
          "type": "text",
          "analyzer": "ik_max_word"
        },
        "msg": {
          "type": "text",
          "analyzer": "ik_max_word"
        },
        "date": {
          "type": "date",
          "format": "yyyy-MM-dd HH:mm:ss"
        }
      }
    }
  }
}


POST testindex/goods/1
{
    "name" : "宝马",
    "msg" : "别摸我!!"
}


PUT testindex/goods/2
{
    "name" : "大宝",
    "msg" : "大宝,天天见"
}


POST _analyze
{
  "analyzer": "ik_max_word",
  "text":     "笔记本"
}


POST testindex/_search
{
  "query": {
    "match": {
      "_all": "笔记本"
    }
  },
  "highlight": {
    "fields": {
      "title": {
        "pre_tags": "<h1>",
        "post_tags": "</h1>"
      }
    }
  }
}


DELETE /testindex

 

猜你喜欢

转载自blog.csdn.net/kang5789/article/details/71730146