VSE PO PORYADKU
(from: http://itc-life.ru/fluentd-bystryj-poisk-logov-s-elasticsearch-kibana-and-fluentd/
)
$ `sudo wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.3.1/elasticsearch-2.3.1.deb`
$ `sudo dpkg -i elasticsearch-2.3.1.deb`
Since this tutorial sets up the Kibana dashboard to be accessed from the public Internet, let's disable dynamic scripting by appending the following line at the end of /etc/elasticsearch/elasticsearch.yml
:
(from: https://www.digitalocean.com/community/tutorials/elasticsearch-fluentd-and-kibana-open-source-log-search-and-visualization
)
`script.disable_dynamic: true`
!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ВАЖНО!!!!!!!! => script.disable_dynamic: true
НЕ вставлять (с ним не работает сервис почему-то)
$ `sudo update-rc.d elasticsearch defaults 95 10`
$ `sudo /bin/systemctl daemon-reload`
$ `sud /bin/systemctl enable elasticsearch.service`
$ `sudo systemctl start elasticsearch.service`
$ `sudo service elasticsearch stop`
$ `sudo service elasticsearch start`
$ `sudo service elasticsearch status`
$ `sudo nano /etc/elasticsearch/elasticsearch.yml`
`network.host: 51.1.0.15`
`http.port: 9200`
(from: http://itc-life.ru/fluentd-bystryj-poisk-logov-s-elasticsearch-kibana-and-fluentd/
)
$ `sudo wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -`
$ `echo "deb http://packages.elastic.co/kibana/4.5/debian stable main" | sudo tee -a /etc/apt/sources.list`
$ `sudo apt-get update`
$ `sudo apt-get -y install kibana`
$ `sudo update-rc.d kibana defaults 95 10`
$ `sudo /bin/systemctl daemon-reload`
$ `sudo /bin/systemctl enable kibana.service`
$ `sudo nano /opt/kibana/config/kibana.yml`
Укажем ip, на котором будет сидеть Kibana. Можете указать свой ип в сети(для этого поставим 0.0.0.0). Так же укажем url elasticsearch.
`server.port: 5601`
`server.host: "0.0.0.0"`
`elasticsearch.url: "http://localhost:9200"`
$ `curl -XPUT 'http://localhost:9200/kibana/' -d '{"index.mapper.dynamic": true}'`
$ `sudo service kibana restart`
`http://localhost:5601`
(from: http://itc-life.ru/fluentd-bystryj-poisk-logov-s-elasticsearch-kibana-and-fluentd
)
(from: http://www.fluentd.org/guides/recipes/elasticsearch-and-s3
)
$ `curl -L http://toolbelt.treasuredata.com/sh/install-ubuntu-precise-td-agent2.sh | sh`
Next, install the Elasticsearch plugin (to store data into Elasticsearch) and the secure-forward plugin (for secure communication with the node server)
$ `sudo /usr/sbin/td-agent-gem install fluent-plugin-secure-forward`
$ `sudo /usr/sbin/td-agent-gem install fluent-plugin-elasticsearch`
$ `sudo nano /etc/td-agent/td-agent.conf`
```ruby
# Listen to incoming data over SSL
<source>
type forward
shared_key 911
self_hostname 51.1.0.15
cert_auto_generate yes
</source>
# Store Data in Elasticsearch
<match *.**>
type copy
<store>
type elasticsearch
host localhost
port 9200
include_tag_key true
tag_key @log_name
logstash_format true
flush_interval 10s
</store>
</match>
```
$ `sudo service td-agent restart`
$ `systemctl status td-agent.service`
$ `journalctl -xe`
$ `sudo apt-get install iptables-persistent -y`
$ `sudo /sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 42185 -j ACCEPT`
$ `sudo /sbin/iptables -A INPUT -i eth0 -p udp --destination-port 42185 -j ACCEPT`
`eth0` в коде выше заменяем на `enp3s0` (в моем случае) - это `network_interface`
для того, чтобы понять на что заменять надо ввести команду
$ `ifconfig`
вывод: ```ruby
enp3s0 Link encap:Ethernet HWaddr fc:aa:14:0d:9f:d6
...
RX bytes:837639863 (837.6 MB) TX bytes:79243706 (79.2 MB)
```
либо:
$ route |grep default |awk ' {print $8} '
вывод:
enp3s0
либо мы можем писать команды так:
$ `sudo /sbin/iptables -A INPUT -i $(route |grep default |awk ' {print $8} ') -p tcp --destination-port 42185 -j ACCEPT`
$ `sudo /sbin/iptables -A INPUT -i $(route |grep default |awk ' {print $8} ') -p udp --destination-port 42185 -j ACCEPT`
для этого заходим под суперюзером
$ `su -` или $ `sudo su -`
далее:
$ `iptables-save > /etc/iptables/rules.v4`
$ `sudo apt-get install rsyslog curl -y`
$ `sudo nano /etc/rsyslog.conf`
Добавим строку, она означает, что rsyslog будет отправлять данные на порт 42185, его будет слушать td-agent(fluentd)
`*.* @127.0.0.1:42185`
$ `sudo systemctl unmask rsyslog.service`
$ `sudo service rsyslog restart`
$ `curl -L http://toolbelt.treasuredata.com/sh/install-ubuntu-precise-td-agent2.sh | sh`
$ `sudo nano /etc/td-agent/td-agent.conf`
```ruby
# Listen to Syslog
<source>
type syslog
port 42185
tag system
</source>
# Ship data to the aggregator
<match *.**>
type forward
shared_key 911
self_hostname 51.0.15.1 (ip нода)
<server>
host 51.1.0.15
</server>
</match>
```
$ `sudo service td-agent restart`
$ `sudo service td-agent restart`
$ `sudo service elasticsearch restart`
$ `sudo service kibana restart`
`http://localhost:5601`
и выбираем там во вкладке Settings
-> Indices
index name of pattern logstash-*
или что-то другое, я еще не разобрался с индексами, передаваемыми в elasticsearch