centos7安裝配置ELK

來源:互聯網
上載者:User

centos7安裝配置ELK

1.server端安裝

#安裝elasticsearch

yum install java-1.8.0-openjdk ruby

yum install elasticsearch-2.1.0.rpm

systemctl start elasticsearch

rpm -qc elasticsearch

curl -X GEThttp://localhost:9200/

#安裝redis

yum install redis

mkdir -p /opt/redis

cd /opt/redis

mkdir {db,log,etc}

redis-server /etc/redis.conf & 啟動預設的redis設定檔

#安裝kibana

tar -zxvf kibana-5.0.0-snapshot-linux-x64.tar.gz

mv kibana-5.0.0-snapshot-linux-x64 kibana

cp -R kibana /opt/

vi /etc/systemd/system/kibana.service

[Service]

ExecStart=/opt/kibana/bin/kibana

[Install]

WantedBy=multi-user.target

systemctl start kibana

http://IP:5601

#安裝logstash

yum install logstash-2.1.0-1.noarch.rpm

cd /etc/pki/tls

openssl req -config /etc/pki/tls/openssl.cnf -x509 -days 3650 -batch -nodes -newkey rsa:2048 -keyout private/logstash-forwarder.key -out certs/logstash-forwarder.crt

vi /etc/logstash/conf.d/logstasg-hello.conf

input {

lumberjack {

# The port to listen on

port => 5000

# The paths to your ssl cert and key

ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"

ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"

type => "this forwarder's file have no type!"

}

}

output {

elasticsearch { host => localhost }

stdout { codec => rubydebug }

}

/opt/logstash/bin/logstash -f /etc/logstash/conf.d/logstash-hello.conf

#安裝lnmp環境

yum install nginx php

vi /etc/nginx/conf.d/logstash.conf

server {

listen 80;

server_name IP;

location / {

proxy_pass http://localhost:5601;

proxy_redirect off;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 10m;

client_body_buffer_size 128k;

proxy_connect_timeout 90;

proxy_send_timeout 90;

proxy_read_timeout 90;

proxy_buffer_size 4k;

proxy_buffers 4 32k;

proxy_busy_buffers_size 64k;

proxy_temp_file_write_size 64k;

}

}

systemctl start nginx

2.client端安裝

3.elasticsearch設定檔詳解

cat /etc/elasticsearch裡的logging.yml用預設配置,elasticsearch.yml配置如下:

cluster.name: elasticsearch

配置es的叢集名稱,預設是elasticsearch,es會自動探索在同一網段下的es,如果在同一網段下有多個叢集,就可以用這個屬性來區分不同的叢集。

node.name: "Franz Kafka"

節點名,預設隨機指定一個name列表中名字,該列表在es的jar包中config檔案夾裡name.txt檔案中,其中有很多作者添加的有趣名字。

node.master: true

指定該節點是否有資格被選舉成為node,預設是true,es是預設叢集中的第一台機器為master,如果這台機掛了就會重新選舉master。

node.data: true

指定該節點是否儲存索引資料,預設為true。

index.number_of_shards: 5

設定預設索引分區個數,預設為5片。

index.number_of_replicas: 1

設定預設索引複本個數,預設為1個副本。

path.conf: /path/to/conf

設定設定檔的儲存路徑,預設是es根目錄下的config檔案夾。

path.data: /path/to/data

設定索引資料的儲存路徑,預設是es根目錄下的data檔案夾,可以設定多個儲存路徑,用逗號隔開,例:

path.data: /path/to/data1,/path/to/data2

path.work: /path/to/work

設定臨時檔案的儲存路徑,預設是es根目錄下的work檔案夾。

path.logs: /path/to/logs

設定記錄檔的儲存路徑,預設是es根目錄下的logs檔案夾

path.plugins: /path/to/plugins

設定外掛程式的存放路徑,預設是es根目錄下的plugins檔案夾

bootstrap.mlockall: true

設定為true來鎖住記憶體。因為當jvm開始swapping時es的效率 會降低,所以要保證它不swap,可以把ES_MIN_MEM和ES_MAX_MEM兩個環境變數設定成同一個值,並且保證機器有足夠的記憶體配置給es。 同時也要允許elasticsearch的進程可以鎖住記憶體,linux下可以通過`ulimit -l unlimited`命令。

network.bind_host: 192.168.0.1

設定綁定的ip地址,可以是ipv4或ipv6的,預設為0.0.0.0。

network.publish_host: 192.168.0.1

設定其它節點和該節點互動的ip地址,如果不設定它會自動判斷,值必須是個真實的ip地址。

network.host: 192.168.0.1

這個參數是用來同時設定bind_host和publish_host上面兩個參數。

transport.tcp.port: 9300

設定節點間互動的tcp連接埠,預設是9300。

transport.tcp.compress: true

設定是否壓縮tcp傳輸時的資料,預設為false,不壓縮。

http.port: 9200

設定對外服務的http連接埠,預設為9200。

http.max_content_length: 100mb

設定內容的最大容量,預設100mb

http.enabled: false

是否使用http協議對外提供服務,預設為true,開啟。

gateway.type: local

gateway的類型,預設為local即為本地檔案系統,可以設定為本地檔案系統,Distributed File System,hadoop的HDFS,和amazon的s3伺服器,其它檔案系統的設定方法下次再詳細說。

gateway.recover_after_nodes: 1

設定叢集中N個節點啟動時進行資料恢複,預設為1。

gateway.recover_after_time: 5m

設定初始化資料恢複進程的逾時時間,預設是5分鐘。

gateway.expected_nodes: 2

設定這個叢集中節點的數量,預設為2,一旦這N個節點啟動,就會立即進行資料恢複。

cluster.routing.allocation.node_initial_primaries_recoveries: 4

初始化資料恢複時,並發恢複線程的個數,預設為4。

cluster.routing.allocation.node_concurrent_recoveries: 2

添加刪除節點或負載平衡時並發恢複線程的個數,預設為4。

indices.recovery.max_size_per_sec: 0

設定資料恢複時限制的頻寬,如入100mb,預設為0,即無限制。

indices.recovery.concurrent_streams: 5

設定這個參數來限制從其它分區恢複資料時最大同時開啟並發流的個數,預設為5。

discovery.zen.minimum_master_nodes: 1

設定這個參數來保證叢集中的節點可以知道其它N個有master資格的節點。預設為1,對於大的叢集來說,可以設定大一點的值(2-4)

discovery.zen.ping.timeout: 3s

設定叢集中自動探索其它節點時ping連線逾時時間,預設為3秒,對於比較差的網路環境可以高點的值來防止自動探索時出錯。

discovery.zen.ping.multicast.enabled: false

設定是否開啟多點傳送探索節點,預設是true。

discovery.zen.ping.unicast.hosts: ["host1", "host2:port", "host3[portX-portY]"]

設定叢集中master節點的初始列表,可以通過這些節點來自動探索新加入叢集的節點。

下面是一些查詢時的慢日誌參數設定

index.search.slowlog.level: TRACE

index.search.slowlog.threshold.query.warn: 10s

index.search.slowlog.threshold.query.info: 5s

index.search.slowlog.threshold.query.debug: 2s

index.search.slowlog.threshold.query.trace: 500ms

index.search.slowlog.threshold.fetch.warn: 1s

index.search.slowlog.threshold.fetch.info: 800ms

index.search.slowlog.threshold.fetch.debug:500ms

index.search.slowlog.threshold.fetch.trace: 200ms

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.