1 --- ELFKログ・プラットフォーム・アーキテクチャ設計をはじめ
ELFKログエントリプラットフォーム2 --- Elasticseachクラスタのセットアップ
3 --- Kibanaを構築するためのELFKログエントリプラットフォーム
ELFKログエントリプラットフォーム4 ---カフカクラスタのセットアップ
エントリー-5 --- Logstash + Filebeatクラスタセットアップ用ELFKログプラットフォーム
この章では、我々はビルドに次のクラスタとビルドElasticseach Elasticseachヘッドをご紹介します。
1、環境の準備
注:以下のオペレーティングシステムでは、一例でありcentos7 +
リソース・プランニング:
環境設定(すべてのサーバー設定):
- ファイアウォールとSELinuxオフすべてのターン:
# systemctl stop firewalld && systemctl disable firewalld
# sed -i 's/=enforcing/=disabled/g' /etc/selinux/config && setenforce 0
- 最大ファイル記述子の制限を変更するには:
# vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
- アクセス権は、メモリー・サイズを変更します。
# vim /etc/sysctl.conf
vm.max_map_count=655360
# sysctl -p
- Java環境をインストールします。
# yum install -y java-1.8.0-openjdk*
2、Elasticsearchクラスタの展開
- アップロードELKF、カフカ関連するインストールパッケージのディレクトリ:/アプリ/ヘラジカ(カスタマイズ可能):
[root@iZuf6dxdji7ys1e6mfapcfZ elk]# ls
elasticsearch-6.2.4.tar.gz filebeat-6.2.4-linux-x86_64.tar.gz kibana-6.2.4-linux-x86_64.tar.gz node-v8.11.3-linux-x64.tar.xz
elasticsearch-head-master.zip kafka_2.11-1.0.0.tgz logstash-6.2.4.tar.gz phantomjs-2.1.1-linux-x86_64.tar.bz2
[root@iZuf6dxdji7ys1e6mfapcfZ elk]# pwd
/app/elk
- ユーザーヘラジカを作成します。
# useradd elk
- インストールElasticsearch:
# cd /app/elk
# tar zxf elasticsearch-6.2.4.tar.gz && mv elasticsearch-6.2.4 /usr/local/elasticsearch
# mkdir /usr/local/elasticsearch/data
# chown -R elk:elk /usr/local/elasticsearch
- Elasticsearchの設定を変更します。
# vim /usr/local/elasticsearch/config/elasticsearch.yml
cluster.name: elk #集群名,同一集群必须相同
node.name: elk-0 #指定节点主机名(注:每台主机不同)
node.master: true #允许成为主节点
node.data: true #允许成为数据节点
path.data: /usr/local/elasticsearch/data #数据存放路径
path.logs: /usr/local/elasticsearch/logs #日志路径
bootstrap.memory_lock: false #关闭锁定内存,设置为true会报错
network.host: 192.168.0.0 #监听ip(注:每台主机不同)
http.port: 9200 #http端口
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["192.168.0.0", "192.168.0.1", "192.168.0.2"] #初始主机列表
discovery.zen.minimum_master_nodes: 2 # n/2+1
http.enabled: true #使用http协议对外提供服务
http.cors.enabled: true #允许head插件访问es
http.cors.allow-origin: "*" #跨域解决
ここでは、問題が発生したbootstrap.memory_lock:真:
# vim /etc/security/limits.conf
baoshan soft memlock unlimited
baoshan hard memlock unlimited
# vim /etc/sysctl.conf
vm.swappiness=0
# reboot
- スタートElasticsearch:
# su - elk -c "/usr/local/elasticsearch/bin/elasticsearch -d"
# tail -f /usr/local/elasticsearch/logs/elk.log #查看日志,是否正常启动
- ビューElasticsearchクラスタの健康状態:
# curl '192.168.0.0:9200/_cluster/health?pretty'
{
"cluster_name" : "elk",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
# curl '192.168.0.1:9200/_cluster/health?pretty'
# curl '192.168.0.2:9200/_cluster/health?pretty' #返回结果与上面一致则成功
- 設定Elasticsearchサービス:
# vim /etc/sysconfig/elasticsearch
################################
# Elasticsearch
################################
# Elasticsearch home directory
#ES_HOME=/usr/share/elasticsearch
ES_HOME=/usr/local/elasticsearch
# Elasticsearch Java path
#JAVA_HOME=
JAVA_HOME=/usr/local/jdk
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib
# Elasticsearch configuration directory
#ES_PATH_CONF=/etc/elasticsearch
ES_PATH_CONF=/usr/local/elasticsearch/config
# Elasticsearch PID directory
#PID_DIR=/var/run/elasticsearch
PID_DIR=/usr/local/elasticsearch/run
# Additional Java OPTS
#ES_JAVA_OPTS=
# Configure restart on package upgrade (true, every other setting will lead to not restarting)
#RESTART_ON_UPGRADE=true
################################
# Elasticsearch service
################################
# SysV init.d
#
# The number of seconds to wait before checking if Elasticsearch started successfully as a daemon process
ES_STARTUP_SLEEP_TIME=5
################################
# System properties
################################
# Specifies the maximum file descriptor number that can be opened by this process
# When using Systemd, this setting is ignored and the LimitNOFILE defined in
# /usr/lib/systemd/system/elasticsearch.service takes precedence
#MAX_OPEN_FILES=65535
# The maximum number of bytes of memory that may be locked into RAM
# Set to "unlimited" if you use the 'bootstrap.memory_lock: true' option
# in elasticsearch.yml.
# When using systemd, LimitMEMLOCK must be set in a unit file such as
# /etc/systemd/system/elasticsearch.service.d/override.conf.
#MAX_LOCKED_MEMORY=unlimited
# Maximum number of VMA (Virtual Memory Areas) a process can own
# When using Systemd, this setting is ignored and the 'vm.max_map_count'
# property is set at boot time in /usr/lib/sysctl.d/elasticsearch.conf
#MAX_MAP_COUNT=262144
サービス設定ファイル:
# vim /usr/lib/systemd/system/elasticsearch.service
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
RuntimeDirectory=elasticsearch
PrivateTmp=true
Environment=ES_HOME=/usr/local/elasticsearch
Environment=ES_PATH_CONF=/usr/local/elasticsearch/config
Environment=PID_DIR=/usr/local/elasticsearch/run
EnvironmentFile=-/etc/sysconfig/elasticsearch
WorkingDirectory=/usr/local/elasticsearch
User=elk
Group=elk
ExecStart=/usr/local/elasticsearch/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet
# StandardOutput is configured to redirect to journalctl since
# some error messages may be logged in standard output before
# elasticsearch logging system is initialized. Elasticsearch
# stores its logs in /var/log/elasticsearch and does not use
# journalctl by default. If you also want to enable journalctl
# logging, you can simply remove the "quiet" option from ExecStart.
StandardOutput=journal
StandardError=inherit
# Specifies the maximum file descriptor number that can be opened by this process
LimitNOFILE=65535
# Specifies the maximum number of processes
LimitNPROC=4096
# Specifies the maximum size of virtual memory
LimitAS=infinity
# Specifies the maximum file size
LimitFSIZE=infinity
# Disable timeout logic and wait until process is stopped
TimeoutStopSec=0
# SIGTERM signal is used to stop the Java process
KillSignal=SIGTERM
# Send the signal only to the JVM rather than its control group
KillMode=process
# Java process is never killed
SendSIGKILL=no
# When a JVM receives a SIGTERM signal it exits with code 143
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
# Built for packages-6.7.1 (packages)
管理サービス:
# chmod +x /usr/lib/systemd/system/elasticsearch.service
# mkdir /usr/local/elasticsearch/run
# touch /usr/local/elasticsearch/run/elasticsearch.pid && chown -R elk:elk /usr/local/elasticsearch
# systemctl daemon-reload
# systemctl enable elasticsearch
# systemctl start elasticsearch #先kill之前的elasticsearch进程
# yum install -y bash-completion && source /etc/profile #命令自动补全
2、Elasticsearchヘッド部署
Ealsticsearchちょうどバックエンドはどのように直感的に使用それので、さまざまなAPIを提供しますか?ElasticsearchヘッドはElasticsearchクライアントツールに固有のものです。以下は、インストールプロセスを説明します。
- Elasticsearchヘッドは、Node.jsの開発者であるので、Node.jsのをインストールする必要があります。
# cd /app/elk
# tar -Jxf node-v8.11.3-linux-x64.tar.xz && mvnode-v8.11.3-linux-x64/ /usr/local/node
# vim /etc/profile
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
export NODE_PATH=$NODE_HOME/lib/node_modules:$PATH
# source /etc/profile
# node -v
v8.11.3 #出现node版本即为成功
- 関連するプラグインをインストールします。
# cd /app/elk
# unzip elasticsearch-head-master.zip && mv elasticsearch-head-master/ /usr/local/elasticsearch-head
# npm install -g cnpm --registry=https://registry.npm.taobao.org
# cnpm install -g grunt-cli
# cnpm install -g grunt
# cnpm install grunt-contrib-clean
# cnpm install grunt-contrib-concat
# cnpm install grunt-contrib-watch
# cnpm install grunt-contrib-connect
# cnpm install grunt-contrib-copy
# cnpm install grunt-contrib-jasmine #若报错就再执行一遍
- 環境設定:
# vim /usr/local/elasticsearch-head/Gruntfile.js
connect: {
server: {
options: {
hostname: '0.0.0.0', #增加hostname
port: 9100,
base: '.',
keepalive: true
}
}
}
- スタートElasticsearchヘッド:
# cd /usr/local/elasticsearch-head
# nohup grunt server &
- ブラウザのアクセス(インデックスなしのデータを作成していません)。
これまでのところ、Elasticsearchクラスタが完了し、後ろの建物は、関連するコンポーネントを導入し続ける設定されています。