云计算学习经验总结

AWS CLI 的最新版本,必须使用以下命令卸载预安装的yum版本:

sudo yum remove awscli

要安装AWS CLI

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

unzip awscliv2.zip

sudo ./aws/install

要更新 AWS CLI 的当前安装

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"

unzip awscliv2.zip

sudo ./aws/install --bin-dir /usr/local/bin --install-dir /usr/local/aws-cli --update

连接SSH客户端

①whoami(显示当前用户)

②exit(退出登录)

③dir(确认文件的路径)

ssh -i .\lab001.pem ubuntu@ec2-47-129-azonaws.com

把.\lab001.pem根据路径换成你创建的密钥对,ubunt换成你用户的名字,@后边的可以用EC2实例的外部DNS,也可以使用IP

拷贝密钥pem文件,新建一个pem文件:vi ./lab002.pem

修改文件权限:chmod 0400 ./lab002.pem

子网访问互联网:curl http://www.bing.com

配置脚本:vi ./date.sh

#!/bin/bash

yum update -y

yum install httpd -y

systemctl enable httpd

systemctl start httpd

cd /var/www/html

echo "This is INSTANCE ${HOSTNAME}"> index.html

执行脚本:sudo sh ./date.sh

创建启动模板:#!/bin/bash

yum update -y

amazon-linux-extras install epel -y

yum install stress -y

yum install httpd -y

systemctl enable httpd

systemctl start httpd

cd /var/www/html

echo "This is INSTANCE ${HOSTNAME}" > index.html

如何给CPU压力,让CPU增高(命令)

①top(查看cpu的数据)

yes > /dev/null &(给cpu压力)

②stress工具:

安装stress:sudo yum install stress

测试CPU:stress --cpu $(nproc) --timeout 60s

指定cpu核心数:stress --cpu 4 --timeout 30s

同时测试cpu,内存和I/O:stress --cpu 8 --io 4 --vm 2 --vm-bytes 1G --timeout 60s

或;stress -c 2

③sudo yum update -y

sudo yum install httpd-tools

输入:ab

确认ALB负载均衡器的状态(后边记得变)

http://lab003-2074558455.us-east-1.elb.amazonaws.com

curl http://internal-lab007-asg-1-1680230458.ap-southeast-1.elb.amazonaws.com/

向ALB网址进行压力测试

ab -n 2400000 -c 600 http://internal-lab007-asg-1-1680230458.ap-southeast-1.elb.amazonaws.com/

数据库:

通过更新 EC2 实例上的软件,获取最新的错误修复和安全更新:sudo dnf update -y

要在 Amazon Linux 2023 上安装 PostgreSQL 中的 psql 命令行客户端

sudo dnf install postgresql15

连接到 PostgreSQL 数据库实例

psql --host=endpoint --port=5432 --dbname=postgres --username=postgres

/dt 查看

创建表:CREATE TABLE IF NOT EXISTS unicorntable (

id SERIAL PRIMARY KEY,

requested VARCHAR(255),

requestvalue VARCHAR(255),

hits INT

);

优化数据库:

索引优化:为高频查询字段添加索引。

例如:CREATE INDEX idx_requested ON unicorntable(requested);

连接池管理:使用pgBouncer减少连接开销(适合高并发)。

查询分析:用EXPLAIN ANALYZE检查慢查询。

EXPLAIN ANALYZE SELECT * FROM unicorntable WHERE requested = 'test';

S3桶:

aws configure

查看文件:dir

给S3桶上传文件:

在EC2实例里访问S3存储桶实例

拷贝pem文件内容到新建文件lab-014.pem

创建S3策略的时候使用这个代码脚本:(但是首先在终端查看IP地址)

{

"Id":"Policy1737196706646",

"Version": "2012-10-17",

"Statement":[

{

"Sid": "stmt1737196700616",

"Action": "s3:*",

"Effect": "Deny",

"Resource": "arn:aws:s3:::lab015-bucket",

"Condition":{

"NotIpAddress":{

"aws:SourceIp":"120.231.211.233/32"

}

},

"Principal":"*"

}

]

}

堆栈:

https://docs.aws.amazon.com/zh_cn/AWSCloudFormation/latest/UserGuide/gettingstarted.walkthrough.html

VPC:

https://docs.aws.amazon.com/vpc/latest/userguide/what-is-amazon-vpc.html

Amazon S3:

https://aws.amazon.com/cn/s3/getting-started/

PostgreSQL DB:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.PostgreSQL.html

AWS CLI (控制指南)

https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html

AWS Auto Scaling (ASG)

https://docs.aws.amazon.com/autoscaling/ec2/userguide/get-started-with-ec2-auto-scaling.html

AWS Load Balancer(ALB/ELB)

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/application-load-balancer-getting-started.html

AWS 高可用的核心概念,包括 Multi-AZ、Auto Scaling、负载均衡等:

https://docs.aws.amazon.com/whitepapers/latest/real-time-communication-on-aws/welcome.html

AWS RDS PostgreSQL:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.PostgreSQL.html

CloudWatch 监控与告警:

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/GettingStarted.html

IAM:

https://docs.aws.amazon.com/IAM/latest/UserGuide/introduction.html

AWS KMS(密钥管理服务)指南:

https://docs.aws.amazon.com/kms/latest/developerguide/overview.html

AWS CloudTrail:

https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-tutorial.html

AWS Spot:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-spot-instances.html

AWS Cost Explorer:

https://docs.aws.amazon.com/cos

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值