인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

동환님의 프로필 이미지
동환

작성한 질문수

AWS로 구축하는 MSA와 컨테이너 오케스트레이션

RDS 읽기 복제본 - 읽기 트래픽 분산 (실습)

rds read replica 접속 에러

작성

·

86

0

시작 템플릿 - 유저 데이터에 write와 read 설정하고 오토스케일링 돌렸는데 에러가 납니다.

 

시작 템플릿에서 테스트로 인스턴스 생성해서 확인해보니 write는 문제 없는데 read에서 에러가 나옵니다. (여러번 설정해봄)

ssh 접속해서 아래부분 실행 시 에러... 무슨 문제 일까요?

java -jar build/libs/aws-msa-monolithic-prac-0.1.jar \
--spring.datasource.write.jdbc-url=jdbc:postgresql://goopang-rds-db.*****.ap-northeast-2.rds.amazonaws.com:5432:goopang_database \
--spring.datasource.write.username=postgres \
--spring.datasource.write.password=**** \
--spring.datasource.read.jdbc-url=jdbc:postgresql://goopang-rds-db-read-replica.****.ap-northeast-2.rds.amazonaws.com:5432:goopang_database \
--spring.datasource.read.username=postgres \
--spring.datasource.read.password=****
2024-08-31T02:10:00.841Z ERROR 2333 --- [           main] j.LocalContainerEntityManagerFactoryBean : Failed to initialize JPA EntityManagerFactory: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect')
2024-08-31T02:10:00.907Z ERROR 2333 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect')
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1770) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:598) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:520) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1156) ~[spring-context-6.0.9.jar!/:6.0.9]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:931) ~[spring-context-6.0.9.jar!/:6.0.9]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:608) ~[spring-context-6.0.9.jar!/:6.0.9]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:733) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:435) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1305) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1294) ~[spring-boot-3.1.0.jar!/:3.1.0]
        at com.prac.monolithic.awsmsamonolithicprac.AwsMsaMonolithicPracApplicationKt.main(AwsMsaMonolithicPracApplication.kt:13) ~[classes!/:0.1]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
        at java.base/java.lang.reflect.Method.invoke(Method.java:569) ~[na:na]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) ~[aws-msa-monolithic-prac-0.1.jar:0.1]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:95) ~[aws-msa-monolithic-prac-0.1.jar:0.1]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) ~[aws-msa-monolithic-prac-0.1.jar:0.1]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65) ~[aws-msa-monolithic-prac-0.1.jar:0.1]
Caused by: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] due to: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect')
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:277) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:239) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:216) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.boot.model.relational.Database.<init>(Database.java:45) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.getDatabase(InFlightMetadataCollectorImpl.java:229) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:197) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:166) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:1380) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:1451) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:66) ~[spring-orm-6.0.9.jar!/:6.0.9]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:376) ~[spring-orm-6.0.9.jar!/:6.0.9]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:409) ~[spring-orm-6.0.9.jar!/:6.0.9]
        at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:396) ~[spring-orm-6.0.9.jar!/:6.0.9]
        at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:352) ~[spring-orm-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1816) ~[spring-beans-6.0.9.jar!/:6.0.9]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1766) ~[spring-beans-6.0.9.jar!/:6.0.9]
        ... 24 common frames omitted
Caused by: org.hibernate.HibernateException: Unable to determine Dialect without JDBC metadata (please set 'javax.persistence.jdbc.url', 'hibernate.connection.url', or 'hibernate.dialect')
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:188) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:87) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:274) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:34) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:119) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:264) ~[hibernate-core-6.2.2.Final.jar!/:6.2.2.Final]
        ... 39 common frames omitted

2024-08-31 02:10:01,061 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2024-08-31 02:10:01,064 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3.9/site-packages/cloudinit/config/cc_scripts_user.py'>) failed
Cloud-init v. 22.2.2 finished at Sat, 31 Aug 2024 02:10:01 +0000. Datasource DataSourceEc2.  Up 122.75 seconds
[root@ip-10-0-1-8 aws-operation-prac]# 

 

 

답변 1

0

Burger님의 프로필 이미지
Burger
지식공유자

안녕하세요 동환님!

 

우선 유저 데이터 부분을 확인해봤습니다.

--spring.datasource.write.jdbc-url=jdbc:postgresql://goopang-rds-db.*****.ap-northeast-2.rds.amazonaws.com:5432:goopang_database \

--spring.datasource.read.jdbc-url=jdbc:postgresql://goopang-rds-db-read-replica.****.ap-northeast-2.rds.amazonaws.com:5432:goopang_database \

spring boot의 jdbc url 입력 부분에 포트번호 입력 뒤 / 가 입력되어야하는데 : 이 입력된것 같습니다

수정된 코드는 아래와 같습니다.

java -jar build/libs/aws-msa-monolithic-prac-0.1.jar \
--spring.datasource.write.jdbc-url=jdbc:postgresql://goopang-rds-db.*****.ap-northeast-2.rds.amazonaws.com:5432/goopang_database \
--spring.datasource.write.username=postgres \
--spring.datasource.write.password=**** \
--spring.datasource.read.jdbc-url=jdbc:postgresql://goopang-rds-db-read-replica.****.ap-northeast-2.rds.amazonaws.com:5432/goopang_database \
--spring.datasource.read.username=postgres \
--spring.datasource.read.password=**** \
--spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

추가적으로 문제가 발생하면 또 문의 남겨주세요!

 

감사합니다.

 

 

 

동환님의 프로필 이미지
동환
질문자

안녕하세요
말씀해주신 부분 수정하니 잘 되었습니다.
수업자료에 있는 텍스트 그대로 복붙해서 사용하다보니 문제가 있었네요
수정이 필요할 것 같습니다. 감사합니다.

Burger님의 프로필 이미지
Burger
지식공유자

죄송합니다. 해당 부분 확인을 못했었네요...
동환님 덕분에 오타 수정 됐습니다.
감사합니다!

동환님의 프로필 이미지
동환

작성한 질문수

질문하기