k8s efk mysql慢日志例子
应用部署文件apiVersion: extensions/v1beta1kind: Deploymentmetadata:name: alpacalabels:app: alpacaspec:replicas: 1template:metadata:labels:app: alpacaspec:...
发布一个k8s部署视频:https://edu.csdn.net/course/detail/26967
课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。
腾讯课堂连接地址https://ke.qq.com/course/478827?taid=4373109931462251&tuin=ba64518
第二个视频发布 https://edu.csdn.net/course/detail/27109
腾讯课堂连接地址https://ke.qq.com/course/484107?tuin=ba64518
介绍主要的k8s资源的使用配置和命令。包括configmap,pod,service,replicaset,namespace,deployment,daemonset,ingress,pv,pvc,sc,role,rolebinding,clusterrole,clusterrolebinding,secret,serviceaccount,statefulset,job,cronjob,podDisruptionbudget,podSecurityPolicy,networkPolicy,resourceQuota,limitrange,endpoint,event,conponentstatus,node,apiservice,controllerRevision等。
第三个视频发布:https://edu.csdn.net/course/detail/27574
详细介绍helm命令,学习helm chart语法,编写helm chart。深入分析各项目源码,学习编写helm插件
————————————————
应用部署文件
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: alpaca
labels:
app: alpaca
spec:
replicas: 1
template:
metadata:
labels:
app: alpaca
spec:
terminationGracePeriodSeconds: 60
nodeSelector:
deploy: app
containers:
- name: alpaca
image: 192.168.1.225:5000/mysql:5.7-youben
imagePullPolicy: Always
readinessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 60
timeoutSeconds: 5
livenessProbe:
tcpSocket:
port: 3306
initialDelaySeconds: 60
timeoutSeconds: 5
env:
- name: MYSQL_ROOT_PASSWORD
value: root
ports:
- containerPort: 3306
name: tcp
volumeMounts:
- name: alpaca
mountPath: /var/lib/mysql
- name: fluentd-es
image: 192.168.1.225:5000/fluentd-elasticsearch:v2.0.4-youben
imagePullPolicy: Always
command: ["/bin/sh"]
args: ["-c", "/run.sh $FLUENTD_ARGS"]
env:
- name: FLUENTD_ARGS
value: --no-supervisor -q
volumeMounts:
- name: config-volume
mountPath: /etc/fluent/config.d
- name: alpaca
mountPath: /var/lib/mysql
volumes:
- name: alpaca
persistentVolumeClaim:
claimName: pvc-alpaca-withlog
- name: config-volume
configMap:
name: fluentd-es-config-mysql-alpaca
---
apiVersion: v1
kind: Service
metadata:
name: alpaca
labels:
app: alpaca
spec:
ports:
- port: 3306
targetPort: 3306
selector:
app: alpaca
配置文件:
kind: ConfigMap
apiVersion: v1
metadata:
name: fluentd-es-config-mysql-alpaca
labels:
addonmanager.kubernetes.io/mode: Reconcile
data:
system.conf: |-
<system>
root_dir /tmp/fluentd-buffers/
</system>
input.conf: |-
<source>
@type mysql_slow_query
path /var/lib/mysql/slow_query.log
pos_file /root/mysql.log.slow.pos
tag mysql.alpaca.slow.query
<parse>
@type none
</parse>
</source>
<source>
@id mysql.error.log
@type tail
path /var/log/mysql/error.log
format multiline
format_firstline /^\d{6} \d\d:\d\d:\d\d/
format1 /(?<time>\d{6} \d\d:\d\d:\d\d) (?<error_msg>.*)/
time_format %y%m%d %H:%M:%S
pos_file /root/mysql.log.error.pos
tag mysql.alpaca.error
</source>
output.conf: |-
<match mysql.alpaca.slow.query>
@id elasticsearch.slow
@type elasticsearch
@log_level info
include_tag_key true
host elasticsearch-logging.kube-system.svc.cluster.local
port 9200
logstash_format true
logstash_prefix docker.mysql.slow
logstash_dateformat %Y-%m-%d
type_name docker_mysql_alpaca_log_slow
<buffer>
@type file
path /var/log/fluentd-buffers/kubernetes.system.buffer.slow
flush_mode interval
retry_type exponential_backoff
flush_thread_count 2
flush_interval 5s
retry_forever
retry_max_interval 30
chunk_limit_size 2M
queue_limit_length 8
overflow_action block
</buffer>
</match>
<match mysql.alpaca.error>
@id elasticsearch.error
@type elasticsearch
@log_level info
include_tag_key true
host elasticsearch-logging.kube-system.svc.cluster.local
port 9200
logstash_format true
logstash_prefix docker.mysql.error
logstash_dateformat %Y-%m-%d
type_name docker_mysql_alpaca_log_error
<buffer>
@type file
path /var/log/fluentd-buffers/kubernetes.system.buffer.error
flush_mode interval
retry_type exponential_backoff
flush_thread_count 2
flush_interval 5s
retry_forever
retry_max_interval 30
chunk_limit_size 2M
queue_limit_length 8
overflow_action block
</buffer>
</match>
记得装上mysql慢日志插件
已经打包好插件:https://github.com/13567436138/kubernetes-yamls/tree/master/docker
更多推荐
所有评论(0)