es+kibana
[*] 安装es
检查java版本,需要1.8.0以上
java -version
下载安装包
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.2.tar.gz 解压
tar -xvf elasticsearch-6.1.2.tar.gz 添加用户并设置密码,并赋予权限
groupadd es
useradd -g es es
echo "123456"|passwd es --stdin
chown -R es.es /usr/local/elasticsearch-6.1.2 修改内核参数
vim /etc/security/limits.conf
es soft nofile 65536
es hard nofile 65536
es soft nproc 4096
es hard nproc 4096
es soft memlock unlimited
es hard memlock unlimited 运行(es禁止使用root用户运行)
su - es
cd/usr/local/
cd elasticsearch-6.1.2/bin
./elasticsearch -d -d选项是在后台运行程序
访问测试
curl localhost:9200
## 搭建es集群
官方配置文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/modules.html
复制文件
su - root
cd /usr/local
mv elasticsearch-6.1.2 elasticsearch-6-node1
cp -r elasticsearch-6-node1/ elasticsearch-6-node3
chown es.es -R elasticsearch-6-node3/
scp -r elasticsearch-6-node1/ kibana:/usr/local/elasticsearch-6.1.2/
[*] 修改node1配置文件
cd /usr/local/elasticsearch-6-node1/config/
vim elasticsearch.ymlcluster.name: my-es
node.name: es-node-1
node.master: true
node.data: true
node.ingest: true
search.remote.connect: true
node.attr.rack: region1
path.data: /usr/local/elasticsearch-6-node1/data
path.logs: /usr/local/elasticsearch-6-node1/logs
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.3.161
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es", "kibana", "es:9301"]
discovery.zen.ping_timeout: 40s
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
action.destructive_requires_name: true 配置文件中又详细的英文介绍,想配置更多参数请看官方文档
设置jvm
vim jvm.options-Xms4g
-Xmx4g
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+AlwaysPreTouch
-server
-Xss1m
-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-XX:-OmitStackTraceInFastThrow
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-XX:+HeapDumpOnOutOfMemoryError
#"以下日志为调试使用,过多"
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintClassHistogram
-XX:+PrintTenuringDistribution
-XX:+PrintGCApplicationStoppedTime
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=12
-XX:GCLogFileSize=64M
#"以上日志为调试使用,过多" 创建文件存放路径
mkdir -pv /usr/local/elasticsearch-6-node2/HeapDump
mkdir -pv /usr/local/elasticsearch-6-node2/gc
[*] 修改node2配置文件
vim /usr/local/elasticsearch-6-node2/config/elasticsearch.ymlcluster.name: my-es
node.name: es-node-2
node.master: true
node.data: true
node.ingest: true
search.remote.connect: true
node.attr.rack: region1
path.data: /usr/local/elasticsearch-6-node2/data/
path.logs: /usr/local/elasticsearch-6-node2/logs/
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.3.162
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["es", "kibana", "es:9301"]
discovery.zen.ping_timeout: 40s
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
action.destructive_requires_name: true vim jvm.options-Xms4g
-Xmx4g
[*] 修改node3配置文件
vim /usr/local/elasticsearch-6-node3/config/elasticsearch.ymlcluster.name: my-es
node.name: es-node-3
node.master: true
node.data: true
node.ingest: true
search.remote.connect: true
node.attr.rack: region1
path.data: /usr/local/elasticsearch-6-node3/data/
path.logs: /usr/local/elasticsearch-6-node3/logs/
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
network.host: 192.168.3.161
http.port: 9400
transport.tcp.port: 9301
discovery.zen.ping.unicast.hosts: ["es", "kibana", "es:9301"]
discovery.zen.ping_timeout: 40s
discovery.zen.minimum_master_nodes: 2
gateway.recover_after_nodes: 3
action.destructive_requires_name: true vim jvm.options-Xms4g
-Xmx4g
[*] 安装kibana
官方文档:https://www.elastic.co/guide/en/kibana/current/index.html
(官网还有一个darwin的版本,不知道具体用处)
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.1.2-linux-x86_64.tar.gz
tar axf kibana-6.1.2-linux-x86_64.tar.gz
cd kibana-6.1.2-linux-x86_64/bin/ 设置环境变量
vim /etc/profile
export KIBANA_HOME=/usr/local/kibana-6.1.2-linux-x86_64
export PATH=${PATH}:${KIBANA_HOME}/bin source /etc/profile
修改配置
cd /usr/local/kibana-6.1.2-linux-x86_64/config
vim kibana.ymlserver.port: 5601
server.host: 0.0.0.0
server.maxPayloadBytes: 1048576
server.name: "kibana"
elasticsearch.url: "http://192.168.3.161:9200"
elasticsearch.preserveHost: true
elasticsearch.requestTimeout: 30000 启动kibana
cd kibana-6.1.2-linux-x86_64/bin
./kibana -c ../config/kibana.yml
[*] 安装elasticsearch-head
root安装 npm
yum install -y npm git
yum install -y nodejs-grunt-cli es用户安装elasticsearch-head(有报错就假装看不见)
su - es
git clone git://github.com/mobz/elasticsearch-head.git
elasticsearch-head/
npm install
grunt server 检查9100端口是否监听
ss -tunlp|grep 9100
curl http://192.168.3.54:9100 连接elasticsearch(与web页面访问地址一致)
http://s1.运维网.com/images/20180201/1517414505791935.png
[*] 报错处理
ERROR: bootstrap checks failed
: max number of threads for user is too low, increase to at least
: max virtual memory areas vm.max_map_count is too low, increase to at least
: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
第一个threads太小,解决方法如下
vim /etc/security/limits.conf
es soft nproc 4096
es hard nproc 4096
第二个是vm.max_map_count太小,解决方法如下
vi /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p
第三个是centos6版本不支持,修改elasticsearch.yml
vim elasticsearch.yml
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
[*] 报错
failed to send join request to master
无法加入集群,网上有说是数据问题,也有说是网络问题,我遇到的是网络问题
检查配置文件中discovery.zen.ping.unicast.hosts:是否设置正确、设置discovery.zen.ping_timeout:为更大值(默认3s),检查防火墙是否拦截
[*] 参考文档:
elasticsearch官方文档:https://www.elastic.co/guide/cn/elasticsearch/guide/current/index.html
kiban官方文档:https://www.elastic.co/guide/en/kibana/current/index.html
生产环境elasticsearch的配置建议:http://blog.csdn.net/thomas0yang/article/details/55518105
elasticsearch5.0集群+kibana5.0+head插件插件的安装:https://www.cnblogs.com/reblue520/p/6239658.html
Elasticsearch5.2.1集群搭建,动态加入节点,并添加监控诊断插件:http://blog.csdn.net/gamer_gyt/article/details/59077189
页:
[1]