배운 내용/클라우드 교육

11월21일 - DB 실습

JooJY 2023. 11. 21. 14:20

https://guide.ncloud-docs.com/docs/database-database-5-10

 

클라우드 외부에서 DB Server 접속

 

guide.ncloud-docs.com

퍼블릭에 서버 만들고 프라이빗에 있는 db 접속하기

서버 ACG 수정하기

22, 80, ICMP 열기

phpMyAdmin를 통한 접속

요거 따라하기

# yum -y install httpd php mysql php-mysql
# yum -y install epel-release
# systemctl restart httpd

아파치 실행중인지 확인하기

# systemctl status httpd
  • 서비스를 시작한 후 웹 브라우저에서 'http://(서버공인IP주소)'에 접속하여 아파치 서버가 정상적으로 작동하는지 확인해 주십시오.

yum install phpMyAdmin
systemctl reload httpd

아래 명령을 차례대로 실행하여 phpMyAdmin.conf에 접속을 허용할 IP를 설정해 주십시오

여기가 중요

conf.d 폴더로 이동

cd /etc/httpd/conf.d

원본 저장하기

cp -a phpMyAdmin.conf phpMyAdmin.conf.origin

vi 편집기로 편집하기

vi phpMyAdmin.conf

4개 부분을 내가 현재 접속할 IP로 수정하기(구글에서 내 아이피 검색)(CMD에서 ipconfig 아님)

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1 # 접속 허용할 IP로 수정
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1 # 접속 허용할 IP로 수정
     Allow from ::1
   </IfModule>
</Directory>

<Directory /usr/share/phpMyAdmin/setup/>
   <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
       Require ip 127.0.0.1 # 접속 허용할 IP로 수정
       Require ip ::1
     </RequireAny>
   </IfModule>
   <IfModule !mod_authz_core.c>
     # Apache 2.2
     Order Deny,Allow
     Deny from All
     Allow from 127.0.0.1 # 접속 허용할 IP로 수정
     Allow from ::1
   </IfModule>
</Directory>

 

수정 후 아파치 재부팅

# cd ~

# systemctl reload httpd
  • 리로드한 후 웹 브라우저에서 'http://서버공인IP/phpMyAdmin'에 접속하여 phpMyAdmin 화면이 정상적으로 표시되는지 확인해 주십시오. 정상적으로 접속되지 않는 경우 서버의 ACG 설정과 phpMyAdmin.conf 설정을 확인해 주십시오.
  • 화면 나오는 것 확인

이거 아직 로그인이 안된다.

cd /etc/phpMyAdmin
vi config.inc.php

DB 콘솔에서 private 도메인, 접속 포트 확인하고 넣는다.

$cfg['Servers'][$i]['host']          = '접속할 MySQL Server의 Private 도메인'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port']          = '접속할 MySQL Server의 접속 포트';          // MySQL port - leave blank for default port

-- 예시
$cfg['Servers'][$i]['host']          = 'db-d3oh.beta-cdb.ntruss.com'; // MySQL hostname or IP address
$cfg['Servers'][$i]['port']          = '3306';          // MySQL port - leave blank for default port

그래도 로그인이 안된다. ACG 수정을 해야 한다.

DB ACG에 서버 ACG를 추가해서 서버에서 DB로 접속 가능하도록 수정해야 한다.

다시 로그인하면 접속이 된다.

클라우드 DB는 콘솔에서 모든 것을 처리해야 한다.