Amazon ec2 DB connection between two instances with hibernate - amazon-ec2

I have one two ec2 instances. One is a web service with DB and another one is a simple web module. Web service connects to DB locally while I want web module instance to connect to the web service instance DB. Both have a stack of Java- Hibernate inside Tomcat with MySQL as database.
I have created one security group and assigned that to both the server. Configuration for DB is as below:
MySQL - TCP Protocol - 3306 port - Source as the Group ID for the same configuration.
The hibernate configuration for web module looks like below:
<property name="connection.url">jdbc:mysql://<web service server ip>:3306/<db name></property>
<property name="connection.username">root</property>
<property name="connection.password">password</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
But I am not able to connect to the DB. If I change the server configuration to accept any IP connection then I can connect but with security group, it fails.
Any pointers?

I think that your DB server is setup to refuse external connections.
Solution

Related

Spring Boot doesn't release DB connection

We user AWS RDS Proxy to connect postgres database from Spring Boot.I assume RDS proxy is configured with session pooling.
As RDS proxy is alternative for pgBouncer Spring boot application doesn't worry about connection pool. So it uses SimpleDriverDataSource
It looks like RDS proxy doesn't share the connections between the DB users. Because when I look at pg_stat_activity my spring boot holds many connections even after the restart. This is understandable that rds proxy hold connections rather than the application. Also the client count is zero in RDS proxy metrics. Does it mean RDS proxy never share the connections in the connection pool with other user?
It makes depriving of connections for other applications.
Is there configurations in RDS proxy to release connection to solve this ?

Error occurred while trying to connect to db in aws

I deployed war file to aws which is spring project. and I installed oracle rds on aws. When I try to connect to oracle rds on aws from my local computer with root-context.xml. It worked. It can connect to oracle rds on aws from my local computer with my spring project. But when I try to run spring war file on aws. http://ip address:8080 it gives me an error message. Would you please help me with this?
I have been struggling with this for three days...any help would be appreciated.
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
here is the root-context.xml
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sf.log4jdbc.sql.jdbcapi.DriverSpy"></property>
<property name="url"
value="jdbc:log4jdbc:oracle:thin:#database ip address on aws:1521:orcl" />
<property name="username" value="id" />
<property name="password" value="password" />
</bean>
aws security inbound setting:
http tcp 80 0.0.0.0/0
custom tcp rule 8080 0.0.0.0/0
custom tcp rule 8080 ::/0
[database setting][1]
[security group][2]
[1]: https://i.stack.imgur.com/869s0.png
[2]: https://i.stack.imgur.com/hqaeU.png
After trying and trying - created another RDS DB, copying existing one, created another VPC to try it out there are few things that need to be considered (obviously, they are all documented, but it's not an easy task to find all the information, since - at least in my case - it wasn't documented in one place:
If you want your DB instance in the VPC to be publicly accessible, you must enable the VPC attributes DNS hostnames and DNS resolution (existing VPC can be changed too).
Check the VPC security group and enable the DB access port (in case of the standard MS SQL deployment - 1433) - since starting the 2013, VPC security groups have replaced the RDS security group.
Check thoroughly the RDS DB information for Security Groups, port and other info that can be misidentified.
Somehow not obvious (at least for me at first), but when using SQL Management Studio to access the RDS DB - do not use the ":1433" or other port identifier at the end of DB instance name.
If nothing of the above works, ask the question here and keep googling... :)
Most of the info found here: http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSVPC.html

How Ignite cluster works

I m novice to apache ignite.
My requirement is to replace the coherence cache with the ignite cache.
As per my understanding to make the cache distributed used the below cache configuration.
<bean class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
<property name="addresses">
<list>
<!-- In distributed environment, replace with actual host IP address. -->
<value>1xx.xxx.xx.xxx</value>
<value>1xx.xxx.xx.xxx</value>
<value>1xx.xxx.xx.xxx</value>
<value>1xx.xxx.xx.xxx</value>
<value>myapplicationport</value>
</list>
</property>
</bean>
with same configuration Integrating spring boot with ignite developed a microservice and deployed in all the 4 servers.
Could see only in one server my microservice is up and running while in the other servers ignite got stopped.
Even i tried without providing the port only the ip address.
case2:
Deployed only in one server with one ip in cache configuration the cache stopped with 2 days of deployment.
What should be done to make the cache to be up always.
Because we are also planning to migrate a schema of DB into cache.
Please help on this

How to configure Spring XD to connect remote Gemfire

I had configured the Spring-XD, application context.xml to connect to remote gemfire db. I am unable to connect to remote DB. It goes and connect to local gemfire which comes as part of Spring XD installation. Please can anyone assist what must be wrong.
Configuration to disable local gemfire and configure to connect remote :
/spring-xd-1.2.0.RELEASE/xd/config/modules/modules.yml
gemfire:
useLocator: true
host: remote-ip-address
port: 44444
**Configuration to remote connection gemfire - spring-module.xml**
<bean id="template" class="org.springframework.data.gemfire.GemfireTemplate">
<property name="region" ref="restaurants" />
</bean>
<util:properties id="gemfire-props">
<prop key="log-level">warning</prop>
</util:properties>
<gfe:cache properties-ref="gemfire-props" />
<gfe:cache-server bind-address="localhost" port="44444" />
<gfe:replicated-region id="restaurants">
</gfe:replicated-region>
When we deploy custom moudules and run it on spring-xd shell which access and store object in gemfire template it goes and saves it in local gmefire instead of remote gemfire database. Please can anyone guide or suggest right way of confuguring gemfire db.
Regards,
Cleophus P.
XD modules that access Gemfire, e.g., the gemfire source and gemfire sink use client-server configuration.
You have a remote cache server and the module is a client. Connecting via a locator requires all servers and clients in the grid to share the locator addresses. Assuming your Gemfire server installation already has one or more locators running, the module context should contain a client-cache configured with the same locator addresses as the remote cache server. If you are not familiar with Gemfire client-server topology, I suggest you review the product documentation and get a simple stand alone example running against your cache server before attempting to deploy your XD modules.

ActiveMQ embedded on cluster instance

I'm implementing a project with ActiveMQ embedded in a cluster instance with schema DB shared in MuleSoft 3.5.1.
The broker has been configured with spring bean
<spring:beans>
<spring:bean class="org.apache.activemq.xbean.BrokerFactoryBean"
id="broker">
<spring:property value="classpath:testActivemq.xml"
name="config" />
<spring:property value="true" name="start" />
</spring:bean>
</spring:beans>
I have tested the system in local mule server stand alone to simululate cluster.
The problem is when I make the deploy the first broker, it grabs an exclusive lock on a table to ensure that no other ActiveMQ broker can access the database at the same time,but the other broker doesn't finish the deploy process and so when I try to undeploy the first broker the server goes in block.
How to resolve my issue?
What you are looking at is ActiveMQ's built in master-slave functionality. To start multiple brokers in the same VM, you need to point their storage locations to different databases (if using JDBC storage) or filesystem locations (if using KahaDB or LevelDB).
See the following on how to do that:
JDBC http://activemq.apache.org/jdbc-master-slave.html
KahaDB http://activemq.apache.org/kahadb.html
LevelDB http://activemq.apache.org/leveldb-store.html

Resources