经常要使用预配置的ec2实例;方便部署和测试;本文总结了笔者工作中常用的配置命令供参考
可以将常用bin放在s3中下载更快
#!/bin/bash
sudo -u ec2-user aws configure set region cn-north-1
sudo yum update -y
sudo yum install telnet -y
sudo yum install httpd-tools -y
sudo yum install bash-completion -y
sudo yum install java-11-amazon-corretto -y
sudo yum install golang -y
yum remove awscli -y
curl ;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip; -o ;awscliv2.zip;
unzip awscliv2.zip
sudo ./aws/install
complete -C ;/usr/local/bin/aws_completer; aws
mkdir /home/ec2-user/bin
mkdir /home/ec2-user/softwares
mkdir /opt/module
aws s3 cp s3://zhaojiew/bin/ /home/ec2-user/bin --recursive
chmod ;x /home/ec2-user/bin/*
chown -R ec2-user:ec2-user /opt/module
chown -R ec2-user:ec2-user /home/ec2-user/softwares
chown -R ec2-user:ec2-user /home/ec2-user/bin
#!/bin/bash
sed -i.bak -e ;s|PasswordAuthentication no|PasswordAuthentication yes|; /etc/ssh/sshd_config
aws configure set region cn-north-1
aws ssm get-parameter --name <parameter-name> --query ;Parameter.Value; --output text | passwd ec2-user --stdin
#!/bin/bash
yum remove awscli -y
curl ;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip; -o ;awscliv2.zip;
unzip awscliv2.zip
./aws/install
complete -C ;/usr/local/bin/aws_completer; aws
#!/bin/bash
yum install docker -y
systemctl start docker
systemctl enable docker
#!/bin/bash
mkdir /home/ec2-user/software
mkdir /opt/module
yum install java-11-amazon-corretto -y
#yum install java-17-amazon-corretto -y
curl -O https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.tar.gz
sudo tar -xzvf apache-maven-3.8.6-bin.tar.gz -C /opt/module
echo ;export MAVEN_HOME=/opt/module/apache-maven-3.8.6; >> /etc/bashrc
echo ;export PATH=$PATH:$MAVEN_HOME/bin; >> /etc/bashrc
configfile=/opt/module/apache-maven-3.8.6/conf/settings.xml
sed -i -e ;s|external:http:||; $configfile
sed -i -e ;s|http://0.0.0.0/|https://maven.aliyun.com/repository/public|; $configfile
sed -i ;164d; $configfile
#!/bin/bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
chmod ug;x ~/.nvm/nvm.sh
source ~/.nvm/nvm.sh
nvm install --lts
node --version
#!/bin/bash
yum install golang -y
go env -w GOPROXY=https://goproxy.cn,direct
#!/bin/bash
curl -o kubectl https://s3.cn-north-1.amazonaws.com.cn/amazon-eks/1.23.7/2022-06-29/bin/linux/amd64/kubectl
chmod ;x ./kubectl
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$PATH:$HOME/bin
echo ;export PATH=$PATH:$HOME/bin; >> ~/.bashrc
kubectl version --short --client
#!/bin/bash
curl --silent --location ;https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz; | tar xz -C /tmp
sudo mv /tmp/eksctl /usr/local/bin
#!/bin/bash
yum install ruby -y
wget https://aws-codedeploy-cn-north-1.s3.cn-north-1.amazonaws.com.cn/latest/install
chmod ;x install
./install auto
service codedeploy-agent status
#!/bin/bash
source /usr/share/bash-completion/bash_completion
source <(kubectl completion bash)
. <(eksctl completion bash)
complete -C ;/usr/local/bin/aws_completer; aws
#!/bin/bash
sudo alternatives --install /usr/bin/java java /usr/java/default/bin/java 500
sudo alternatives --config java