当前位置:网站首页 > 智能化工程 正文 智能化工程

华为云跳板机的设置

frank 2025-08-24 22:51:29 智能化工程 3 ℃ 0 评论

1.给云主机配置公网ip

购买公网ip

华为云跳板机的设置

华为云跳板机的设置

按需购买即可,此处练习选择按流量计费华为云跳板机的设置购买成功页面图:

华为云跳板机的设置

给云主机配置ip(关机状态下)

华为云跳板机的设置

华为云跳板机的设置

稍等片刻,此处ip地址已经配置完成华为云跳板机的设置

2.使用远程工具,远程主机ssh + 公网ip

ansible管理主机,配置ansible

[root@ecs-proxy ~]# dnf install -y ansible-core glibc-langpack-zh
[root@ecs-proxy ~]# ssh-keygen #一路回车
[root@ecs-proxy ~]# chmod 0400 /root/.ssh/id_rsa
[root@ecs-proxy ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.1.125
[root@ecs-proxy ~]# ansible --version

优化主机系统

[root@ecs-proxy ~]# systemctl stop atd kdump nis-domainname //暂停不需要服务
[root@ecs-proxy ~]# dnf remove -y postfix at audit kexec-tools firewalld-* *-firmware unbound-libs//卸载不需要软件,保障系统安全
[root@ecs-proxy ~]# dnf install -y rsync tree bash-completion lrzsz tar iptables patch ipset time //按装系统不具备的必要服务
[root@ecs-proxy ~]# echo 'ListenAddress 0.0.0.0' >>/etc/ssh/sshd_config//允许 SSH 服务监听所有网络接口
[root@ecs-proxy ~]# sed -ri 's,^(OPTIONS).*,\1="-4u chrony",' /etc/sysconfig/chronyd//配置 chronyd 服务在系统启动时以特定的运行级别和用户运行
[root@ecs-proxy ~]# sed 's,^manage_etc_hosts:.*,# &,' -i /etc/cloud/cloud.cfg//禁用或忽略 Cloud-init 在初始化时对 /etc/hosts 文件的管理
[root@ecs-proxy ~]# vim /etc/hosts
::1             localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
[root@ecs-proxy ~]# reboot

3.代理yum仓库

华为云跳板机的设置
[root@ecs-proxy ~]# dnf install -y nginx
[root@ecs-proxy ~]# vim /etc/nginx/default.d/dnf_proxy.conf
resolver 100.125.1.250 100.125.129.250 valid=5 ipv6=off;
location ~ ^/rockylinux/(.*)$ {
  proxy_pass https://repo.huaweicloud.com/rockylinux/$1; //使用nginx反向代理功能,匹配^/rockylinux/(.*)$的请求自动跳转到华为云官方仓库
}
[root@ecs-proxy ~]# systemctl enable --now nginx

4.私有yum仓库

[root@ecs-proxy ~]# dnf install -y createrepo

[root@ecs-proxy ~]# mkdir -p /var/localrepo

[root@ecs-proxy ~]# createrepo --update /var/localrepo 创建仓库元数据文件

[root@ecs-proxy ~]# ln -s /var/localrepo /usr/share/nginx/html/ 创建软链接到nginx下

5.客户端配置

[root@ecs-host ~]# rm -f /etc/yum.repos.d/{epel,Rocky-[!ABE]}* //删除不需要的repo文件

[root@ecs-host ~]# sed -ri 's,https://repo.huaweicloud.com,http://192.168.1.252,' /etc/yum.repos.d/*.repo //192.168.1.252 为跳板级ip

[root@ecs-host ~]# vim /etc/yum.repos.d/local.repo

[local_repo]

name=Rocky Linux $releasever - Localrepo

baseurl=http://192.168.1.252/localrepo

enabled=1

gpgcheck=0

[root@ecs-host ~]# dnf makecache

版权说明:如非注明,本站文章均为 扬州驻场服务-网络设备调试-监控维修-南京泽同信息科技有限公司 原创,转载请注明出处和附带本文链接

请在这里放置你的在线分享代码
«    2025年8月    »
123
45678910
11121314151617
18192021222324
25262728293031
搜索
最新留言
    文章归档
    网站收藏
    友情链接