반응형

Security Group (보안 그룹) 설정을 내 IP로 하면

당연히 EC2 인스턴트에 무리없이 연결 될 줄 알았는데...

 

웹 상에서 인스턴스에 연결은 안되었다....

 

친절한 오류메시지 내역

We were unable to connect to your instance. Make sure that your instance’s network settings are configured correctly for EC2 Instance Connect. For more information, see Task 1: Configure network access to an instance.

 

당연하게도

 

Security Group에서 22(SSH)를 0.0.0.0/0 으로 설정하면 된다...

 

하지만 이것은 치명적인 보안 문제가 있기 때문에 권장하지 않습니다.

 

해결방법

 

1. 우선 보안 그룹(Security Group)에서 22포트에 대해 0.0.0.0/0으로 설정 뒤 웹으로 연결 한다.

2. 다음 명령어를 사용하여 내가 접속하는 웹의 접근 IP 대역을 체크한다. (서울 리전 기준!)
  curl -s https://ip-ranges.amazonaws.com/ip-ranges.json| jq -r '.prefixes[] | select(.region=="ap-northeast-2") | select(.service=="EC2_INSTANCE_CONNECT") | .ip_prefix'

13.209.1.56/29

 

  ※ Amazone Linux 2 AMI 설치 내역임 

  ※ 설치된 명령어(curl, jd )

      * 없을 경우 #> yum install jd 와 같은 명령어로 설치함.

 

3. 위의 설정 값을 기준으로 다시 보안 그룹 (Security Group)을 재 설정한다.

   * xxx.xxx.xxx.130 은 내 IP로 설정한 고정 IP 주소

   * 위의 웹 접근시 나온 정보 (13.209.1.26/29)를 SSH 접근하도록 설정하면 EC2를 웹에서 연결 가능함.

 

   

 

참고 URL : https://stackoverflow.com/questions/66884055/elastic-beanstalk-ec2-instance-connect-cant-connect

 

Elastic Beanstalk & EC2 Instance Connect: Can't connect

I created an Elastic Beanstalk environment from Visual Studio and need to login to service the underlying ec2 vm. I don't have an credentials for the server, so I wanted to use EC2 Instance Connect...

stackoverflow.com

참고 URL : https://aws.amazon.com/ko/premiumsupport/knowledge-center/ec2-instance-connect-troubleshooting/

 

EC2 Instance Connect를 사용한 연결 문제 해결

Amazon EC2 Instance Connect를 사용하여 Amazon EC2(Amazon Elastic Compute Cloud) 인스턴스에 연결하려고 할 때 다음 오류가 표시됩니다. “ 인스턴스 연결을 설정하는 동안 문제가 발생했습니다. 로그인하지 못

aws.amazon.com

 

반응형
반응형

관련 URL : https://mariadb.com/kb/en/library/installing-the-connect-storage-engine/

 

Installing the CONNECT Storage Engine

Installing the CONNECT storage engine.

mariadb.com

 

MariaDB 10.2 버전부터 connect engine 이 반영되었습니다.

 

CONNECT 스토리지 엔진은 MariaDB가 외부나 원격 데이터에 접근할 수 있습니다.

 

이 스토리지 엔진은 테이블 파티셔닝, MariaDB 가상 컬럼을 지원하며 ROWID, FILEID 및 SERVID와 같은 특수 컬럼을 정의할 수 있습니다.

 

0. CONNECT 스토리지 엔진 설치 여부

 

# mysql -uroot -p 접속

 

MariaDB [ (none) ] > show engines; 

 

 

위 출력 결과에 Engine 컬럼에 CONNECT가 보이지 않는다면 설치되어 있지 않은 상태입니다.

 

현재 이 글을 쓸때 10.3 버전의 최신은 10.3.19이나 버그가 발생하여 10.3.18로 다운 그레이드하여 사용합니ㅏㄷ.

 

1. 플러그인 패키지 설치

 

MariaDB를 설치할 때 레파지토리를 이미 구성하였다고 가정합니다.

 

