SQL数据同步到ELK(二)- Elastic Search 安装

开篇废话

没错,前面扯了一堆SQL SERVER,其实我连Elastic Search根本没动手玩过(是否是与时代有点脱节了?),那今天我就准备尝试安装一个ELK的简单集群出来(这个集群是使用个人小米笔记本建立了两个虚拟机,虚拟出来的一个集群,没钱买阿里云)html

虚拟机的操做系统实CentOS 7 64位,不一样的Linux版本可能略有差别~node

直接安装Elastic Search

安装Master Node

本文也是参考官网文档进行安装,你们能够直接看官网文档,通常来讲,比较新一些。linux

官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started-install.htmlgit

1)找个合适的文件夹下载安装包:github

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0-linux-x86_64.tar.gz

友情提示,若是下载速度比较慢,能够拿迅雷这类软件下载好,上传到服务器,迅雷这类软件在下载这种热门资源的时候,仍是有速度上的提高的。npm

2)解压下载下来的文件bootstrap

本文的版本号均为7.2.0,安装不一样的版本时,灵活应变就行。浏览器

tar -xvf elasticsearch-7.2.0-linux-x86_64.tar.gz

3)修改配置文件服务器

进入解压后的elasticsearch-7.2.0 文件夹中的config文件夹,并修改elasticsearch.yml 文件中的配置:cors

cluster.name: jax-elk-group1
node.name: master
node.master: true
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*"
cluster.initial_master_nodes: ["master"]

此时咱们在elasticsearch-7.2.0文件夹下执行

./bin/elasticsearch

因为我虚拟机内存不够大的缘由,他会抛个异常:

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

对于第一个报错ELK官网是这么解释的:

是因为Elasticsearch须要使用大量的文件描述符或文件句柄,用完文件描述符多是灾难性的,也有可能致使数据丢失,须要确保将运行Elasticsearch的用户能打开文件描述符数量的限制增长到65,536或更高。

官网连接在这里:https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html

官网解决方案的连接:https://www.elastic.co/guide/en/elasticsearch/reference/current/setting-system-settings.html#limits.conf

然而,我照官网作了以后,并无论什么用,最终找到了一篇文章:

http://www.kxtry.com/archives/1635

首先第一个问题,须要修改文件etc/security/limits.conf中的一些配置:

执行命令:

sudo vi /etc/security/limits.conf

像文件最后添加内容:

* soft nofile 65536

* hard nofile 131072 (貌似只添加这句就行)

* soft nproc 2048

* hard nproc 4096

而后退出当前的终端从新链接进入,这步很是重要,不从新进不起做用的~

第二个问题须要修改/etc/sysctl.conf中的一些配置:

执行命令:

sudo vi /etc/sysctl.conf

向文件最后添加记录:

vm.max_map_count=655360

保存并退出后执行命令:

sudo sysctl -p

这步跟上面退出终端从新进入同样重要,不执行这个配置不会生效的。

执行完这两步,而后从新执行就能够启动成功了~

./bin/elasticsearch

能够在新开一个终端执行下面命令来验证安装的成果:

curl http://服务器ip:9200/

此时若是安装的没问题,会打印相似下面的内容:

{
  "name" : "master",
  "cluster_name" : "jax-elk-group1",
  "cluster_uuid" : "NtmpxdwtRQOiT8sv8bJrvg",
  "version" : {
    "number" : "7.2.0",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "508c38a",
    "build_date" : "2019-06-20T15:54:18.811730Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

若是你想在后台启动elastic search进程,那么能够在启动时加个 -d参数:

./bin/elasticsearch –d

到此为止,咱们的Master节点(主节点)就安装完毕了

安装Slave node

接下来,咱们再次来安装一台Slave节点(从节点),而且跟咱们当前的Master节点组成一个Elastic search集群。

Slave节点的大部分步骤和Master节点是同样的,惟一的区别在于elasticsearch.yml 文件中的配置。

cluster.name: jax-elk-group1
node.name: node-01
network.host: 0.0.0.0
http.cors.enabled: true
http.cors.allow-origin: "*" cluster.initial_master_nodes: ["master"]
discovery.zen.ping.unicast.hosts: ["192.168.154.135"]

配置的时候,须要注意如下几点:

  • cluster.name 必定要跟Master节点配置的同样
  • node.name 是一个惟一标识,必定不要跟Master节点配置的同样,各个不一样的Salve也不要重复
  • discovery.zen.ping.unicast.hosts中的IP列表是集群中其余节点的IP地址列表

到这里为止,咱们整个集群都安装完成了

使用ElasticSearch-Head可视化界面

默认咱们只能经过命令行或者Http的方式来操做Elastic Search,elasticsearch-head 则是一款开源的ElasticSearch管理界面,它的项目主页为:https://github.com/mobz/elasticsearch-head

使用起来也很是简单:

  1. 下载他的源码,不论是使用Clone仍是直接使用Github的download zip功能
  2. 执行命令:npm install 还原npm依赖,(依赖于Node.js和npm)
  3. 还原完成后,执行npm start命令启动项目
  4. 浏览器中打开http://localhost:9100/
  5. 修改浏览器中最上方的链接地址(默认是http://localhost:9200

image

该项目能够在任意一台能访问到ElasticSearch的机器上安装,装在你的本地机器也能够哦~

ELK的安装就介绍到这里喽~更多的ELK的知识,还须要多多探索哦~

相关文章
相关标签/搜索