k8s mysql cluster

install

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
─❯ helm install -f ./mysql-operator/values.yaml -name mysql-operator --namespace mysql-operator  --create-namespace  ./mysql-operator



❯ helm install mycluster ./mysql-innodbcluster \
--namespace mysql-operator \
--set tls.useSelfSigned=true \
--set credentials.root.user='root' \
--set credentials.root.password='cs@123456' \
--set credentials.root.host='%' \
--set serverInstances=3 \
--set routerInstances=1



❯ helm uninstall -name mycluster --namespace mysql-operator
release "mycluster" uninstalled
❯ helm uninstall -name mysql-operator --namespace mysql-operator
release "mysql-operator" uninstalled

❯ kubectl logs mysql-operator-9d99d7fb4-slm2p -n mysql-operator
2023-08-31 10:45:24: Info: mysqlsh Ver 8.1.0 for Linux on x86_64 - for MySQL 8.1.0 (MySQL Community Server (GPL)) - build 11806291 - commit_id aa072a78647c21a540e40b8bdd04420e6efbe677
2023-08-31 10:45:24: Info: Using credential store helper: /usr/bin/mysql-secret-store-login-path
2023-08-31 10:45:24: Info: Loading startup files…
2023-08-31 10:45:24: Info: Loading plugins…
[2023-08-31 10:45:26,726] root [WARNING ] Failed to detect cluster domain. Reason: [Errno 2] Host name lookup failure
….
[2023-08-31 10:45:54,977] root [WARNING ] Failed to detect cluster domain. Reason: [Errno 2] Host name lookup failure
[2023-08-31 10:45:56,979] root [ERROR ] Failed to automatically identify the cluster domain. If this
persists try setting MYSQL_OPERATOR_K8S_CLUSTER_DOMAIN via environment.

kafka介绍

基础架构

producer 生产者,消息产生

broker 实例对应服务器的节点,每个cluster集群内的broker都有不重复的编号

topic 消息主题,分类

partition topic的分区,用作负载,提高吞吐量,对应的是一个个文件

replication 分区副本,作用是备份,主leader故障,follower进行选主,副本数不大于broker数,主备不在同一个机器,同一机器对同一分区也只放一个副本

dnsmasq

配置

四行的含义:

resolv-file:从文件读取 DNSMasq 上游的 DNS 服务器配置。
strict-order:resolv-file 文件中如果指定了多个 DNS 服务器,严格安装 DNS 服务器的先后顺序查询域名。
listen-address:监听地址,配置为本机 IP 即可。
addn-hosts:从文件读取本地 DNS 域名和 IP 的对应关系,格式为 。其实可以把 IP 和域名的对应关系写在 /etc/hosts 文件中,DNSMasq 默认从那里读取,但如果要支持一个域名对应多个 IP,就必须使用 addn-hosts 选项了。

resolv-file=/etc/resolv.conf
strict-order
listen-address=192.168.122.1
addn-hosts=/opt/tools/dns/hosts

1
2
3
4
5
systemctl start dnsmasq.service 启动

systemctl enable dnsmasq.service # 开机启动

netstat -lnp|grep dnsmasq

k8s dns

coredns 异常检查以下配置

/etc/kubernetes/manifests/kube-controller-manager.yaml

1
2
3
4
5
6
cat /etc/kubernetes/manifests/kube-controller-manager.yaml | grep cluster-
- --cluster-cidr=121.21.0.0/16 #意味着Pod IP地址将从121.21.0.0到121.21.255.255范围内分配
- --cluster-name=cs
- --cluster-signing-cert-file=/etc/kubernetes/pki/ca.crt
- --cluster-signing-key-file=/etc/kubernetes/pki/ca.key
- --service-cluster-ip-range=10.96.0.0/12 #服务的IP地址将从10.96.0.0到10.97.255.255范围内分配

cluster-cidr

service-cluster-ip-range

/var/lib/kubelet/config.yaml

1
2
3
4
5
$  cat /var/lib/kubelet/config.yaml | grep -A 1 cluster
clusterDNS:
- 10.96.1.10
clusterDomain: cluster.local
cpuManagerReconcilePeriod: 0s

clusterDNS

进入pod中 查看/etc/reslove.conf 中nameserver和kube-dns ClusterIP 是否一致

1
kubectl edit cm kube-proxy -n kube-system

