从母盘克隆出一个虚拟机openEuler-node2
如何设定网卡的名称为ehtx x为数字
在内核中禁止使用net.ifnames模块,这样可以让网卡显示为ethx
[root@localhost ~]# gruuby --update-kernel ALL --args net.ifnames=0
修改完这个参数过后需要重启系统reboot
,让参数生效
然后添加一张网卡
进入网卡配置目录(除了rhel9之外的网卡配置文件目录)
删除原有的ens33配置文件
重写一个网卡配置文件,名为ifcfg-eth0
重启激活
配置临时ip地址
[root@localhost ~]# ip address add 172.25.254.100/24 dev eth0
[root@localhost ~]# ip address add 172.25.254.110/24 dev eth1
[root@localhost ~]# ip addr show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:0c:76:54 brd ff:ff:ff:ff:ff:ff
inet 172.25.254.110/24 scope global eth1
valid_lft forever preferred_lft forever
临时ip关机重启不生效
再写一个ifcfg-eth1配置文件
[root@localhost network-scripts]# vim ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
IPADDR1=172.25.254.100
NETMASK1=255.255.255.0
DNS1=114.114.114.114
GATEWAY1=172.25.254.2
NAME=eth1
[root@localhost network-scripts]# nmcli connection reload
[root@localhost network-scripts]# nmcli connection up eth1
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/3)
编写脚本
[root@localhost ~]# vim /bin/vmset.sh
#!/bin/bash
cat > /etc/sysconfig/network-scripts/ifcfg-$1 <<EOF
DEVICE=$1
ONBOOT=yes
BOOTPROTO=none
IPADDR1=$2
NETMASK1=255.255.255.0
DNS1=114.114.114.114
GATEWAY1=172.25.254.2
NAME=$1
EOF
nmcli connection reload
nmcli connection up $1
[root@localhost ~]# vmset.sh eth1 172.25.254.115
连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/4)
软件仓库搭建及使用
搭建仓库时前提条件,保证光盘连接
创建挂载目录
[root@localhost ~]# mkdir /openeuler
挂载镜像并显示内容
[root@localhost ~]# mount /dev/sr0 /openeuler/
mount: /openeuler: WARNING: source write-protected, mounted read-only.
[root@localhost ~]# ls /openeuler/
docs images ks repodata TRANS.TBL
EFI isolinux Packages RPM-GPG-KEY-openEuler
配置开机自动挂载
[root@localhost ~]# vim /etc/rc.d/rc.local
# 将挂载命令写入文件中
mount /dev/sr0 /openeuler/
赋予执行权限
[root@localhost ~]# chmod +x /etc/rc.d/rc.local
reboot重启验证是否开机自动挂载
系统重启之后依然可以挂载
将系统原有的仓库移走
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
openEuler.repo
[root@localhost yum.repos.d]# mv openEuler.repo openEuler.repo.bak
重新编写一个仓库配置文件
[root@localhost yum.repos.d]# vim openEuler.repo
[openEuler]
name=openEuler
baseurl=file:///openeuler
gpgcheck=0
# 验证仓库是否有效
[root@localhost yum.repos.d]# dnf makecache
openEuler 89 MB/s | 3.4 MB 00:00
Metadata cache created.
查找哪个软件包中含有vim
[root@localhost yum.repos.d]# dnf whatprovides */vim
Last metadata expiration check: 0:02:42 ago on 2024年08月03日 星期六 22时54分26秒.
vim-enhanced-2:9.0-23.oe2203sp4.x86_64 : This is a package containing enhanced
: vim editor.
Repo : @System
Matched from:
Filename : /usr/bin/vim
vim-enhanced-2:9.0-23.oe2203sp4.x86_64 : This is a package containing enhanced
: vim editor.
Repo : openEuler
Matched from:
Filename : /usr/bin/vim
搭建第三方软件仓库
搭建网络仓库下载软件前提保证自己的环境网络是否连通,ping百度检测
[root@localhost yum.repos.d]# ping www.baidu.com
PING www.baidu.com (36.155.132.76) 56(84) 字节的数据。
64 字节,来自 36.155.132.76 (36.155.132.76): icmp_seq=1 ttl=128 时间=53.0 毫秒
64 字节,来自 36.155.132.76 (36.155.132.76): icmp_seq=2 ttl=128 时间=74.7 毫秒
64 字节,来自 36.155.132.76 (36.155.132.76): icmp_seq=3 ttl=128 时间=45.2 毫秒
64 字节,来自 36.155.132.76 (36.155.132.76): icmp_seq=4 ttl=128 时间=67.9 毫秒
64 字节,来自 36.155.132.76 (36.155.132.76): icmp_seq=5 ttl=128 时间=26.4 毫秒
64 字节,来自 36.155.132.76 (36.155.132.76):
^C
--- www.baidu.com ping 统计 ---
已发送 10 个包, 已接收 10 个包, 0% packet loss, time 9007ms
rtt min/avg/max/mdev = 26.426/52.875/74.738/15.531 ms
以下载docker为例
[root@localhost yum.repos.d]# vim docker-ce.repo
[docker-ce]
name=docker
baseurl=https://mirrors.aliyun.com/docker-ce/linux/rhel/9/x86_64/stable/
gpgcheck=0
检测仓库是否有问题
[root@localhost yum.repos.d]# cd
[root@localhost ~]# yum makecache
docker 23 kB/s | 20 kB 00:00
openEuler 3.7 MB/s | 3.8 kB 00:00
Metadata cache created.
通过软件仓库下载软件但不安装
[root@localhost ~]# dnf install docker-ce --downloadonly --downloaddir=/mnt
在目录下查看是否下载成功
[root@localhost ~]# cd /mnt/
[root@localhost mnt]# ls
containerd.io-1.7.19-3.1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm
docker-ce-cli-27.1.1-1.el9.x86_64.rpm
docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
重新创建一个目录存放docker安装包,此目录只是存放rpm软件包的目录,并不是软件仓库
[root@localhost mnt]# mkdir docker
[root@localhost mnt]# mv *.rpm docker
[root@localhost mnt]# cd docker/
[root@localhost docker]# ls
containerd.io-1.7.19-3.1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm
docker-ce-cli-27.1.1-1.el9.x86_64.rpm
docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
安装用来采集rpm数据的软件
[root@localhost docker]# dnf whatprovides */createrepo
Last metadata expiration check: 0:13:04 ago on 2024年08月03日 星期六 23时10分51秒.
createrepo_c-0.17.6-3.oe2203sp4.x86_64 : Creates a common metadata repository
Repo : openEuler
Matched from:
Filename : /usr/bin/createrepo
[root@localhost docker]# dnf install createrepo_c-0.17.6-3.oe2203sp4.x86_64 -y
# 扫描软件并生成软件仓库的数据
[root@localhost docker]# createrepo -v /mnt/docker/
23:25:04: Version: 0.17.6 (Features: DeltaRPM LegacyWeakdeps )
23:25:04: Signal handler setup
23:25:04: Thread pool ready
Directory walk started
23:25:04: Adding pkg: /mnt/docker/docker-ce-27.1.1-1.el9.x86_64.rpm
23:25:04: Adding pkg: /mnt/docker/docker-ce-cli-27.1.1-1.el9.x86_64.rpm
23:25:04: Dir to scan: /mnt/docker/.repodata
23:25:04: Adding pkg: /mnt/docker/container-selinux-2.138-5.oe2203sp4.noarch.rpm
23:25:04: Adding pkg: /mnt/docker/docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
23:25:04: Adding pkg: /mnt/docker/docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
23:25:04: Adding pkg: /mnt/docker/containerd.io-1.7.19-3.1.el9.x86_64.rpm
23:25:04: Package count: 6
Directory walk done - 6 packages
Temporary output repo path: /mnt/docker/.repodata/
23:25:04: Creating .xml.gz files
23:25:04: Setting number of packages
Preparing sqlite DBs
23:25:04: Creating databases
23:25:04: Thread pool user data ready
Pool started (with 5 workers)
Pool finished
23:25:05: Generating repomd.xml
23:25:05: Old repodata doesn't exists: Cannot rename /mnt/docker/repodata/ -> /mnt/docker/repodata.old.1947.20240803232505.30252: No such file or directory
23:25:05: Renamed /mnt/docker/.repodata/ -> /mnt/docker/repodata/
23:25:05: Memory cleanup
23:25:05: All done
[root@localhost docker]# ls
containerd.io-1.7.19-3.1.el9.x86_64.rpm
container-selinux-2.138-5.oe2203sp4.noarch.rpm
docker-buildx-plugin-0.16.1-1.el9.x86_64.rpm
docker-ce-27.1.1-1.el9.x86_64.rpm
docker-ce-cli-27.1.1-1.el9.x86_64.rpm
docker-compose-plugin-2.29.1-1.el9.x86_64.rpm
repodata
[root@localhost docker]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ll
总用量 12
-rw-r--r--. 1 root root 108 8月 3 23:10 docker-ce.repo
-rw-r--r--. 1 root root 64 8月 3 22:54 openEuler.repo
-rw-r--r--. 1 root root 2685 5月 27 16:26 openEuler.repo.bak
[root@localhost yum.repos.d]# vim docker-ce.repo
[root@localhost yum.repos.d]# cat docker-ce.repo
[docker-ce]
name=docker
baseurl=file:///mnt/docker
gpgcheck=0
[root@localhost yum.repos.d]# dnf install docker -y