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
Related
I am trying to configure MySQL databases using the Master-Slave replication. Before I realized that I had to set up my environment using this replication, I already have 2 separate servers running their own MySQL DB. Each of these servers are configured the exact same. The MySQL DB are configured with hundreds of tables.
Is there a way that i can set up (Master-Slave) Replication using the configured DB's? Or will i have to start from scratch and configure the replication first and then load in all the DB tables?
You can delete all data from one of the servers. Remaining one with the data will be your Master. Then use mysqldump to backup all the data and insert it to the slave.
Take a look for the detailed instructions on the page below:
https://livecaller.io/blog/how-to-set-up-mysql-master-slave-replication/
If the data is exactly same in both the MySQL database then you can start master slave replication, but you need to be sure that the data is same. MySQL will not check that, and if there is some discrepancy in the primary key then it will throw error immediately after next DML statement.
To be on a safer side, drop the database from one server, and restore it using the MySQL dump of another server. This will give the surety that database is same on both the server.
Take the reference from the below link to establish replication between two MySQL servers.
https://www.digitalocean.com/community/tutorials/how-to-set-up-master-slave-replication-in-mysql
I wrote some functions that work with SQL. I test the functions using testthat and an in memory SQLite database. However, some functions cannot be tested using SQLite because SQLite does not support the ALTER TABLE command.
Is there some way to simulate a mySQL database in memory the same way that one can simulate a SQLite?
> DBI::dbConnect(RSQLite::SQLite(), ":memory:")
<SQLiteConnection>
Path: :memory:
Extensions: TRUE
> DBI::dbConnect(RMySQL::MySQL(), ":memory:")
Error in .local(drv, ...) :
Failed to connect to database: Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
If not, how does one write automatic tests for mySQL functions?
You can't make a whole MySQL instance run in memory like the SQLite :memory: option. MySQL is designed to be a persistent database server, not an ephemeral embedded database like SQLite.
However, you can use MySQL's MEMORY Storage Engine for individual tables:
CREATE TABLE MyTable ( ...whatever... ) ENGINE=MEMORY;
The equivalent in RMySQL seems to be the dbWriteTable() method, but as far as I can tell from documentation, you can't specify the ENGINE when creating a table with this method. You'll have to create the table manually in the MySQL client if you want to use the MEMORY engine.
But you should be aware that every storage engine has some subtle different behavior. If any of your tests depend on features of InnoDB, you won't be able to simulate them with the MEMORY storage engine (e.g. row-level locking, foreign keys, fulltext search).
Read the manual on the MEMORY storage engine: https://dev.mysql.com/doc/refman/5.7/en/memory-storage-engine.html
P.S.: Ignore the suggestions on that manual page to use NDB Cluster. It may be faster, but it requires multiple servers and special database design to achieve that performance. It's much harder to set up.
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.
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
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.