> 文章列表 > 华为云操作

华为云操作

华为云操作

1.创建VPC

2.放行安全组

3.创建ECS(弹性计算服务)

        基础配置 选择区域,计费模式 cpu架构 规格2C 4G 选择镜像版本 下一步

        网络配置 手动分配一个IP 然后设置一个密码 同意协议买

VPC(Virtual Private Cloud)虚拟私有云

VPC即是一种云,也是一种网络模式,不过应该从服务和技术的角度分别来看

有些时候会把VPC当作一个路由器

这是一种运行在公有云上,将一部分公有云资源为某个用户隔离出来,给这个用户私有使用的资源的集合。VPC是这么一种云,它由公有云管理,运行在公共资源上,但是保证每个用户之间的资源是隔离,用户在使用的时候不受其他用户的影响,感觉像是在使用自己的私有云一样。

VPC应该理解成,向用户提供的隔离资源的集合。

4.购买弹性公网IP

按需计费

按流量计费

5.绑定你买的公网IP地址

jumpserver

公网IP 作为Jumpserver 连接到内网的其他主机(生产环境中就是这样的管理方式)

ansible 写playbook管理后端主机

yum 仓库

jumpserver安装配置

[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 install -y net-tools lftp rsync psmisc \\
vim-enhanced tree vsftpd  bash-completion createrepo lrzsz iproute
[root@ecs-proxy ~]# systemctl enable --now vsftpd
[root@ecs-proxy ~]# mkdir -p /var/ftp/localrepo
[root@ecs-proxy ~]# createrepo --update /var/ftp/localrepo

优化系统服务

[root@ecs-proxy ~]# systemctl stop postfix atd
[root@ecs-proxy ~]# yum remove -y postfix at audit kexec-tools firewalld-*
[root@ecs-proxy ~]# sed 's,^manage_etc_hosts:.*,# &,' -i /etc/cloud/cloud.cfg
[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

配置ansible管理主机

[root@ecs-proxy ~]# tar zxf ansible_centos7.tar.gz
[root@ecs-proxy ~]# yum install -y ansible/*.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
[root@ecs-proxy ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub 192.168.1.125

后端模板镜像配置(那些没有公网IP的server)

配置yum源,安装工具包

[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 repolist
[root@ecs-host ~]# yum install -y net-tools lftp rsync psmisc vim-enhanced tree lrzsz bash-completion iproute

优化系统服务

[root@ecs-host ~]# systemctl stop postfix atd
[root@ecs-host ~]# yum remove -y postfix at audit kexec-tools firewalld-*
[root@ecs-host ~]# sed 's,^manage_etc_hosts:.*,# &,' -i /etc/cloud/cloud.cfg
[root@ecs-host ~]# vim /etc/hosts
# ::1           localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1       localhost localhost.localdomain localhost4 localhost4.localdomain4
[root@ecs-host ~]# yum clean all 
[root@ecs-host ~]# poweroff

关机以后把主机系统盘制作为模板

Rsync(远程数据同步工具)

-a --archive归档模式,表示以递归的方式传输文件 ,并保持所有文件属性等于-rlptgoD

-v 显示详细模式输出

-H 保留硬链接

-S 对稀疏文件进行特殊处理 以节省DST的空间

-X 保留扩展属性

安装部署

[root@ecs-proxy ~]# mkdir website
[root@ecs-proxy ~]# cd website
[root@ecs-proxy website]# vim ansible.cfg
[defaults]
inventory         = hostlist
host_key_checking = False
[root@ecs-proxy website]# vim hostlist
[web]
192.168.1.[11:13]
[root@ecs-proxy website]# vim install.yaml
---
- name: web 集群安装hosts: webtasks:- name: 安装 apache 服务 yum:name: httpd,phpstate: latestupdate_cache: yes- name: 配置 httpd 服务 service:name: httpdstate: startedenabled: yes- name: 部署网站网页unarchive:src: website.tar.gzdest: /var/www/html/copy: yesowner: apachegroup: apache

然后去买ELB服务弹性负载均衡

        共享型 按需计费

        添加监听器 按提示操作

        就可以实现负载均衡访问后端服务器了