以下操作可在wsl中进行
- 同步索引信息
- mysql 8
1 | mkdir -p mysql8/repodata |
- mysql 5.7
1
2
3mkdir -p mysql57/repodata
cd mysql57/repodata
lftp "https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/repodata/" -e "mirror --verbose -P 5 --delete --only-missing; bye"
- 获取最新的版本号
- mysql 8
1 | mysql8_version=$(lftp https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/ -e "cls;bye" | grep -e "mysql-community-client.*.el7.x86_64.rpm" | sed -r 's/mysql-community-client-(.*).el7.x86_64.rpm/\1/g' | sort -rV | xargs | awk -F ' ' '{print $1}') |
- mysql 5.7
1 | mysql57_version=$(lftp https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql57-community-el7/ -e "cls;bye" | grep -e "mysql-community-client.*.el7.x86_64.rpm" | sed -r 's/mysql-community-client-(.*).el7.x86_64.rpm/\1/g' | sort -rV | xargs | awk -F ' ' '{print $1}') |
- 在与repodata同级的目录下,下载各个依赖的rpm包
- mysql 8
1
2
3
4
5
6
7
8curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-client-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-common-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-devel-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-embedded-compat-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-compat-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-server-${mysql8_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-test-${mysql8_version}.el7.x86_64.rpm - mysql 5.7
1
2
3
4
5
6
7
8curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-client-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-common-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-devel-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-embedded-compat-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-libs-compat-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-server-${mysql57_version}.el7.x86_64.rpm
curl -O https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql80-community-el7/mysql-community-test-${mysql57_version}.el7.x86_64.rpm
在本地的windows上配置一个http服务器,将http路径指向刚刚操作的目录,
我用的是Apache,参考配置:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15Alias /mirrors/mysql8 "E:/linux/repo/mysql8"
<Directory E:/linux/repo/mysql8>
Options Indexes
IndexOptions NameWidth=25 Charset=UTF-8
AllowOverride All
Require all granted
</Directory>
Alias /mirrors/mysql57 "E:/linux/repo/mysql57"
<Directory E:/linux/repo/mysql57>
Options Indexes
IndexOptions NameWidth=25 Charset=UTF-8
AllowOverride All
Require all granted
</Directory>
CentOS7虚拟机上yum源的配置
1 | vim /etc/yum.repos.d/mysql-community.repo |
自动同步脚本
1 |
|