Docker builds elk log monitoring system from scratch

1. Install docker

2. Install docker-compose

3. Install nginx

取最新版的 Nginx 镜像 docker pull nginx:latest
运行容器 docker run --name nginx-test -p 8080:80 -d nginx

The relevant locations in the container (disk/var/lib/docker/overlay2) are:
log location: /var/log/nginx/
configuration file location: /etc/nginx/
project location:/usr/share/nginx/html

4. Install jdk and tomcat

docker pull openjdk

docker pull tomcat

Run container

docker run --name tomcat -p 8080:8080 -v $PWD/test:/usr/local/tomcat/webapps/test -d tomcat

-p 8080:8080: Maps the container's 8080 port to the host's 8080 port.

-v $PWD/test:/usr/local/tomcat/webapps/test: Mount test in the current directory on the host to /test in the container.

4. Install elk

mkdir /docker

Pull the information required to deploy elk from github

git clone https://github.com/deviantony/docker-elk.git

cd docker-elk
通过docker-compose创建并启动容器
docker-compose up -d
可以看该elk容器的默认端口为:
5000: Logstash TCP input.
9200: Elasticsearch HTTP
9300: Elasticsearch TCP transport
5601: Kibana
Kibana的web入口:http://localhost:5601
Elasticsearch 的web入口:http://localhost:9200

修改配置文件

vim /root/docker/docker-elk/elasticsearch/config/elasticsearch.yml

vim /root/docker/docker-elk/kibana/config/kibana.yml

vim /root/docker/docker-elk/logstash/config/logstash.yml

Restart docker-compose start/restart/up

5. Configure nginx log

Install nginx

Start nginx

/usr/local/src/nginx/sbin

./nginx

Download and install Filebeat

curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.6.2-x86_64.rpm sudo rpm -vi filebeat-7.6.2-x86_64.rpm

Edit configuration

Modify  /etc/filebeat/filebeat.yml to set connection information:

vim  /etc/filebeat/filebeat.yml 

 

Enable and configure nginx module

sudo filebeat modules enable nginx

/etc/filebeat/modules.d/nginx.yml Modify settings in the file

Configure nginx log file location

Start Filebeat

setup command loads the Kibana dashboard. If the dashboard is already set up, omit this command.

sudo filebeat setup
sudo service filebeat start

Guess you like

Origin blog.csdn.net/weixin_36416680/article/details/106404827