案例1:准备MHA集群环境
案例2:部署MHA集群案例3:测试配置1 案例1:准备MHA集群环境1.1 问题配置SSH免密登录安装依赖包配置MySQL一主多从结构1.2 方案准备5台虚拟机,角色规划如图-1所示。图-1IP规划,如图-2所示:图-21.3 步骤实现此案例需要按照如下步骤进行。步骤一: 配置ssh免密登录1)配置数据库服务器192.168.4.51[root@host51 ~]# ssh-keygen //创建秘钥对Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): //回车Enter passphrase (empty for no passphrase): //回车Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:SHA256:qb7EZByHad3Jadr+zkiEbo7ZKGmCNlctgp+Wfp3Yad0 root@pxcnode71The key’s randomart image is:±–[RSA 2048]----+| || + o o || = o * || o o * || . = S o || . . * + o || … =.O * + ||.o.+= & o E ||. =+…B.o …+ |±—[SHA256]-----+[root@host51 ~]#[root@host51 ~]# ssh-copy-id root@192.168.4.52 //传递公钥给host52主机/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keysroot@192.168.4.71’s password: //输入host52主机系统管理员root用户密码Number of key(s) added: 1Now try logging into the machine, with: "ssh ‘root@192.168.4.52’“and check to make sure that only the key(s) you wanted were added.[root@host51 ~]#[root@host51 ~]# ssh-copy-id root@192.168.4.53 //传递公钥给host53主机/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keysroot@192.168.4.71’s password: //输入host53主机系统管理员root用户密码Number of key(s) added: 1Now try logging into the machine, with: “ssh ‘root@192.168.4.53’“and check to make sure that only the key(s) you wanted were added.[root@host51 ~]#[root@host51 ~]# ssh root@192.168.4.52 //可以无密码连接52主机Last login: Fri Jun 21 13:21:39 2019 from 192.168.4.254.-”””-./ .=. \/ 6 6 /( _/ )ooo_/__________/ | I am Virtual Host ! ! ! |______________ooo/| | || | _|| | ||||/-‘Y’-(/ __)[root@host52 ~]#[root@host52 ~]# exit //断开连接登出Connection to 192.168.4.52 closed.[root@host51 ~]#[root@host51 ~]# ssh root@192.168.4.53 //可以无密码连接52主机Last login: Fri Jun 21 09:01:15 2019 from 192.168.4.254.-"""-./ .=. \/ 6 6 /( _/ )ooo_/__________/ | I am Virtual Host ! ! ! |______________ooo/| | || | _|| | ||||/-‘Y’-(/ __)[root@host53 ~]# exit//断开连接登出Connection to 192.168.4.53 closed.[root@host51 ~]#2)配置数据库服务器192.168.4.52[root@host52 ~]# ssh-keygen //创建秘钥对Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): //回车Enter passphrase (empty for no passphrase): //回车Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub.The key fingerprint is:SHA256:qb7EZByHad3Jadr+zkiEbo7ZKGmCNlctgp+Wfp3Yad0 root@pxcnode71The key’s randomart image is:±–[RSA 2048]----+| || + o o || = o * || o o * || . = S o || . . * + o || … =.O * + ||.o.+= & o E ||. =+…B.o …+ |±—[SHA256]-----+[root@host52 ~]#[root@host52 ~]# ssh-copy-id root@192.168.4.51 //传递公钥给host51主机/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keysroot@192.168.4.51’s password: //输入host51主机系统管理员root用户密码Number of key(s) added: 1Now try logging into the machine, with: "ssh ‘root@192.168.4.51’“and check to make sure that only the key(s) you wanted were added.[root@host52 ~]#[root@host52 ~]# ssh-copy-id root@192.168.4.53 //传递公钥给host53主机/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: “/root/.ssh/id_rsa.pub”/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed – if you are prompted now it is to install the new keysroot@192.168.4.53’s password: //输入host53主机系统管理员root用户密码Number of key(s) added: 1Now try logging into the machine, with: “ssh ‘root@192.168.4.53’“and check to make sure that only the key(s) you wanted were added.[root@host52 ~]#[root@host52 ~]# ssh root@192.168.4.51 //可以无密码连接51主机Last login: Fri Jun 21 13:21:39 2019 from 192.168.4.254.-”””-./ .===. \/ 6 6 /( _/ )ooo_/_______
apiVersion: v1
kind: Service
metadata:
name: service-clusterip
namespace: dev
spec:
selector:
app: nginx-pod
clusterIP: 10.99.99.99 #serviceIP 如果不写会默认生成一个
type: ClusterIP
ports:
- port: 80 #service端口
targetPort: 80 #pod端口