使用Docker和K8s搭建ELK日志收集系统

  环境查看

# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
[root@localhost elasticsearch]# uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost elasticsearch]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 1
  Paused: 0
  Stopped: 0
 Images: 5
 Server Version: 19.03.8
 Storage Driver: overlay2
  Backing Filesystem: <unknown>
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-862.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 5.67GiB
 Name: localhost.localdomain
 ID: PGGH:4IF4:TXUV:3CSM:LZZY:KVTA:FONM:WJIO:KVME:YYJJ:55IZ:WR7Q
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  192.168.1.11
  192.168.1.61
  127.0.0.0/8
 Registry Mirrors:
  https://7sl94zzz.mirror.aliyuncs.com/
 Live Restore Enabled: false

  使用Docker搭建ELK日志收集系统

  搭建单机日志收集系统

  下载镜像

  下载elasticsearch和kibana镜像

docker pull docker.elastic.co/elasticsearch/elasticsearch:6.6.2
docker pull docker.elastic.co/kibana/kibana:6.6.2

   设置elasticsearch配置文件

# cat elasticsearch.yml 
cluster.name: myes            
#node.name: node-1            
path.data: /usr/share/elasticsearch/data
#path.logs: /var/log/elasticsearch     
bootstrap.memory_lock: false
network.host: 0.0.0.0          
http.port: 9200

   启动elasticsearch

docker run -d --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -v /nas/nas/scripts/docker_es_kibana/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml -v /usr/share/elasticsearch/data:/usr/share/elasticsearch/data docker.elastic.co/elasticsearch/elasticsearch:6.6.2

   参数解析

docker run -d #后台启动
--name elasticsearch #容器命名
-p 9200:9200 -p 9300:9300 #映射到主机的端口
-e "discovery.type=single-node" #设置环境为单node模式
-v /nas/nas/scripts/docker_es_kibana/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml #挂载配置文件
-v /usr/share/elasticsearch/data:/usr/share/elasticsearch/data#挂载数据目录 docker.elastic.co/elasticsearch/elasticsearch:6.6.2#使用镜像启动

猜你喜欢

转载自www.cnblogs.com/minseo/p/12956563.html