修改每个Node上kubelet的启动参数,在其中加上以下两个参数:

–cluster-dns=169.169.0.100:为DNS服务的ClusterIP地址。
–cluster-domain=cluster.local:为在DNS服务中设置的域名。
然后重启kubelet服务

nslookup

1
❯ kubectl debug -it vault-0  -n vault  --image=k8s.org/cs/netshoot   -- sh

Defaulting debug container name to debugger-8z7lk.
If you don’t see a command prompt, try pressing enter.
root $ nslookup vault-internal
Server: 10.96.1.10
Address: 10.96.1.10#53

Name: vault-internal.vault.svc.cluster.local
Address: 121.21.64.141
Name: vault-internal.vault.svc.cluster.local
Address: 121.21.80.152
Name: vault-internal.vault.svc.cluster.local
Address: 121.21.48.135

NetworkManager

1
2
3
4
5
❯ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.5.1
nameserver 8.8.8.8
nameserver 114.114.114.114

/etc/network/interfaces

故障

泛域名

配置日志

1
2
3
4
log-queries
log-facility=/opt/tools/dns/dnsmasq.log
addn-hosts=/opt/tools/dns/hostname
address=/local.org/192.168.122.1

Aug 29 18:16:12 dnsmasq[28763]: started, version 2.89 cachesize 150
Aug 29 18:16:12 dnsmasq[28763]: compile time options: IPv6 GNU-getopt DBus no-UBus i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset nftset auth cryptohash DNSSEC loop-detect inotify dumpfile
Aug 29 18:16:12 dnsmasq[28763]: reading /opt/tools/dns/resolv.dnsmasq.conf
Aug 29 18:16:12 dnsmasq[28763]: ignoring nameserver 192.168.122.1 - local interface
Aug 29 18:16:12 dnsmasq[28763]: using nameserver 202.96.128.86#53
Aug 29 18:16:12 dnsmasq[28763]: using nameserver 202.96.134.33#53
Aug 29 18:16:12 dnsmasq[28763]: read /etc/hosts - 11 names
Aug 29 18:16:12 dnsmasq[28763]: read /opt/tools/dns/hostname - 12 names

没有走dnsmasq

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ nslookup es.local.org    
Server: 202.96.128.86
Address: 202.96.128.86#53

** server can't find es.local.org: NXDOMAIN

❯ nslookup es.local.org 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53

Name: es.local.org
Address: 192.168.122.1

Aug 29 18:16:12 dnsmasq[28763]: read /opt/tools/dns/hostname - 12 names
Aug 29 18:16:21 dnsmasq[28763]: query[A] es.local.org from 127.0.0.1
Aug 29 18:16:21 dnsmasq[28763]: config es.local.org is 192.168.122.1
Aug 29 18:16:21 dnsmasq[28763]: query[AAAA] es.local.org from 127.0.0.1
Aug 29 18:16:21 dnsmasq[28763]: forwarded es.local.org to 202.96.128.86
Aug 29 18:16:21 dnsmasq[28763]: reply es.local.org is NODATA-IPv6

解决方式

NetworkManager 管理网络
1
❯ sudo mousepad /etc/NetworkManager/NetworkManager.conf

[main]
dns=dnsmasq #添加

zabbix 安装配置

zabbix

https://www.zabbix.com/download_sources

编译

Documentation: Zabbix 6.4 Installation from sources

1
2
3
4
5
6
❯ sudo addgroup --system --quiet zabbix

❯ sudo adduser --quiet --system --disabled-login --ingroup zabbix --home /var/lib/zabbix --no-create-home zabbix


./configure --prefix=/opt/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi

Running make install will by default install the daemon binaries (zabbix_server, zabbix_agentd, zabbix_proxy) in /usr/local/sbin and the client binaries (zabbix_get, zabbix_sender) in /usr/local/bin.

缺依赖

https://packages.debian.org/search?searchon=contents&keywords=libssl.so

vim 配置

vim

依赖 vim-runtime

gui 依赖 libruby2.1 libyaml-0-2 vim-gui-common

将会安装下列额外的软件包:

libruby2.1 libyaml-0-2 vim-gui-common

建议安装的软件包:

cscope vim-doc

下列【新】软件包将被安装:

libruby2.1 libyaml-0-2 vim-athena vim-gui-common

载入天数...载入时分秒... ,