패키지 설치를 위해 Centos 7 이하 yum / 이상 dnf 를 사용합니다.

 

아래 명령을 수행하면 설치를 위한 ha_connect.so 파일등이 로컬에 설치됩니다.

 

현재 이 문서는 Centos 7 로 수행합니다.

 

# yum install -y MariaDB-connect-engine

 

or

 

특정 버전 지정 설치 (DB 버전과 일치해야 합니다!)

# yum install -y MariaDB-connect-engine-10.3.18

 

 

2. 플러그인 설치

기본적으로 플러그인은 자동으로 설치되지 않습니다.

 

두가지 방법이 있습니다.

 

방법1. INSTALL SONAME  명령 수행하기

 

다음 명령을 통해 ha_connect 를 설치합니다.

 

# mysql -uroot -p

 

MariaDB [(none)]> install soname 'ha_connect';
Query OK, 0 rows affected (0.000 sec)

 

방법2. 환경 설정 파일(my.cnf / server.cnf) 에 추가

[mariadb]

...

plugin_load_add = ha_connect

 

설치후에는 다음과 같이 조회합니다.

 

MariaDB [(none)]> show engines;

 

Engine 컬럼에 CONNECT가 보이면 정상적으로 설치되어 해당 엔진을 사용할 수 있는 상태입니다.

 

3. 플러그인 제거

 

다음 명령을 통해 제거 할 수 있습니다.

 

MariaDB [(none)]> UNINSTALL SONAME 'ha_connect';

 

MariaDB [(none)]> show engines;

 

 

4. 종속성 설치

 

10.2 버전대에는 10.3 이후 버전대와 다르게 unixODBC 라이브러리를 별도로 설치했는거 같습니다.

현재 10.3 버전은 설치 시점에 종속성이 unixODBC라 같이 설치되었기 때문에 별도로 작업은 하지 않습니다.

 

별도 작업시에는 아래 명령을 통해 설치합니다.

 

# yum install unixODBC

 

 

5. 외부 테이블 연결

 

관련 정보 : https://mariadb.com/kb/en/library/connect-table-types/

 

CONNECT Table Types

 

mariadb.com

위의 내용 중 

 

CONNECT MYSQL Table Type: Accessing MySQL/MariaDB Tables

 

부분을 살펴보겠습니다.

 

A Maria 10.4 DB서버 : 192.168.10.191

B Maria 10.3 DB서버 : 192.168.10.194

 

B 서버에서 A서버 test 데이터베이스에 json_test 테이블을 Connect 하겠습니다.

 

※ 무한 루프를 피하기 위해 MYSQL 본인 자체를 참조하지 않도로 주의하세요!

 

※ Connect는 BLOC or TEXT 컬럼은 지원하지 않습니다. 

ERROR 1163 (42000): Storage engine CONNECT doesn't support BLOB/TEXT columns

 

A 서버 json_test 테이블 CREATE 구문

 

