Giter Site home page Giter Site logo

aws-lightsail-part2-update's Introduction

AWS-lightsail-Part2-Update

针对油管博主 BIGDONGDONG 的第 96 期视频 part 2 命令的一次更新, 原链接: https://github.com/bigdongdongCLUB/GoodGoodStudyDayDayUp/issues/2

由于原命令部分已经失效,为了方便后人操作,会将所有步骤再列一次:

第一步:获取 AWS AccessKeyId 和 AWS SecretKey

这一步只需要先点击 https://lightsail.aws.amazon.com/ls/webapp/account/advanced ,然后点击转到IAM控制台,选择访问密钥(访问密钥ID和秘密访问密钥), 最后点击创建新的访问密钥并保存.csv格式的文件。

第二步:安装AWS CLI

以ubuntu系统为例: 先检查是否安装了 Pip 和 Python

pip --version
python --version

没有的话需要安装,使用东东的执行语句安装

apt update -y
apt install python-pip -y

或者也可以使用 AWS 的用户指南进行安装,点击网址:https://docs.aws.amazon.com/zh_cn/cli/latest/userguide/install-linux.html#install-linux-path
再使用 Pip 安装 AWS CLI

pip install awscli --upgrade --user
第三步:手动配置 AWS CLI 的文件

东东给的脚本已经失效了。访问原博客的文章,原来是博主自己更改了方法,自己感觉没有很好用,所以决定不用脚本,手动更改,很简单!

  1. 配置credentials
    运行vim ~/.aws/credentials或者nano ~/.aws/credentials
    复制黏贴以下文本,将第一步获取的 AWS AccessKeyId 和 AWS SecretKey 复制进去
[default]
aws_access_key_id=AKIAIOSFODNN7EXAMPLE
aws_secret_access_key=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

vim 保存的方式是 :wq!, nano保存的方式是 ctrl + x 再按Y
2. 配置config
运行vim ~/.aws/config或者nano ~/.aws/config
复制黏贴以下文本,根据自己虚拟机所在区域填写即可。注意,不需要管a,b,c区。比如你的实例所在位置是us-west-2a,那就填写us-west-2

[default]
region=us-west-2
output=json
第四步:写重启文件

输入

nano renewip.sh

以下命令和东东给的方法一致,比如我想重启的服务器的名字是Oregon,那么就填写成以下形式后保存

aws lightsail stop-instance --instance-name Oregon
sleep 30
aws lightsail start-instance --instance-name Oregon
第五步:编辑重写配置

输入

crontab -e

将以下命令复制到最后一行。注意,命令前面不要加#

0 3 * * * bash /root/renewip.sh

最后调整一下时区

timedatectl set-timezone Asia/Hong_Kong

aws-lightsail-part2-update's People

Contributors

hephaest avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.