温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

ELKstack-Elasticsearch各类安装部署方法

发布时间:2020-07-21 16:25:13 来源:网络 阅读:771 作者:vekergu 栏目:开发技术

手动安装部署Elasticsearch

开篇

开篇闲话,如果是新人在接触ELKstack什么都不懂的情况下,可以先看看各位前人写的关于ELKstack的博客,如何对ELKstack部署安装及使用,但是别人的东西只能作为借鉴,在自己搭建使用一定要以官方文档为准。

一定要注意软件版本,这里系统集合类软件,如果各软件版本不一致,会造成不可预估的后果!!!

资源列表

官方文档: https://www.elastic.co/products/elasticsearch

elasticsearsh权威指南: http://es.xiaoleilu.com/

kibana中文指南: http://kibana.logstash.es/content/

部署

打开官网-->访问docs

ELKstack-Elasticsearch各类安装部署方法

我们以最新版本2.3来进行引导

ELKstack-Elasticsearch各类安装部署方法

ELKstack-Elasticsearch各类安装部署方法

下载方式安装

Installation

设置java环境

java -version

echo $JAVA_HOME

下载elasticsearch压缩包

curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.3/elasticsearch-2.3.3.tar.gz

解压压缩包,解压后可以直接使用

tar -xvf elasticsearch-2.3.3.tar.gz

cd elasticsearch-2.3.3/bin

启动elasticsearch

./elasticsearch

启动信息:

./elasticsearch

[2014-03-13 13:42:17,218][INFO ][node ] [New Goblin] version[2.3.3], pid[2085], build[5c03844/2014-02-25T15:52:53Z]

[2014-03-13 13:42:17,219][INFO ][node ] [New Goblin] initializing ...

[2014-03-13 13:42:17,223][INFO ][plugins ] [New Goblin] loaded [], sites []

[2014-03-13 13:42:19,831][INFO ][node ] [New Goblin] initialized

[2014-03-13 13:42:19,832][INFO ][node ] [New Goblin] starting ...

[2014-03-13 13:42:19,958][INFO ][transport ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.8.112:9300]}

[2014-03-13 13:42:23,030][INFO ][cluster.service] [New Goblin] new_master [New Goblin][rWMtGj3dQouz2r6ZFL9v4g][mwubuntu1][inet[/192.168.8.112:9300]], reason: zen-disco-join (elected_as_master)

[2014-03-13 13:42:23,100][INFO ][discovery ] [New Goblin] elasticsearch/rWMtGj3dQouz2r6ZFL9v4g

[2014-03-13 13:42:23,125][INFO ][http ] [New Goblin] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.8.112:9200]}

[2014-03-13 13:42:23,629][INFO ][gateway ] [New Goblin] recovered [1] indices into cluster_state

[2014-03-13 13:42:23,630][INFO ][node ] [New Goblin] started

设置集群名和节点名

./elasticsearch --cluster.name my_cluster_name --node.name my_node_name

yum方式安装

ELKstack-Elasticsearch各类安装部署方法

安装GPG验证KEY

rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

把下面的源配置加入到 /etc/yum.repos.d/目录中的 a.repo文件里, 可以起名为:elasticsearch.repo

怎么配elasticsearchrepo源,我想中级以上的小伙伴都会

[elasticsearch-2.x]

name=Elasticsearch repository for 2.x packages

baseurl=https://packages.elastic.co/elasticsearch/2.x/centos

gpgcheck=1

gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch

enabled=1

yum安装即可

yum install elasticsearch

基于salt自动化安装elasticsearch

此处只是分享下salt安装elasticsearch的模板,写的比较粗糙,也是刚开始写,很多自定义配置未加入到模板中,后面会逐步改进,内容里不会涉及新手的入门知识,此类入门知识会逐步在salt模块进行分享。

配置state目录

file_roots:

base_init:

- /etc/salt/states

配置top.sls

[root@sz-a-saltstack-xen states]# cat /etc/salt/states/top.sls

'*':

- init.yum_config

- init.selinux_shutdown

- init.limit

- init.sshd_config

- init.clock_config

- init.ntp_config

- init.user_config

- init.salt_minion_config

- init.tty_init

- init.zabbix_agent

'sz-a-qhfaxes0[1,3]-es-hw':

- jdk

- elkstack.es

配置elkstack 目录es.sls

elasticsearch-2:

pkgrepo.managed:

- humanname: Elasticsearch repository for 2.x packages

- baseurl: https://packages.elastic.co/elasticsearch/2.x/centos

- gpgcheck: 1

- gpgkey: https://packages.elastic.co/GPG-KEY-elasticsearch

elasticsearch-server:

pkg.installed:

- pkgs:

- elasticsearch

- git

- openssl.x86_64

- openssl-devel.x86_64

/etc/elasticsearch/elasticsearch.yml:

file.managed:

- source: salt://elkstack/files/elasticsearch.yml

- template: jinja

- user: elasticsearch

- group: elasticsearch

- require:

- pkg: elasticsearch-server

/data/qhfax_elckstack:

file.directory:

- user: elasticsearch

- group: elasticsearch

- makedirs: True

elasticsearch_log_path:

file.directory:

- name: /var/log/elasticsearch

- user: elasticsearch

- group: elasticsearch

- makedirs: True

elasticsearch:

service.running:

- enable: True

- watch:

- pkg: elasticsearch-server

- file: /etc/elasticsearch/elasticsearch.yml

service_plugins_install:

file.directory:

- name: /root/soft

- makedirs: True

cmd.run:

- cwd: /root/soft

- name: git clone https://github.com/elasticsearch/elasticsearch-servicewrapper.git && ls

- unless: test -d /root/soft/elasticsearch-servicewrapper

mv_service_es:

cmd.run:

- cwd: /root/soft

- name: cp -a elasticsearch-servicewrapper/service/ /usr/share/elasticsearch/bin

- unless:

- test -d /usr/share/elasticsearch/bin/service

- test -d elasticsearch-servicewrapper/service || echo False

head_plugins_install:

cmd.run:

- cwd: /usr/share/elasticsearch/bin

- name: /usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head

- unless: test -d /usr/share/elasticsearch/plugins/head

license_plugins_install:

cmd.run:

- cwd: /usr/share/elasticsearch/bin

- name: /usr/share/elasticsearch/bin/plugin install license

- unless:

- test -d /usr/share/elasticsearch/plugins/license

marvel_plugins_install:

cmd.run:

- cwd: /usr/share/elasticsearch/bin

- name: /usr/share/elasticsearch/bin/plugin install marvel-agent

- unless:

- test -d /usr/share/elasticsearch/plugins/marvel-agent

上文sls模板存在问题:

1. 没有很好的使用到各类自定义和动态参数

2. 没有进行分层

我考虑应该使用一个应用的生命周期来进行分层,服务器始终保持无状态

安装前预环境 --> 安装 --> 升级

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI