环境说明
|服务器|是否主节点|是否数据节点|
10.0.116.144 | true | true |
---|---|---|
10.0.110.101 | true | true |
10.0.110.130 | true | true |
jdk安装 (略)
Elasticsearch安装
- 解压文件 tar -zxvf elasticsearch-6.2.1.tar.gz
- 修改elasticsearch配置文件
#集群的名称
cluster.name: es6.2
#节点名称,其余两个节点分别为node-2 和node-3
node.name: node-1
#指定该节点是否有资格被选举成为master节点,默认是true,es是默认集群中的第一台机器为master,如果这台机挂了就会重新选举master
node.master: true
#允许该节点存储数据(默认开启)
node.data: true
#索引数据的存储路径
path.data: /usr/local/elk/elasticsearch/data
#日志文件的存储路径
path.logs: /usr/local/elk/elasticsearch/logs
#设置为true来锁住内存。因为内存交换到磁盘对服务器性能来说是致命的,当jvm开始swapping时es的效率会降低,所以要保证它不swap
#bootstrap.memory_lock: true
#绑定的ip地址
network.host: 10.0.116.144
#设置对外服务的http端口,默认为9200
http.port: 9200
# 设置节点间交互的tcp端口,默认是9300
transport.tcp.port: 9300
#Elasticsearch将绑定到可用的环回地址,并将扫描端口9300到9305以尝试连接到运行在同一台服务器上的其他节点。
#这提供了自动集群体验,而无需进行任何配置。数组设置或逗号分隔的设置。每个值的形式应该是host:port或host
#(如果没有设置,port默认设置会transport.profiles.default.port 回落到transport.tcp.port)。
#请注意,IPv6主机必须放在括号内。默认为127.0.0.1, [::1]
discovery.zen.ping.unicast.hosts: ["10.0.116.144:9300", "10.0.1110.101:9300", "10.0.110.130:9300"]
#如果没有这种设置,遭受网络故障的集群就有可能将集群分成两个独立的集群 - 分裂的大脑 - 这将导致数据丢失
discovery.zen.minimum_master_nodes: 2
调整jvm内存
vim /usr/local/elk/elasticsearch/config/jvm.options
#默认是1g官方建议对jvm进行一些修改,不然很容易出现OOM,参考官网改参数配置最好不要超过内存的50%
-Xms1g
-Xmx1g
报错:
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
原因:
这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。
解决:
在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process likely too low,
increase to at least [65536]
max number of threads [1024] for user [lishang] likely too low,
increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] likely too low,
increase to at least [262144]
解决:切换到root用户,编辑limits.conf 添加类似如下内容
vi /etc/security/limits.conf
添加如下内容:
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
对于第二条错误同意需要切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
* soft nproc 1024
#修改为
* soft nproc 2048
第三条错误需要切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
然后,重新启动elasticsearch,即可启动成功。
Head插件简介
ElasticSearch-head是一个H5编写的ElasticSearch集群操作和管理工具,可以对集群进行傻瓜式操作。
显示集群的拓扑,并且能够执行索引和节点级别操作 搜索接口能够查询集群中原始json或表格格式的检索数据 能够快速访问并显示集群的状态 有一个输入窗口,允许任意调用RESTful API。这个接口包含几个选项,可以组合在一起以产生有趣的结果; 5.0版本之前可以通过plugin名安装,5.0之后可以独立运行。
Head插件安装
1)安装NodeJS
[root@node1 ~]# yum install -y nodejs
(2)安装npm [root@node1 ~]# npm install -g cnpm --registry=https://registry.npm.taobao.org (3)使用npm安装grunt [root@node1 ~]# npm install -g grunt [root@node1 ~]# npm install -g grunt-cli --registry=https://registry.npm.taobao.org --no-proxy
(4) 下载head插件源码 [es@node1 ~]$ wget https://github.com/mobz/elasticsearch-head/archive/master.zip [es@node1 ~]$ unzip master.zip
(5) 下载依赖 [es@node1 elasticsearch-head-master]$ npm install 如果上面命令安装较慢或失败,可以尝试国内镜像安装 [es@node1 elasticsearch-head-master]$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
配置
1)配置 ElasticSearch,使得HTTP对外提供服务
[es@node1 elasticsearch-6.1.1]$ vi config/elasticsearch.yml
添加如下内容
# 增加新的参数,这样head插件可以访问es。设置参数的时候:后面要有空格
http.cors.enabled: true
http.cors.allow-origin: "*"
(2)修改Head插件配置文件 [es@node1 elasticsearch-head-master]$ vi Gruntfile.js
找到connect:server,添加hostname一项,如下
connect: {
server: {
options: {
hostname: 'ip',
port: 9100,
base: '.',
keepalive: true
}
}
}
2.4 启动 (1)启动elasticsearch 首先确认elasticsearch已经启动
[es@node1 elasticsearch-6.1.1]$ bin/elasticsearch -d
[es@node1 elasticsearch-6.1.1]$ jps
3451 Jps
3436 Elasticsearch
(2)启动head 通过命令grunt server启动head
[es@node1 elasticsearch-head-master]$ grunt server
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100
或者通过命令npm run start也可以启动head [es@node1 elasticsearch-head-master]$ npm run start
Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://node1:9100
转载自:https://blog.csdn.net/qq_34021712/article/details/79330028
https://blog.csdn.net/chengyuqiang/article/details/78838175