CREATE TABLE `connect_test` (
`id` INT(11) NULL DEFAULT NULL,
`DT` DATE NULL DEFAULT NULL,
`TXT` VARCHAR(1000) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci'
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;

아래 INSERT 문장을 통해 3줄의 데이터를 입력합니다.

INSERT INTO connect_test VALUES (1, CURDATE(), '첫번재 입력');

INSERT INTO connect_test VALUES (2, CURDATE(), '두번재 입력');

INSERT INTO connect_test VALUES (3, CURDATE(), '세번재 입력');

 

COMMIT;

 

 

B 서버에 test 데이터베이스에 new_connect_test를  아래와 같이 명령어를 입력하여 적용합니다.

CREATE TABLE test.`new_connect_test` ( 
`id` INT(11) NULL DEFAULT NULL, 
`DT` DATE NULL DEFAULT NULL, 
`TXT` VARCHAR(1000) NULL DEFAULT NULL COLLATE 'utf8_unicode_ci' 

COLLATE='utf8_unicode_ci' 
ENGINE=CONNECT

table_type=mysql

dbname=test
tabname=connect_test
connection='mysql://root:비밀번호@192.168.10.191'

table_type : Mariadb / mysql 일 때 명시

dbname : 원본(A DB 서버) 데이터베이스 명

tabname : 원본(A DB 서버) 테이블 명

 

아래 실행 결과와 같이 오류가 발생하지 않으면 정상적으로 데이터가 조회됩니다.

 

조회

 

위와 같이 연결된 상태에서 A원본 서버에 데이터를 한건 지우고 나면 B 서버에서도 동일하게 한건 지워진 상태로 조회됩니다.

 

또한 B서버에서 new_connect_test 에 데이터를 입력/삭제하여도 동일하게 원본서버에 connect_test 테이블도 변경됩니다.

 

좀더 상세한 것은 아래 링크를 참조하면 됩니다.

 

https://mariadb.com/kb/en/library/connect-mysql-table-type-accessing-mysqlmariadb-tables/

 

CONNECT MYSQL Table Type: Accessing MySQL/MariaDB Tables

Accessing a MySQL or MariaDB table or view

mariadb.com

 

반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB JSON 컬럼 및 함수들  (0) 2019.11.04
MariaDB 테이블 백업 및 복구  (0) 2019.11.01
MariaDB 우편번호 Import 하기  (0) 2019.11.01
MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
반응형

출처 : http://cafe.naver.com/prodba

sysdba로 접속하여 알아낸다...

또한 결과는 alert.log로 찍힌다 ~

$> sqlplus '/as sysdba'

sql>


create trigger logon_denied_to_alert
after servererror on database
declare
message varchar2(4000);
begin
    select 'ip='||sys_context('userenv','ip_address')||',host='||sys_context('userenv ','host')||',osuser='||SYS_CONTEXT('USERENV', 'OS_USER')
    into message
    from dual;
IF (ora_is_servererror(1017)) THEN
message := to_char(sysdate,'Dy Mon dd HH24:MI:SS YYYY') || ' logon denied for ' || message;
sys.dbms_system.ksdwrt(2,message);
end if;
end;
/
반응형

'Database > ORACLE' 카테고리의 다른 글

오라클 TRANSLATE  (0) 2011.03.31
오라클 자격증 신청 절차  (0) 2011.03.28
테이블 정의서 추출 생성 스크립트  (0) 2011.01.06
ORACLE SESSION Monitoring SQL  (0) 2011.01.05
오라클 공부 방법  (0) 2010.12.08
반응형


- 이클립스 상에서 오라클 DATABASE를 바로 연결하여 사용하는 방법을 기술한다.

설치에 사용된 이클립스...




Help -> SoftWare Update를 클릭


1. Add Site를 누름 

2.http://quantum.sourceforge.net/update-site/ (Location) 부분에 입력

3. OK를 클릭

4. Quantum 을 검색 한뒤

5. Install 버튼 클릭



6. NEXT를 클릭


7. 사용 조건에 승인하고 Finish 를 클릭 -> 설치 완료
  
    - 아래와 같이 설치가 완료되어 다시 시작한다는 메시지가 뜨면 YES를 누르고 이클립스를 다시 시작함.
  


8. 이클립스 상에서 Quantum 플러그인 추가

window -> open Perspective -> other



9. Other open Perspective 화면에서 Quantum DB를 선택함.


10. 정상적으로 설치되었음을 확인할 수 있다.(연결정보 설정은 당연히 현재는 안되어 있음)

11. 연결 정보를 다음과 같이 추가함.
Database Bookmarks 탭상에서 빈공간에서 마우스 우클릭 -> New Bookmark... 클릭


12.  ADD driver을 눌러 추가하자 ! (우리는 오라클을 추가할 것이다.)



13. Add External Jar.. 늘 눌러 ojbc14.jar를 추가함.


14. 아래와 같이 정보를 설정하고 Finish를 누름



15. 입력한 Oracle 드라이버를 선택후 Next> 를 클릭


16. 다음과 같이 DB 연결 정보를 입력
     userid : 연결ID
     passwd : 연결ID의 암호
     HOSTNAME : DB서버 주소
     PORT : 오라클 리스너 포트(일반적으로 1521)
     DATABASE NAME : SID NAME


17. 북마크에서 사용할 이름을 지정함


18. 17번까지의 설정을 모두 마치면 자동으로 연결되고(정보가 틀리지 않았다면)
     Quantum SQL Queries View상에서 쿼리를 입력후 초록색 ▶ 버튼을 누르면 하단의 Quantum Table View 상에서 데이터가 조회됨.





P.$ :
1. MySql 연결시에는 mysql-connector-java-5.1.6-bin.jar 파일을 다운받음
2. 드라이버 선택 -> com.mysql.jdbc.Driver
3. 연결 포트는 3306임.
반응형
반응형
Oracle C++ Call Interface (OCCI) is an Application Programming Interface (API) that provides C++ applications access to data in an Oracle database. This API is a significant improvement to the Oracle Call Interface (OCI) API as far as ease of use is concerned. Engineers who have written JDBC (Java Database Connectivity) code will find the OCCI API to be quite similar to that of JDBC

1) The table that is used in the example code is:

Code: SQL
CREATE TABLE EMP(
    empno     NUMBER,
    ename     VARCHAR2(10),
    hireDate  Date);
2) Database Query : Select the contents of the EMP table

