#!/bin/bash #1. 判断参数个数 if [ $# -lt 1 ] then echo Not Enough Arguement! exit; fi
#2. 遍历集群所有机器 for host in unclebryan02 unclebryan03 do echo ==================== $host ==================== #3. 遍历所有目录,挨个发送 for file in$@ do #4. 判断文件是否存在 if [ -e $file ] then #5. 获取父目录 pdir=$(cd -P $(dirname$file); pwd) #6. 获取当前文件的名称 fname=$(basename$file) ssh $host"mkdir -p $pdir" rsync -av $pdir/$fname$host:$pdir else echo$file does not exists! fi done done
1 2 3 4
#设置脚本权限 chmod 777 xsync # 执行测试 xsync + 文件夹
4.编写批量命令执行脚本
在/usr/local/bin路径下新建xcall文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash #在集群的所有机器上批量执行同一条命令 if(($#==0)) then echo 请输入您要操作的命令! exit fi
echo 要执行的命令是$*
#循环执行此命令 for((i=1;i<=3;i++)) do echo ---------------------unclebryan0$i----------------- ssh unclebryan0$i $* done
用Navicat连接mysql,报错如下: Client does not support authentication protocol requested by server; 报错原因: mysql8.0 引入了新特性 caching_sha2_password;这种密码加密方式Navicat 12以下客户端不支持; Navicat 12以下客户端支持的是mysql_native_password这种加密方式; 解决方案: 1,用如下语句查看MySQL当前加密方式 select host,user,plugin from user; 查询结果
warning: /var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-server-8.0.28-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 8.0 Community Server" repository are already installed but they are not correct for this package. Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-server-8.0.28-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
CentOS Linux 8 - AppStream 73 B/s | 38 B 00:00 Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
Step 1: Go to the /etc/yum.repos.d/ directory.
1
[root@autocontroller ~]# cd /etc/yum.repos.d/
Step 2: Run the below commands
1 2
[root@autocontroller ~]# sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* [root@autocontroller ~]# sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*