yum私有仓库的实现
服务器环境:
VERSION=“9.1 (Blue Onyx)”
ID=“rocky”
1.安装httpd服务
2.下载软件源
3.http协议访问测试路径
4.配置yum源
安装httpd服务
1 2
| yum -y install httpd systemctl enable --now httpd
|
复制Base源
1 2 3
| mkdir /var/www/html/centos/8 -pv mount /dev/sr0 /mnt/ cp -a /mnt/* /var/www/html/centos/8
|
下载epel源
1 2 3 4
| dnf repolist#查看仓库ID dnf reposync --repoid=epel --download-metadata -p /var/www/html/centos dnf -y install createrepo httpd createrepo /var/www/html/centos/epel/
|
浏览器验证访问路径,找到repodata路径


修改yum源
1 2
| cd /etc/yum.repos.d/ cp base.repo base.repo.bak #备份
|

TCP协议和三次握手及四次挥手

静态配置网卡IP
centos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #修改网卡名称 function replacenetworkname(){ source /etc/os-release if [ $ID = 'ubuntu' ] ; then sed -ri.bak 's|^GRUB_CMDLINE_LINUX=.*|GRUB_CMDLINE_LINUX=/" net.ifnames=0\"|g' /etc/default/grub grub-mkconfig -o /boot/grub/grub.cfg
else sed -ri.bak 's|^(GRUB_CMDLINE_LINUX.*)(")$|\1 net.ifnames=0\2|g' /etc/default/grub grub2-mkconfig -o /boot/grub2/grub.cfg
fi
} #修改网卡后重启服务器生效 #查看当前机器网卡 ip a cd /etc/sysconfig/network-scripts/ vi ifcfg-eth0
DEVICE=eth0 NAME=eth0 BOOTRPOTO=static IPADDR=10.0.0.11 PREFIX=24 GATEWAY=10.0.0.2 DNS1=8.8.8.8
nmcli c reload #配置生效 nmcli c up eth0 #网卡生效 #重新查看配置 ip a / ip route
|
ubuntu
1 2 3 4 5 6 7 8 9 10 11 12
| vi /etc/netplan/eth0.yam network: ethernets: eth0: dhcp4: no addresses: [10.0.0.12/24] gateway4: 10.0.0.11 nameservers: addresses: [8.8.8.8] version: 2 netplan apply # 配置生效 ip route /ip a #查看配置
|
实现免密登陆脚本, expect登陆远程主机,将生成的密钥写入到目标主机, expect测试远程登陆。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
| #!/bin/bash # #************************************ #Author: 白展躺 #Date: 2023-06-12 #FileName: install.sh #Description: 功能主菜单 #Copyright: 2023 #************************************ function passwordlessLogin(){ echo "请输入登录的IP:" read -ea values local for value in "${values[@]}" ; do /usr/bin/expect ./passwordlessLogin.sh $value shift done }
MENU=( "安装mysql" "安装apahce" "免密钥登录主机" "退出"
) RED=" \E[01;31m" END="\E[0m" GREEN="\E[1;32m"
while true; do PS3="请选择一个选项: " select opt in "${MENU[@]}" do case $opt in "安装mysql") #installmysql echo -e "$RED建设中...$END" break ;; "安装apahce") echo -e "$RED建设中...$END" break ;; "免密钥登录主机") passwordlessLogin break ;; "退出") echo -e "$GREEN祝您工作愉快 再见!$END" break 2 ;; *) echo "无效的选项,请重新选择" ;; esac done done
|
passwordlessLogin.sh脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #!/bin/expect # #************************************ #Author: 白展躺 #Date: 2023-06-12 #FileName: passwordlessLogin.sh #Description: 免密登录 #Copyright: 2023 #************************************ set timeout -1 set IP [lindex $argv 0] spawn ssh-copy-id root@$IP -f expect { "yes/no" {send "yes\n"; exp_continue } "password" { send "1\r"; expect eof; } } spawn ssh $IP expect { -re "Last login.*" { puts "$IP:测试登录成功" send "exit\r" }
}
|