Code: Cpp
#include <DbManager.h>
#include <iostream>

using namespace std;

using namespace oracle::occi;

const string sqlString("select empno, ename, hiredate from emp");

const string dateFormat("DD-MON-YYYY HH24:MI:SS");

int main(int argc, char **argv)

{
    if (argc != 2)
    {
        cerr << "\nUsage: " << argv[0] << " <db-user-name>\n" << endl;
        exit(1);
    }
   
    // Initialize OracleServices
   
    DbManager* dbm = NULL;
   
    OracleServices* oras = NULL;
   
    Statement *stmt = NULL;
   
    ResultSet *resultSet = NULL;
   
    try
    {
       
        // Obtain OracleServices object with the default args.
       
        dbm = new DbManager(userName);
       
        oras = dbm->getOracleServices();
       
        // Obtain a cached connection
       
        Connection * conn = oras->connection();
       
        // Create a statement
       
        stmt = conn->createStatement(sqlString);
       
        int empno;
       
        string ename;
       
        Date hireDate;
       
        string dateAsString;
       
        // Execute query to get a resultset
       
        resultSet = stmt->executeQuery();
       
        while (resultSet->next())
        {
           
            empno = resultSet->getInt(1)// get the first column returned by the query;
           
            ename = resultSet->getString(2)// get the second column returned by the query
           
            hireDate = resultSet->getDate(3)// get the third column returned by the query
           
            dateAsString="";
           
            //You cannot check for null until the data has been read
           
            if (resultSet->isNull(1))
            {
                cout << "Employee num is null... " << endl;
            }
            if (resultSet->isNull(2))
            {
                cout << "Employee name is null..." << endl;
            }
            if (resultSet->isNull(3))
            {
                cout << "Hire date is null..." << endl;
            }
            else
            {
                dateAsString=hireDate.toText(dateFormat);
            }
            cout << empno << "\t" << ename << "\t" << dateAsString << endl;
           
        }
       
        // Close ResultSet and Statement
       
        stmt->closeResultSet(resultSet);
       
        conn->terminateStatement(stmt);
       
        // Close Connection and OCCI Environment
       
        delete dbm;
       
    }
    catch (SQLException& ex)
    {
        if (dbm != NULL)
        {
            dbm->rollbackActions(ex, stmt, resultSet); // free resources and rollback transaction
        }
    }
    catch (ExoException& ex1)
    {
        cerr << "\nCaught ExoException:\n" << ex1.getExceptionText() << endl;
        exit(2);
    }
   
    return 0;
}

반응형

+ Recent posts