用途:node
1.问题排查。咱们常说,运维和开发这一生无非就是和问题在战斗,因此这个提及来很朴实的四个字,实际上是沉甸甸的。不少公司其实不缺钱,就要稳定,而要稳定,就要运维和开发可以快速的定位问题,甚至防微杜渐,把问题杀死在摇篮里。日志分析技术显然问题排查的基石。基于日志作问题排查,还有一个很帅的技术,叫全链路追踪,好比阿里的eagleeye 或者Google的dapper,也算是日志分析技术里的一种。 2.监控和预警。 日志,监控,预警是相辅相成的。基于日志的监控,预警使得运维有本身的机械战队,大大节省人力以及延长运维的寿命。 3.关联事件。多个数据源产生的日志进行联动分析,经过某种分析算法,就可以解决生活中各个问题。好比金融里的风险欺诈等。这个能够能够应用到无数领域了,取决于你的想象力。 4.数据分析。 这个对于数据分析师,还有算法工程师都是有所裨益的。
官网下载:https://www.elastic.co/cn/downloads/
网速慢这边有百度网盘:
连接:https://pan.baidu.com/s/15bojKanJ5k_YbBayjP1bdw
提取码:m4vclinux
下载上述三个安装包以后,上传至服务器,准备开始安装git
#建立用户组esgithub
注:elasticsearch 不容许以 root 权限来运行!因此须要建立一个非root用户,因为ElasticSearch能够接收用户输入的脚本而且执行,为了系统安全考虑,
建议建立一个单独的用户用来运行ElasticSearch。算法
groupadd es
#建立新用户es,设置用户组为es,密码esnpm
useradd es -g es -p es
#受权,更改elasticsearch-7.12.0文件夹所属用户及用户组为es:es(首先在/home/elk 目录下建立名成为elasticsearch-7.12.0文件夹)json
chown -R es:es elasticsearch-7.12.0
#切换用户esbootstrap
su - es
#开始安装解压vim
tar -xzvf elasticsearch-7.12.0-linux-x86_64.tar.gz
#修改es配置文件centos
1)调整jvm内存大小(机器内存够也可不调整) vim elasticsearch-7.1.1/config/jvm.options #修改以下配置 -Xms512m -Xmx512m 2)vim /config/elasticsearch.yml network.host: 0.0.0.0 http.port: 9200 cluster.name: es_cluster path.data: /tmp/elasticsearch/data path.logs: /tmp/elasticsearch/logs 注:#对应目录下用es用户建立data和logs文件夹 node.name: node-1 bootstrap.memory_lock: false bootstrap.system_call_filter: false cluster.initial_master_nodes: ["node-1"]
#修改虚拟机配置文件
1)vim /etc/security/limits.conf 添加如下内容: * soft nofile 65536 * hard nofile 65536 2)vim /etc/sysctl.conf #添加如下配置信息 vm.max_map_count=262144 3)而且执行命令使前两个配置生效: sysctl -p
#先别着急启动es
此时启动es有可能会爆出如下错误
[es@VM-0-10-centos bin]$ ./elasticsearch warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_211/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set. warning: usage of JAVA_HOME is deprecated, use ES_JAVA_HOME Future versions of Elasticsearch will require Java 11; your Java version from [/usr/local/jdk1.8.0_211/jre] does not meet this requirement. Consider switching to a distribution of Elasticsearch with a bundled JDK. If you are already using a distribution with a bundled JDK, ensure the JAVA_HOME environment variable is not set.
大体意思就是当前JDK版本不符合该版本的es,咱们须要作的就是要么更换本机jdk 匹配当前版本的es,要么使用该版本的自带jdk,咱们选择使用自带的jdk。
在 /bin 下看到了一堆的可执行文件,其中有一个elasticsearch-env vim elasticsearch-env 新增:ES_JAVA_HOME="/home/elk/elasticsearch-7.12.0/jdk/"
#好的,整理心情,启动es(es启动可能会好久,须要耐心等待...)
#elasticsearch经常使用命令 #启动命令 ./elasticsearch #后台启动命令 ./elasticsearch -d #设置开机自启动 systemctl enable elasticsearch.service
#检测是否启动成功
第一种方法:看启动日志
第二种方法:访问你本机的ip http://150.xxx.xxx.xxx:9200/
#安装Elasticsearch-Head
1)nodejs安装
# wget https://nodejs.org/dist/v10.9.0/node-v10.9.0-linux-x64.tar.xz // 下载 # tar xf node-v10.9.0-linux-x64.tar.xz // 解压 # cd node-v10.9.0-linux-x64/ // 进入解压目录 # ./bin/node -v // 执行node命令 查看版本 v10.9.0 2)解压文件的 bin 目录底下包含了 node、npm 等命令,咱们能够使用 ln 命令来设置软链接:
ln -s /usr/software/nodejs/bin/npm /usr/local/bin/ ln -s /usr/software/nodejs/bin/node /usr/local/bin/
3)2)phantomjs安装配置
wget https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
#缺乏bzip2包的同窗记得安装下bzip2
yum -y install bzip2
tar -xvf phantomjs-2.1.1-linux-x86_64.tar.bz2
vim /etc/profile
export PATH=$PATH:/home/elk/phantomjs-2.1.1-linux-x86_64/bin
#注意环境变量$Path移动在最前面
source /etc/profile
4)elasticsearch-head安装(他的主要用处我也没搞清楚,后期再补充进来吧)
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
yum install -y nodejs
npm install -g cnpm --registry=https://registry.npm.taobao.org
#可能时间比较长
5)/elasticsearch-head 目录下执行
npm install
npm run start
#安装完成后 ,访问地址
http://localhost:9200/ es #上面已经访问过了
http://localhost:9100/ es head #访问截图以下,链接刚才的es节点是否健
#解压
tar -zxvf logstash-7.12.0-linux-x86_64.tar.gz
#修改配置文件
cd logstash-7.12.0/config/ vim log4j_to_es.conf #没有改文件的自行建立一下
#文件中插入一下内容
input { stdin { } beats { port => 5000 } tcp { port => 4569 codec => "json" } } output { elasticsearch { action => "index" hosts => "本机ip:9200" index => "%{[appname]}-%{+YYYY-MM}" } stdout { codec=> rubydebug } }
#启动
./bin/logstash -f config/log4j_to_es.conf &
#解压
tar -zxvf kibana-7.12.0-linux-x86_64
#修改Kibana的配置文件
cd kibana-7.12.0-linux-x86_64/config/ vim kibana.yml 修改配置文件以下: # 端口 server.port: 5601 # 指定本机ip让外部能访问 server.host: "0.0.0.0" # 请求数据指向的elasticsearch服务器 elasticsearch.hosts: ["http://ip:9200"]
#启动
sh kibana &
#访问地址:http://ip:5601