different rds instance and joinig two tables - mysql

I have two tables named user and user_posts.These two tables are in different amazone rds instance. I wants to join these two tables. Is it possible to write mysql join using laravel framework?
Thanks in advance!

This isn't possible with RDS.
MySQL has a FEDERATED storage engine that allows one server to access tables on another server, but it is disabled in RDS for MySQL.
The Federated Storage Engine is currently not supported by Amazon RDS for MySQL.
— http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html
Clarificarion:
When using the FEDERATED storage engine to allow tables with data on one server to appear to exist on another server -- thus allowing the data to be queried from a server that does not actually have a persistent copy of the data -- only the server that does not have the actual data needs to actually support the FEDERATED engine.
This means that while an RDS instance can't access the data from another server using FEDERATED, a non-RDS MySQL server can access data on an RDS instance using a FEDERATED table configured on the non-RDS server, with the table configured to retrieve data from RDS.
This is because -- from the perspective of the server with the actual data -- the connection from the server using FEDERATED looks like an ordinary client connection. The data is retrieved using normal queries, so FEDERATED support does not need to be available on that side of the link.
This means that a non-RDS server running MySQL can access the data on one or more RDS servers, using FEDERATED tables.
I use this routinely for generating reports that join tables on two (and in one case, three) different RDS instances.
FEDERATED tables do have limitations -- they appear to the server that is fetching the remote data as being very similar to MyISAM tables, in the sense that they do not support transacrions and any query that would result in a full table scan will actually fetch the entire remote table for each query, which can obvioisly get out of hand... so they have to be used with diligence and discretion.
This may not be useful for the scenario described, since it would require the addition of a third server, but it is a solution that is not completely ruled out when RDS makes up a portion of the database infrastructure. The information above is also true when using RDS/MariaDB and RDS/Aurora for MySQL.

Related

MySQL NDB Cluster : Disable Replication for a table / database

In our project we are planning to introduce MySQL NDB cluster to have 99% uptime for our multiple applications dependent on MySQL.
So MySQL is being deployed in two machines. In both the machines Data Node, Management Server and SQL node is deployed and configured to form a cluster as shown in the below snippet.
Based on my understanding replication of data will be done for the data stored in Data Nodes. But can we restrict the replication only to a set of tables or database?
Reason for this query is, there are two applications that are dependent on MySQL, where only one application needs this replication and the other doesn't need this feature because it should connect to a standalone instance of MySQL to store it's local data which shouldn't be replicated as it would cause problem to the application running in another machine.
Please share your thoughts on this.
Though we have deployed MySQL NDB Cluster, the mysqld still supports INNODB storage type. So in order to achieve the above requested need, we created tables explicitly with Storage Engine by mentioning in CREATE TABLE statement like below. This overrode the storage configuration mentioned in my.cnf.
CREATE TABLE IF NOT EXISTS `CDS` (
`CD_ID` bigint(20) NOT NULL,
PRIMARY KEY (`CD_ID`)
) ENGINE=innodb

Synchronize one table between MySQL database(s)

We have the requirement to synchronize the data in a table across multiple MySQL databases. One of the databases would be the source, and all others need to have the synchronized data for one of the tables.
We have multiple databases used in microservice architecture, and they all need to have a local copy of a specific table in their database, and not the entire database itself, hence read replica or multi-AZ configuration is not the solution.
Database: MySQL hosted on AWS RDS
Is there any managed service by AWS or another vendor that can be used to accomplish this? Or do we have to write a custom script to do that?
It's a simple MySQL replication. But you have to replicate the whole database. So create a MySQL database in AWS and enable Multi-AZ replication and activate the automatic snapshots.
The A-Z Replication is synchronous. When you use a "Read replica" it's asynchronous. So if you have very important data you should enable Multi-AZ replication.
https://aws.amazon.com/rds/details/multi-az/?nc1=h_ls
I think you have to either isolate the table in one database and replicate that database or write a custom script.
If I were writing a custom script I would look at the binlog functionality. Here are some helpful links:
https://dev.mysql.com/doc/refman/5.7/en/mysqlbinlog.html
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_LogAccess.Concepts.MySQL.html (at the bottom).

MySQL Group Replication or a Single Server is enough?

I'm planning to create a system which tracks visitors clicks into the database. I'm expecting around 1M inserts/day into the Database.
On the backend, I'll have an analytics system which will analyze all the data that's been collected over the days/weeks/months/years.
My question is: is it a practical approach to have 2 different MySQL Servers + 1 Web server? MySQL Server A would insert the clicks into it's DB and it would be connected to MySQL Server B by group replication, so whenever I create reports, etc on MySQL Server B, it doesn't load Server A heavily.
These 2 Database servers would then be connected to the Web Server which would handle all the click requests and displaying the backend reports also.
Is it a practical solution, or is it better to have one bigger server to handle all the MySQL data? Or have multiple MySQL servers that are load balancing each other? Anything else perhaps?
1M inserts/day is not a high load by modern standards. That's less than 12 per second on average.
On sufficiently powerful servers with fast storage and proper tuning of MySQL options, you can expect to support at least 100x that load with a single MySQL server.
A better reason to use multiple MySQL servers is redundancy. Inevitably, any MySQL server needs to be upgraded, or you might have hardware failures and need to replace a disk, or other components. To avoid downtime, you should have a standby database server, which stays in sync with the primary server, either using MySQL replication or by disk-level replication like DRBD.

It's posible to use Federated table in MySQL NDB Cluster

I'm developing a application that needs two diferent databases, this is because one of this databases is per client and the other one is a generic database.
I'm thinking in make a MySQL NDB Cluster and i need to know if it's possible to uses some Federated tables in the Cluster or all must use ndbcluster engine.
If this is not posible, how can i make joins with tables that are in other host using ndbcluster?
Please forget about, why i need this schema (one databse per client and one generic database) because i spent a lot of time thinking which should be the best schema for my application i choosed this one.
Thanks in for your help!!!
MySQL Cluster uses a full version of mysqld (slightly modified), which includes all storage engines included on a standalone version. So the question for your answer is YES, you can have some tables in FEDERATED storage engine, or any other storage engine.
However, only tables with storage engine=ndbcluster will be replicated to all the api nodes connected to the cluster.
The federated approach with a cluster of two api nodes could work, but keep in mind that only those tables with the same storage engine can have referential integrity (FK) between them.
Which version of MySQL Cluster are you using? It is recommended using always the latest GA release (now 7.4.12)
Regards

Linking different schemas from different mysql servers into only one mysql server so he can manage the queries

I have 5 different schemas, eventually I want to separate them into different servers for specific RAM and CPU assignment depending on the load.
How can I configure so I can show a schema from a different server into a "front" mysql server?
MySQL Proxy:
The MySQL Proxy is an application that communicates over the network using the MySQL network protocol and provides communication between one or more MySQL servers and one or more MySQL clients.
However, note:
 Warning
MySQL Proxy is currently an Alpha release and should not be used within production environments.
The FEDERATED Storage Engine:
The FEDERATED storage engine lets you access data from a remote MySQL database without using replication or cluster technology. Querying a local FEDERATED table automatically pulls the data from the remote (federated) tables. No data is stored on the local tables.
Replication:
Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves).
However, note:
In this environment, all writes and updates must take place on the master server. Reads, however, may take place on one or more slaves.