软件和环境: virtual box 6.1 centos 7 java: jdk1.8.0_171
es: 7.3.0 官网地址:https://www.elastic.co/cn/downloads/elasticsearch 下载地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.3.0-linux-x86_64.tar.gz
Kibana: 7.3.0 官网地址:https://www.elastic.co/cn/downloads/kibana 下载地址:https://artifacts.elastic.co/downloads/kibana/kibana-7.3.0-linux-x86_64.tar.gz
logstash: 7.3.0 官网地址:https://www.elastic.co/cn/downloads/logstash 下载地址:https://artifacts.elastic.co/downloads/logstash/logstash-7.3.0.tar.gz
配置 hosts
关闭防火墙
1 2 3 systemctl stop firewalld.service systemctl disable firewalld.service firewall-cmd --state
java 环境配置
1 2 3 4 5 6 JAVA_HOME=/usr/java JRE_HOME=/usr/java/jre CLASS_PATH=.:$JAVA_HOME /lib/dt.jar:$JAVA_HOME /lib/tools.jar:$JRE_HOME /lib PATH=$JAVA_HOME /bin:$JRE_HOME /bin:$PATH export JAVA_HOME JRE_HOME CLASS_PATH PATH
es
单机安装请取消注释:node.name: node-1,否则无法正常启动。修改网络和端口,取消注释 master 节点,单机只保留一个 node
1 2 3 4 5 node.name: node-1 network.host: node.com http.port: 9200 cluster.initial_master_nodes: ["node-1" ]
按需修改 vim /usr/elasticsearch/config/jvm.options 内存设置
添加 es 用户,es 默认 root 用户无法启动,需要改为其他用户
1 2 3 4 useradd estest passwd estest chown -R estest /usr/elasticsearch/
修改/etc/sysctl.conf
1 2 vm.max_map_count=655360
修改/etc/security/limits.conf
1 2 3 4 * soft nofile 65536* hard nofile 65536* soft nproc 4096* hard nproc 4096
用 estest 用户启动 es
1 2 su estest /usr/elasticsearch/bin/elasticsearch
测试
1 curl http:// node.com:9200
ik 分词器 https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v7.3.0
在 elasticsearch 的 bin 目录下执行以下命令,es 插件管理器会自动帮我们安装,然后等待安装完成:
1 /usr/ elasticsearch/bin/ elasticsearch-plugin install https://gi thub.com/medcl/ elasticsearch-analysis-ik/releases/ download/v7.3.0/ elasticsearch-analysis-ik-7.3 .0 .zip
下载完成后会提示 Continue with installation?输入 y 即可完成安装
重启 Elasticsearch 和 Kibana
测试
1 2 3 4 POST _analyze { "analyzer" : "ik_max_word" , "text" : "南京市长江大桥" }
Kibana 最好也用 estest 用户操作 解压,修改配置(端口号、es 地址等)
1 2 3 4 5 server.port: 5601 server.host: "0.0.0.0" elasticsearch.hosts: ["http://192.168.211.136:9200" ]
启动
按照和运行redis
: 1 2 3 4 5 6 7 8 9 10 11 12 yum install wget -y wget https://download.redis.io/releases/redis-5.0.8.tar.gz tar -zxf redis-5.0.8.tar.gz yum install gcc -y cd redis-5.0.8make && make install cd /usr/local/bin/cp ~/redis-5.0.8/redis.conf .redis-server redis.conf
Logstash 配置 shipper-logstash.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 input { file { path => [ "/log/out.log" ] } } output { redis { host => "node.com" port => 6379 db => 0 password => "123456" data_type => "channel" key => "sb-logback" } }
配置 indexer-logstash.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 input { redis { host => "node.com" port => 6379 password => "123456" db => 0 data_type => "channel" key => "sb-logback" } } filter { grok { match => { "message" => "%{TIMESTAMP_ISO8601:time} \[%{NOTSPACE:threadName}\] %{LOGLEVEL:level} %{DATA:logger} %{NOTSPACE:applicationName} -(?:.*=%{NUMBER:timetaken}ms|)" } } } output { stdout {} elasticsearch { hosts => "node.com:9200" index => "logback" } }
运行 jar,指定输出目录 1 java -jar spring-api.jar & > /log.out
其他资料