반응형
Data volum없는 버전
- timezone 세팅
- 사용자추가
- ssh 패스워드 사용 허용 설정
- 추가한 사용자에게 sudo 권한 추가
- Cloudwatch Agent 설치
sudo -s
## time zone
echo "ZONE=\"Asia/Seoul\"" > /etc/sysconfig/clock
echo "UTC=true" >> /etc/sysconfig/clock
ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
#-----------이 부분 변수 값만 변경-------------
USER_NAME="gsnadmin"
#---------------------------------
USER_NAME1="$(tr [a-z] [A-Z] <<< "${USER_NAME:0:1}")"
USER_NAME2=${USER_NAME:1}
PASSWD=${USER_NAME1}${USER_NAME2}
echo ${USER_NAME}
echo ${VOL_NAME}
useradd ${USER_NAME}
echo ${PASSWD}'123!@#' | passwd ${USER_NAME} --stdin
#mv /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
cat /etc/ssh/sshd_config_bak | sed -r 's/^PasswordAuthentication no/PasswordAuthentication yes/g' > /etc/ssh/sshd_config
#참고------------------------------------------------
#PasswordAuthentication yes
#------------------------------------------------
service sshd restart
#cp /etc/sudoers /etc/sudoers_bak
#vi /etc/sudoers
echo ${USER_NAME}" ALL=(ALL) ALL" >> /etc/sudoers
#참고 ------------------------------------------------
#USER_NAME ALL=(ALL) ALL
#------------------------------------------------
yum install -y wget
#--------cloud watch cw install---------------
cd /home/centos
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
rpm -i /home/ec2-user/amazon-cloudwatch-agent.rpm
wget https://prod-cwagent-json.s3.ap-northeast-2.amazonaws.com/config.json
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/home/ec2-user/config.json -s
#------------------------
Data volum을 LV까지 해주는 버전
- timezone 세팅
- 사용자추가
- ssh 패스워드 사용 허용 설정
- 추가한 사용자에게 sudo 권한 추가
- data용 EBS를 lv설정
- Cloudwatch Agent설치
#!/bin/bash
sudo -s
echo "ZONE=\"Asia/Seoul\"" > /etc/sysconfig/clock
echo "UTC=true" >> /etc/sysconfig/clock
ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
yum install -y lvm2
#------------------------
USER_NAME="stonresize"
VOL_NAME="stonresize2"
#---------------------------------
USER_NAME1="$(tr [a-z] [A-Z] <<< "${USER_NAME:0:1}")"
USER_NAME2=${USER_NAME:1}
PASSWD=${USER_NAME1}${USER_NAME2}
echo ${USER_NAME}
echo ${VOL_NAME}
useradd ${USER_NAME}
echo ${PASSWD}'123!@#' | passwd ${USER_NAME} --stdin
mv /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
cat /etc/ssh/sshd_config_bak | sed -r 's/^PasswordAuthentication no/PasswordAuthentication yes/g' > /etc/ssh/sshd_config
service sshd restart
#------------------------------------------------
#PasswordAuthentication yes
#------------------------------------------------
cp /etc/sudoers /etc/sudoers_bak
#vi /etc/sudoers
echo ${USER_NAME}" ALL=(ALL) ALL" >> /etc/sudoers
#------------------------------------------------
#USER_NAME ALL=(ALL) ALL
#------------------------------------------------
VOL_NAME="somansa01"
mkdir /somansa
sudo chown -R ${USER_NAME}:${USER_NAME} /somansa
pvcreate /dev/nvme1n1
vgcreate ${VOL_NAME}-vg01 /dev/nvme1n1
lvcreate --extents 100%FREE -n ${VOL_NAME}-vg01/${VOL_NAME}-lv01
sudo mkfs.ext4 /dev/${VOL_NAME}-vg01/${VOL_NAME}-lv01
#blkid
#vi /etc/fstab
DATA_UUID=$(blkid -t TYPE=ext4 -s UUID -o value)
echo "UUID="${DATA_UUID}" /data ext4 defaults 0 0" >> /etc/fstab
#------------------------------------------------
#UUID=2538ea59-729d-4555-af0f-430bc5aded10 /data ext4 defaults 0 0
#------------------------------------------------
mount -a
df -h
yum install -y wget
#--------cloud watch cw install---------------
cd /home/centos
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
rpm -i /home/ec2-user/amazon-cloudwatch-agent.rpm
wget https://prod-cwagent-json.s3.ap-northeast-2.amazonaws.com/config.json
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/home/ec2-user/config.json -s
#------------------------
반응형
'IT > AWS' 카테고리의 다른 글
[AWS] SSM(session manager)를 통하여 EC2 접근하기 (0) | 2021.08.12 |
---|---|
[AWS] amazonlinux2의 로그(/var/log)를 AWS cloudwatch logs로 백업하기 (0) | 2021.08.11 |
[AWS] S3를 사용하여 웹호스팅 하기 (0) | 2021.08.04 |
[AWS] S3 Object 권한 이슈 (0) | 2021.08.04 |
[AWS] EKS Cluster kube config등록 (0) | 2021.06.28 |