메뉴 건너뛰기

Bigdata, Semantic IoT, Hadoop, NoSQL

Bigdata, Hadoop ecosystem, Semantic IoT등의 프로젝트를 진행중에 습득한 내용을 정리하는 곳입니다.
필요한 분을 위해서 공개하고 있습니다. 문의사항은 gooper@gooper.com로 메일을 보내주세요.


* shellscript파일
-----------------
#!/bin/bash
export CLASSPATH=${CLASSPATH}:/opt/cloudera/parcels/CDH-7.1.7-1.cdh7.1.7.p1000.24102687/lib/hive/auxlib/ImpalaJDBC42.jar
export CLASSPATH=${CLASSPATH}:~/gooper/libs/*.jar

kinit -kt /var/lib/keytab/hadoop.keytab hadoop
if [ $? != 0 ]; then
   echo "kinit fail"
   exit -1
else
   echo "kinit sucess"
fi

java ImpalaTest
------------------------

*참고1 : 아래 프로그램을 수행하는데 필요한 jar파일 목록(os폴더 위치 : ~/gooper/libs)
(/opt/cloudera/parcels/CDH/jars에 있으니 복사해서 사용한다, 이곳에은 동일한 jar가 바젼별로 존재하므로 이 경로를 classpath에 통째 포함시켜서 사용하면 실행시 NoSuchMehod같은 오류가 발생한다)
commons-collections-3.2.2.jar         hadoop-common-3.1.1.7.1.7.1000-141.jar            hive-service-3.1.3000.7.1.7.1000-141.jar      log4j-1.2-api-2.17.1.jar
commons-configuration2-2.1.1.jar      hive-exec-3.1.3000.7.1.7.1000-141.jar             hive-service-rpc-3.1.3000.7.1.7.1000-141.jar  log4j-api-2.17.1.jar
commons-lang-2.6.jar                  hive-jdbc-3.1.3000.7.1.7.1000-141.jar             httpclient-4.5.13.jar                         log4j-core-2.17.1.jar
guava-27.0.1-jre.jar                  hive-jdbc-3.1.3000.7.1.7.1000-141-standalone.jar  jaxb-impl-2.2.3-1.jar                         slf4j-log4j12-1.7.30.jar
hadoop-auth-3.1.1.7.1.7.1000-141.jar  hive-metastore-3.1.3000.7.1.7.1000-141.jar        libthrift-0.9.3.jar


* 참고2 : java source(파일명 ImpalaTest.java)
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ImpalaTest {
        private static String connectionUrl;
        private static String jdbcDriverName;

        private static void loadConfiguration() throws IOException {
                try {
          // connectionUrl = "jdbc:impala://impalajdbcnode.gooper.com1050;AuthMech=3;UID=hadoop;PWD=;UseSasl=0";             // 해당 user로 동작함
          connectionUrl = "jdbc:impala://impalajdbc_l4.gooper.com:21051/default;AuthMech=1;KrbRealm=GOOPER.COM;KrbHostFQDN=impala_jdbc_node.gooper.com;KrbServiceName=impala;" ;
             //impalaJDBC4.1의 경우
             //jdbcDriverName = "com.cloudera.impala.jdbc41.Driver";
             //ImpalaJDBC4.2의 경우
             jdbcDriverName = "com.cloudera.impala.jdbc.Driver";
                } finally {
                      System.out.println("test");
                }
        }

        public static void main(String[] args) throws IOException, ClassNotFoundException, SQLException {
                selectTest();
        }
        public static void selectTest() throws IOException {
                String sqlStatement = "select count(*) as 'abcd' from test.test_table;";
                loadConfiguration();

                System.out.println("\n=============================================");
                System.out.println("Using Connection URL: " + connectionUrl);

                Connection con = null;
                Statement stmt = null;

                try {

                        Class.forName(jdbcDriverName);
                        con = DriverManager.getConnection(connectionUrl);
                        stmt = con.createStatement();
                        ResultSet rs = stmt.executeQuery(sqlStatement);

                        System.out.println("\n== Begin Query Results ======================");
                        System.out.println("rs:"+rs);
                        // print the results to the console
                        while (rs.next()) {
                                // the example query returns one String column
                                System.out.println(rs.getString(1));
                        }

                        System.out.println("== End Query Results =======================\n\n");

                } catch (SQLException e) {
                        e.printStackTrace();
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
                        try {
                                stmt.close();
                                con.close();
                        } catch (Exception e) {
                                // swallow
                        }
                }
        }
}
번호 제목 글쓴이 날짜 조회 수
741 VirtualBox에 ubuntu 설치 하기 (12.10) file 구퍼 2013.03.04 1768
740 우분투 root 패스워드 설정하기 구퍼 2013.03.04 1314
739 메이븐 (maven) 설치 및 이클립스 연동하기 file 구퍼 2013.03.06 2280
738 Hadoop 설치 및 시작하기 file 구퍼 2013.03.06 1951
737 Hadoop wordcount 소스 작성 file 구퍼 2013.03.06 1888
736 이클립스에서 생성한 jar 파일 hadoop 으로 실행하기 file 구퍼 2013.03.06 2836
735 ExWordCount jar파일 file 구퍼 2013.03.06 1336
734 Hadoop Cluster 설치 (Hadoop+Zookeeper+Hbase) file 구퍼 2013.03.07 3995
733 Hive+mysql 설치 및 환경구축하기 file 구퍼 2013.03.07 2722
732 Hive 사용법 및 쿼리 샘플코드 구퍼 2013.03.07 2991
731 hadoop 설치(3대) file 구퍼 2013.03.07 2613
730 hadoop설치시 참고사항 구퍼 2013.03.08 2131
729 MySQL 다운로드 및 리눅스에서 간단 컴파일 설치 구퍼 2013.03.08 1869
728 checking for termcap functions library... configure: error: No curses/termcap library found 구퍼 2013.03.08 4120
727 ../depcomp: line 512 exec : g++ : not found 구퍼 2013.03.08 2062
726 org.apache.hadoop.hdfs.server.common.InconsistentFSStateException: Directory /tmp/hadoop-root/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible. 구퍼 2013.03.11 14781
725 HBase 설치하기 – Pseudo-distributed file 구퍼 2013.03.12 2644
724 HBase 설치하기 – Fully-distributed 구퍼 2013.03.12 3548
723 Cacti로 Hadoop 모니터링 하기 file 구퍼 2013.03.12 2367
722 org.apache.hadoop.hbase.PleaseHoldException: Master is initializing 구퍼 2013.03.15 2668

A personal place to organize information learned during the development of such Hadoop, Hive, Hbase, Semantic IoT, etc.
We are open to the required minutes. Please send inquiries to gooper@gooper.com.

위로