Linux用户登陆(bae),咱们用的是5.3版本的包。从官网下载:java
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.3.0.tar.gz
解压后,进入到bin目录下,使用 ./elasticsearch 命令启动,看到以下的提示,即为启动成功。端口号9200.node
1.记住不要在root下启动,不然会报错:can not run elasticsearch as rootgit
2.若是是在root下下载的elasticsearch,可能会报下面的错误:github
main ERROR Could not register mbeans Java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
【解决】:改变elasticsearch文件夹全部者到当前用户bootstrap
sudo chown -R bae:bae elasticsearch
3. jdk的版本要在1.8以上api
4.错误:cookie
ERROR: bootstrap checks failed max file descriptors [10240] for elasticsearch process is too low, increase to at least [65536] system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk [2017-05-09T21:34:03,914][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] stopping ... [2017-05-09T21:34:03,946][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] stopped [2017-05-09T21:34:03,946][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] closing ... [2017-05-09T21:34:03,960][INFO ][o.e.n.Node ] [m1-hic-ssd-bae03] closed
【解决方法】:负载均衡
切换到root用户, vi /etc/security/limits.confcurl
添加以下内容:elasticsearch
* soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096
#下面的work是用户名,用哪一个用户启动es,就配置成对应的用户名
work soft memlock unlimited
work hard memlock unlimited
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
执行上述sysctl -p命令可能会遇到以下错误:
net.ipv4.ip_forward = 0 net.ipv4.conf.default.rp_filter = 1 net.ipv4.conf.default.accept_source_route = 0 kernel.sysrq = 0 kernel.core_uses_pid = 1 net.ipv4.tcp_syncookies = 1 error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key error: "net.bridge.bridge-nf-call-iptables" is an unknown key error: "net.bridge.bridge-nf-call-arptables" is an unknown key kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296
错误的缘由是3个bridge模块未加载。能够先执行命令,
modprobe bridge
而后再执行sysctl -p命令
重启elasticsearch。此处备注一下es的启动,能够在bin目录下直接执行./elasticsearch,可是有一个问题,终端关闭以后,elasticsearch这个进程就被杀掉了。此时,可使用以下命令启动
nohup ./elasticsearch &
5. 报错:
ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
【解决】:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false bootstrap.system_call_filter: false
【错误缘由】:
这是在由于Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,因此致使检测失败,失败后直接致使ES不能启动。
多机集群中的节点能够分为master nodes和data nodes,在配置文件中使用Zen发现(Zen discovery)机制来管理不一样节点。Zen发现是ES自带的默认发现机制,使用多播发现其它节点。只要启动一个新的ES节点并设置和集群相同的名称这个节点就会被加入到集群中。
Elasticsearch集群中有的节点通常有三种角色:master node、data node和client node。
咱们选m1这台机器做为client node,elasticsearch.yml中的配置以下:
cluster.name: mkt-es-cluster node.name: ${HOSTNAME} network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.**.**.**"]
在m2上配置elasticsearch.yml:
cluster.name: mkt-es-cluster node.name: ${HOSTNAME} network.host: 0.0.0.0 discovery.zen.ping.unicast.hosts: ["10.**.**.**"]
咱们在任意一台机器上请求:curl 'localhost:9200/_cat/health?v'
咱们能够看到,标志着集群状态的status显示为green,节点个数为2个。
1.下载安装包https://github.com/medcl/elasticsearch-analysis-ik/releases
有针对不一样es版本的安装包,须要下载与所安装的es版本匹配的安装包。咱们仍是用5.3.0版本.zip格式的好了。
2.在elasticsearch/plugins目录下新建ik目录,将zip包拷贝到ik目录下,解压。
3.重启elasticsearch
4.注意事项:若是是搭建的集群,须要在每一个节点下都安装ik
5.调用下面的url
GET _analyze { "analyzer":"ik_max_word", "text":"中华人民共和国国歌" }
会获得下面结果:
{ "tokens": [ { "token": "中华人民共和国", "start_offset": 0, "end_offset": 7, "type": "CN_WORD", "position": 0 }, { "token": "中华人民", "start_offset": 0, "end_offset": 4, "type": "CN_WORD", "position": 1 }, { "token": "中华", "start_offset": 0, "end_offset": 2, "type": "CN_WORD", "position": 2 }, { "token": "华人", "start_offset": 1, "end_offset": 3, "type": "CN_WORD", "position": 3 }, { "token": "人民共和国", "start_offset": 2, "end_offset": 7, "type": "CN_WORD", "position": 4 }, { "token": "人民", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 5 }, { "token": "共和国", "start_offset": 4, "end_offset": 7, "type": "CN_WORD", "position": 6 }, { "token": "共和", "start_offset": 4, "end_offset": 6, "type": "CN_WORD", "position": 7 }, { "token": "国", "start_offset": 6, "end_offset": 7, "type": "CN_CHAR", "position": 8 }, { "token": "国歌", "start_offset": 7, "end_offset": 9, "type": "CN_WORD", "position": 9 } ] }
或者经过postman采用这种方式:hz01-bae3-rdtest00.hz01.baidu.com:8920/_analyze?analyzer=ik_max_word&text= 我是好人
问题表现:请求es机器集群信息:http://*******.com:8920/_cluster/health?pretty
可是kibana上面status确实red,重启都不行。显示以下:
先恢复一下数据吧,参照下面连接:
https://stackoverflow.com/questions/42376101/getting-plugin-is-red-error-when-launching-kibana
删掉es的每一个节点下data/es/ 里面的全部数据,重启每一个节点。就ok了。
具体缘由参考下面连接:(其实就是我不知道怎么的吧.kibana这个索引删掉了)
https://stackoverflow.com/questions/31201051/elasticsearch-is-still-initializing-the-kibana-index