AWS EC2 고정 ip 부여하기 & 원격 클라이언트로 접속

생성한 EC2 instance에 고정 ip를 부여해서 80포트를 열고 웹서버를 설치 외부에서 ip로 접근할 수 있다.

의외로 간단.


좌측 메뉴의 가장 아래에 있는 NETWORK & SECURITY에서 Elastic IPs를 선택.
그럼 우측에 할당된 ip목록이 나온다. 당연히 하나도 없으니까 비어있고.
위의 Allocate New Address를 누르면 정말 만들거냐고 묻는 팝업창이 뜬다. Yes, Allocate을 누르면 하나 생성돼서 목록이 바뀐다.
여기서 끝이 아니고 방금 생성한 그 아이디를 선택하고 위의 Associate Address를 클릭.

그럼 아래와 같은 창이 뜨는데,


인스턴스나 네트워크 인터페이스를 선택해주고 Associate을 눌러서 연결해준다.

연결한 다음에 일단 터미널에서 접속이 잘 되나 테스트

~/Project> ssh -i awskey/up_db_server.pem ubuntu@54.238.205.73
The authenticity of host '54.238.205.73 (54.238.205.73)' can't be established.
RSA key fingerprint is 7e:18:69:de:df:0d:b9:c5:22:9c:f1:88:62:df:05:43.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '54.238.205.73' (RSA) to the list of known hosts.
Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-12-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu Oct 31 08:12:07 UTC 2013

  System load:  0.0               Processes:           69
  Usage of /:   12.0% of 7.75GB   Users logged in:     0
  Memory usage: 26%               IP address for eth0: 172.31.24.62
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

  Use Juju to deploy your cloud instances and workloads:
    https://juju.ubuntu.com/#cloud-saucy

Last login: Thu Oct 31 08:12:07 2013 from 211.106.111.78
ubuntu@ip-172-31-24-62:~$ 

client에서 접속하려면 security groups에서 inbound 포트를 열어줘야 한다. 다른 포스팅에 있는 것과 마찬가지로 현재 instance가 어떤 Security group을 사용하고 있는지 확인하고 그 Security group을 골라서 Inbound rule에 MySQL을 추가하면 된다.
그렇게 해서 클라이언트로 원격 접속을 시도했으나 계속 실패. 이유는 MySql 설정에서 서버에 접속이 가능한 ip가 로컬로 한정되어 있던 것. /etc/mysql/my.cnf 파일을 살짝 수정해 줘야 한다.

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address  = 127.0.0.1

저 bind-address 부분의 로컬 ip를 0.0.0.0으로 바꿔주면 오케이.

그 뒤에 생성한 사용자로 접근 권한이 있는 db를 선택해서 외부의 클라이언트를 이용해 접속이 가능하다.

댓글 없음:

댓글 쓰기