03:华为云管理|云主机管理|云项目实战

华为云管理|云主机管理|云项目实战

安全组配置

设置安全组


云主机是默认访问不了互联网的 要访问互联网 需要买弹性公网ip

搭建yum?

在文档中心搜索 "华为云 yum 源"

https://support.huaweicloud.com/ecs_faq/ecs_faq_1003.html

在云主机上配置华为云 Yum 源 (2台)

配置以后使用 yum repolist 查看

安装 bash-completion 进行测试

配置yum源,并测试

部署跳板机

配置yum源,安装软件包

shell 复制代码
[root@ecs-proxy ~]# rm -rf /etc/yum.repos.d/*.repo
[root@ecs-proxy ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-Base-7.repo
[root@ecs-proxy ~]# yum clean all
[root@ecs-proxy ~]# yum makecache
[root@ecs-proxy ~]# yum install -y net-tools lftp rsync psmisc vim-enhanced tree vsftpd  bash-completion createrepo lrzsz iproute
[root@ecs-proxy ~]# mkdir /var/ftp/localrepo
[root@ecs-proxy ~]# cd /var/ftp/localrepo
[root@ecs-proxy ~]# createrepo  .
[root@ecs-proxy ~]# createrepo --update . # 更新
[root@ecs-proxy ~]# systemctl enable --now vsftpd  # vsftpd开机自启动

优化系统服务

shell 复制代码
[root@ecs-proxy ~]# systemctl stop postfix atd tuned
[root@ecs-proxy ~]# yum remove -y postfix at audit tuned kexec-tools firewalld-*
[root@ecs-proxy ~]# vim /etc/cloud/cloud.cfg
# manage_etc_hosts: localhost 注释掉这一行 防止更新
[root@ecs-proxy ~]# reboot
如下:没有添加新的主机配置名 证明关闭成功


安装配置ansible管理主机

shell 复制代码
# 拷贝ansible到跳板机
[root@ecs-proxy ~]# tar zxf ansible_centos7.tar.gz
[root@ecs-proxy ~]# yum install -y ansible_centos7/*.rpm
[root@ecs-proxy ~]# ssh-keygen -t rsa -b 2048 -N '' -f /root/.ssh/id_rsa
[root@ecs-proxy ~]# chmod 0400 /root/.ssh/id_rsa # 私钥权限 400
[root@ecs-proxy ~]# ssh-copy-id -i /root/.ssh/id_rsa 模板主机IP # 配置到模板主机

模版镜像配置

配置yum源,安装软件包

shell 复制代码
[root@ecs-host ~]# rm -rf /etc/yum.repos.d/*.repo
[root@ecs-host ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-Base-7.repo
[root@ecs-host ~]# vim /etc/yum.repos.d/local.repo 
[local_repo]
name=CentOS-$releasever -- Localrepo
baseurl=ftp://192.168.1.252/localrepo
enabled=1
gpgcheck=0
[root@ecs-host ~]# yum clean all # 清空缓存
[root@ecs-host ~]# yum makecache # 重新生成缓存
[root@ecs-host ~]# yum repolist # 检查
[root@ecs-host ~]# yum install -y net-tools lftp rsync psmisc vim-enhanced tree lrzsz bash-completion iproute

优化系统

shell 复制代码
[root@ecs-host ~]# systemctl stop postfix atd tuned
[root@ecs-host ~]# yum remove -y postfix at audit tuned kexec-tools firewalld-*
[root@ecs-host ~]# vim /etc/cloud/cloud.cfg
# manage_etc_hosts: localhost 注释掉这一行
[root@ecs-host ~]# yum clean all 
[root@ecs-host ~]# poweroff # 因为要做成镜像模版 所以要关机
# 注:配置完成以后,关机,在华为云主机管理菜单中把模板主机系统硬盘做成镜像,供以后使用


网站云平台部署实战





shell 复制代码
# 配置ansible
[root@ecs-proxy ~]# mkdir -p web-site
[root@ecs-proxy ~]# cd web-site
[root@ecs-proxy ~]# vim ansible.cfg
[defaults]
inventory         = hostlist
host_key_checking = False
[root@ecs-proxy ~]# vim hostlist
[web]
192.168.1.[11:13]
[root@ecs-proxy ~]# vim web_install.yaml
---
- name: web 集群安装
  hosts: web
  tasks:
  - name: 安装 apache 服务 
    yum:
      name: httpd,php
      state: latest
      update_cache: yes
  - name: 配置 httpd 服务 
    service:
      name: httpd
      state: started
      enabled: yes
  - name: 部署网站网页
    unarchive:
      src: files/webhome.tar.gz
      dest: /var/www/html/
      copy: yes
      owner: apache
      group: apache
[root@ecs-proxy ~]# mkdir files
# 上传 webhome.tar.gz 到 files 目录下
[root@ecs-proxy ~]# ansible-playbook web_install.yaml

检测ansible对云主机是否管理正常

华为云的负载均衡







跳板机测试

可以直接访问公网ip

相关推荐
Linux猿12 小时前
828华为云征文 | 云服务器Flexus X实例:部署 AgentOps,全方位监测智能体
人工智能·华为云·agent·autogen·flexus云服务器x实例·华为云服务器·agentops
huaqianzkh12 小时前
了解华为云容器引擎(Cloud Container Engine)
云原生·架构·华为云
cooldream200916 小时前
828华为云征文 | 在华为云X实例上部署微服务架构的文物大数据管理平台的实践
微服务·架构·华为云·文物大数据平台
cooldream200917 小时前
828华为云征文 | 华为云X实例监控与告警管理详解
华为云·自动化运维·云监控·告警
lgbisha1 天前
828华为云征文|华为云Flexus X实例docker部署最新Appsmith社区版,搭建自己的低代码平台
低代码·docker·华为云
A^mber1 天前
828华为云征文|云服务器Flexus X实例|Ubunt部署Vue项目
运维·服务器·华为云
繁依Fanyi2 天前
828 华为云征文|华为 Flexus 云服务器部署 RustDesk Server,打造自己的远程桌面服务器
运维·服务器·开发语言·人工智能·pytorch·华为·华为云
Linux猿2 天前
828华为云征文 | 云服务器Flexus X实例:多智能体对话框架 AutoGen 部署和实例运行
华为云·agent·多智能体·autogen·flexus云服务器x实例·华为云服务器·autogen studio
繁依Fanyi2 天前
828华为云征文|华为Flexus云服务器搭建OnlyOffice私有化在线办公套件
服务器·开发语言·前端·python·算法·华为·华为云
Just_Paranoid3 天前
828华为云征文|部署在线文件管理器 Spacedrive
docker·华为云·文件管理·flexus云服务器·spacedrive