실습 전 EMR 비용이 부담이라면 기능적인 것만 테스트 할 것이라면 Hadoop standalone 모드로 기능적인 것은 할 수 있음. 하둡 공식 메뉴얼에 보면 싱글 노드 클러스터 세팅하는 방법을 제공한다.
EMR의 Multi Primary 또는 hue를 사용하지 않을거면 별도의 MySQL을 생성하지 않아도 된다.
별도의 MySQL 서버가 있다면, 꼭 RDS 를 이용하지 않아도 괜찮다.
RDS를 이용하는 경우
mysql cli로 접속
hive 용 데이터베이스 생성
create database hive;
show databases;
create user 'hive' identified by 'hive';
grant all privileges on hive.* to 'hive'@'%';
AWS console에서 EMR > Create cluster 한 뒤 진행.
다음은 실습에서 구성한 패키지이다. 버전이 조금 바뀌더라도 기본 기능에는 큰 차이는 없지만, 일부 차이가 있을 수 있다.
EMR version: emr-6.8.0
패키지
실습에서는 m5.xlarge(4 vCore, 16 GiB memory, EBS only storage) 인스턴스 타입을 설정했다.
EBS Root Volumn: 50GB
이후 실습은 지정된 리소스 풀에서 사용하는 것을 실습할 것이기 때문에 Task Node는 지정하지 않았다.
Core node 의 수에 따라서 hdfs-site.xml의 dfs.replication이 달라진다. 매뉴얼 참고
AWS servcie
를 선택EMR
선택이렇게 만든 자신의 Role 을 EMR 생성 단계에서 불러와서 사용하면 된다.
💡 EMR_EC2_DefaultRole 이 안보이는 경우 다음 순서를 따라서 생성하면 된다.EMR_EC2_DefaultRole 이 안보이는 경우 다음 순서를 따라서 생성하면 된다.
위의 EMR_DefaultRole 생성시 했던 방법과 동일한 순서로 1~3번까지 진행한다.
Step 1: Select trusted entity
AWS servcie
를 선택EMR Role for EC2
선택Step 2: Add Permission 에서 기본 선택되어있는 AmazonElasticMapReduceforEC2Role 그대로 진행
Step 3: Name, review, and create 에서 이름을 지정하고 Next
생성한 자신의 Role 설정화면에 접속해서 권한 추가
이렇게 만든 자신의 Role 을 EMR 생성 단계에서 불러와서 사용하면 된다.
클러스터의 로그를 S3 에 저장하도록하면 EC2에 각각 접속하지 않고도 쉽게 확인할 수 있다. 또한 예상치못한 에러로 종료되었을 때도 원인을 파악하는 데 사용할 수 있다. 인스턴스가 자동으로 줄어들거나, 종료되었을때 로그를 볼 수 없는 경우에는 문제해결이 어렵다.
EMR용 로그 디렉토리를 만들고 연결해주자.
HA를 위해 Multi Primary(Master)를 구성하는 경우, 메타데이터의 데이터베이스가 외부에 있어야 한다. 데이터베이스는 MySQL 만 가능하다.
HA(multi primary)를 위한 MySQL database, user
생성 구성을 따라한 뒤 아래 내용으로 설정을 추가한다.hive-site 설정 변경 매뉴얼
ℹ️ 아래 jupyter 설정은 필수는 아니어서 강의영상에서는 나오지 않았다. EMR의 jupyter hub는 내부적으로 sparkmagic 을 이용하는데, sparkmagic에서 사용하는 auth 정보를 설정할 수 있다.jupyter 설정 매뉴얼 (필수 아님)
jupyter
, password: anVweXRlcg==
(jupyter 를 encode한 값) 을 사용한다.jovyan
jupyter
아래는 위 매뉴얼을 반영한 설정이다. 이것을 Software settings - optional 메뉴에 설정으로 추가한다.
--configurations $yourconfig.json
과 같이 파라미터로 설정한다.$your_rds_hostname
을 자신의 mysql host name으로 수정한다.[
{
"Classification": "hive-site",
"Properties": {
"javax.jdo.option.ConnectionDriverName": "org.mariadb.jdbc.Driver",
"javax.jdo.option.ConnectionPassword": "hive",
"javax.jdo.option.ConnectionURL": "jdbc:mysql://$your_rds_hostname:3306/hive?createDatabaseIfNotExist=true",
"javax.jdo.option.ConnectionUserName": "hive"
}
},
{
"Classification":"jupyter-sparkmagic-conf",
"Properties": {
"kernel_python_credentials" : "{\"username\":\"jupyter\",\"base64_password\":\"anVweXRlcg==\",\"url\":\"http:\/\/localhost:8998\",\"auth\":\"None\"}"
}
}
]
jupyter
, password: anVweXRlcg==
(jupyter 를 encode한 값) 을 별도로 수정할 수 있다.[
{
"Classification": "hive-site",
"Properties": {
# key-value configs..
}
},
{
"Classification": "oozie-site",
"Properties": {
# key-value configs..
}
}
]
클러스터 생성시 EC2인스턴스를 EMR 에서 직접 생성하기 때문에 대시보드에서 다음과 같이 확인한다.
자세한 내용은 환경별로 매뉴얼 을 따라한다.
ssh -i $your_key_file hadoop@$your_primary_node
다음 명령어로 hdfs 명령어가 잘 수행된다면, 잘 설치된 것이다.
hdfs --help
hdfs version
hdfs dfs --help
hdfs dfs -ls /
다음 명령어로 hdfs 의 active namnode를 확인할 수 있다.
hdfs haadmin -getAllServiceState
다음 명령어로 yarn의 active resource manager를 확인할 수 있다.
yarn rmadmin -getAllServiceState
Primary 노드의 다음 경로에서 설정 파일을 확인할 수 있다.
ls -al /etc/hadoop/conf/
해당 EMR 인스턴스 > Events
메뉴로 들어가서 이벤트의 순서와 실패의 이유를 확인할 수 있다.
원래 시도했던 설정을 유지하고, 실패한 부분만 변경하고 싶다면
AWS Cli 로 표현된 설정을 보고 싶다면
❗ clone시에 password 설정은 masking(*) 된다. password 설정은 clone 뒤에 다시 수동으로 고쳐줘야한다.
❗ The "map public IP on launch" feature for subnet …
위 에러를 만난다면, 선택한 subnet 의 설정을 변경해야한다. 다음 두 설정을 선택으로 변경한다.
Enable auto-assign public IPv4 address
Enable resource name DNS A record on launch
bootstrap-actions
디렉토리가 있는 경로에서 찾아야 한다.사례
bootstrap-actions
2023-01-07 08:56:15,457 INFO i-08026ffb5574067e2: new instance started
2023-01-07 08:56:20,504 ERROR i-08026ffb5574067e2: failed to start. bootstrap action 1 failed with non-zero exit code.
2023-01-07 08:57:51,195 INFO i-0e1dce635b968dcff: new instance started
2023-01-07 08:57:51,195 INFO i-0e1dce635b968dcff: all bootstrap actions complete and instance ready
2023-01-07 08:57:52,055 INFO i-05bc2ee0e9e775662: new instance started
2023-01-07 08:57:52,055 INFO i-05bc2ee0e9e775662: all bootstrap actions complete and instance ready
2023-01-07 08:57:52,286 INFO i-07e46be496b950d83: new instance started
2023-01-07 08:57:52,286 INFO i-07e46be496b950d83: all bootstrap actions complete and instance ready
puppet 로그 확인
Error: Could not connect to the database: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
2023-01-07 09:03:27 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema] (info): Starting to evaluate the resource (984 of 1138)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Initializing the schema to: 3.1.0
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Metastore connection URL: jdbc:mysql://de-emr.cgfpdcibdeds.ap-northeast-2.rds.amazonaws.com:3306/hive?createDatabaseIfNotExist=true
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Metastore Connection Driver : org.mariadb.jdbc.Driver
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Metastore connection User: hive
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Underlying cause: java.sql.SQLSyntaxErrorException : Could not connect to address=(host=de-emr.cgfpdcibdeds.ap-northeast-2.rds.amazonaws.com)(port=3306)(type=master) : Access denied for user 'hive'@'%' to database 'hive'
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): SQL Error code: 1044
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:94)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hive.beeline.schematool.HiveSchemaTool.getConnectionToMetastore(HiveSchemaTool.java:163)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hive.beeline.schematool.HiveSchemaTool.testConnectionToMetastore(HiveSchemaTool.java:174)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hive.beeline.schematool.HiveSchemaToolTaskInit.execute(HiveSchemaToolTaskInit.java:53)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hive.beeline.schematool.HiveSchemaTool.main(HiveSchemaTool.java:353)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at java.lang.reflect.Method.invoke(Method.java:498)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Caused by: java.sql.SQLSyntaxErrorException: Could not connect to address=(host=de-emr.cgfpdcibdeds.ap-northeast-2.rds.amazonaws.com)(port=3306)(type=master) : Access denied for user 'hive'@'%' to database 'hive'
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.createException(ExceptionFactory.java:62)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.util.exceptions.ExceptionFactory.create(ExceptionFactory.java:192)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1392)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:635)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:150)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.Driver.connect(Driver.java:89)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at java.sql.DriverManager.getConnection(DriverManager.java:664)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at java.sql.DriverManager.getConnection(DriverManager.java:247)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:88)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): ... 10 more
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): Caused by: java.sql.SQLException: Access denied for user 'hive'@'%' to database 'hive'
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1681)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readPacket(AbstractQueryProtocol.java:1543)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.getResult(AbstractQueryProtocol.java:1506)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.additionalData(AbstractConnectProtocol.java:1136)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.postConnectionQueries(AbstractConnectProtocol.java:890)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.createConnection(AbstractConnectProtocol.java:595)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1387)
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): ... 16 more
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (notice): *** schemaTool failed ***
2023-01-07 09:05:04 +0000 Puppet (err): '/usr/lib/hive/bin/schematool -dbType mysql -initSchema -verbose' returned 1 instead of one of [0]
2023-01-07 09:05:04 +0000 /Stage[main]/Hadoop_hive::Init_metastore_schema/Exec[init hive-metastore schema]/returns (err): change from 'notrun' to ['0'] failed: '/usr/lib/hive/bin/schematool -dbType mysql -initSchema -verbose' returned 1 instead of one of [0]