MySQL Master/Slave with Castle Activerecord - mysql

I have an existing web application using Castle Activerecord to interact with a single MySQL database. The Database has recently been reconfigured to replicate to a number of Slaves.
How do you configure Castle Activerecord to direct writes to the MySQL Master and reads to the MySQL Slaves or are there other ways of achieving Master/Slave operation transparently in this setup?

I have never done this, but I think this kind of things are better handled at the DB-driver level. Indeed, Connector/J has a specific ReplicationDriver for this purpose. The Connector/NET documentation has a rather vague reference to replication:
Host, Server, Data Source, DataSource, Address, Addr, Network Address:
The name or network address of the
instance of MySQL to which to connect.
Multiple hosts can be specified
separated by &. This can be useful
where multiple MySQL servers are
configured for replication and you are
not concerned about the precise server
you are connecting to. No attempt is
made by the provider to synchronize
writes to the database so care should
be taken when using this option. In
Unix environment with Mono, this can
be a fully qualified path to MySQL
socket file name. With this
configuration, the Unix socket will be
used instead of TCP/IP socket.
Currently only a single socket name
can be given so accessing MySQL in a
replicated environment using Unix
sockets is not currently supported.

Related

Linking MySql Database to Azure

I have a Database using MySql, however i want to migrate to azure MySql which i know is possible, I am new to Azure.
My question if i make changes to the local database, is it possible to automatically update the tables in azure with same changes?
I want to link both Database together and any changes effected on any will affect the other.
This functionality is available and is called Data-In replication. Please see: How to configure Azure Database for MySQL Data-in Replication for instructions on how to configure this functionality. Please see the Limitations and Considerations but the following are the requirements:
The master server version must be at least MySQL version 5.6.
The master and replica server versions must be the same. For example, both must be MySQL version 5.6 or both must be MySQL version 5.7.
Each table must have a primary key.
Master server should use the MySQL InnoDB engine.
User must have permissions to configure binary logging and create new users on the master server.
If the master server has SSL enabled, ensure the SSL CA certificate provided for the domain has been included in the mysql.az_replication_change_master stored procedure. Refer to the following examples and the master_ssl_ca parameter.
Ensure the master server's IP address has been added to the Azure Database for MySQL replica server's firewall rules. Update firewall rules using the Azure portal or Azure CLI.
Ensure the machine hosting the master server allows both inbound and outbound traffic on port 3306.
Ensure the master server has a public IP address, the DNS is publicly accessible, or has a fully qualified domain name (FQDN).

MySQL Cluster SQL node failover

I'm trying to setup a mysql cluster for a web application to avoid having a single point of failure. The Mysql documentation says:
MySQL Cluster does not provide any sort of automatic failover between
SQL nodes. Your application must be prepared to handle the loss of SQL
nodes and to fail over between them.
The docs say the data is still accessible via the NDB API, but if my app is configured to point to a mysql server, how can i setup some type of loadbalancing/failover for multiple SQL nodes.
The failover functionality is provided by client connector libraries. For example, if you're using Java, your JDBC connection string can provide a list of MySQL host names. Here's documentation. http://dev.mysql.com/doc/connector-j/5.1/en/connector-j-config-failover.html
With ado.net and python, you'll need a setup called MySQL Fabric. This explains the connection string monkey business you'll need. http://dev.mysql.com/doc/connector-net/en/connector-net-programming-fabric.html
Or, you can write specific application connection code that detects connection timeouts, and then tries another MySQL server.

Replicate mnesia database to Mysql

I have installed ejabberd on an AWS EC2 instance and am using the smack library to connect to it with my android app. At the moment the ejabberd server is using mnesia as the database, however I want to perform some complex queries on some of the data (mainly the MUC room names), as SQL will predominantly the best solution for this, I was wondering if it was possible to replicate the required data to an external MySQL database that I could then query.
Is this possible or am i better looking at a different approach to this problem?
There is no module built into ejabberd to replicate data in Mnesia to MySQL. However, the usual approach is to use the backend you need for each feature. If you want mod_muc to store data into MySQL instead of Mnesia, you can just change the backend to odbc (which means it will store data for that module in a relational database).
You can refer to ejabberd documentation for MUC module: http://docs.ejabberd.im/admin/guide/configuration/#modmuc
Once your MySQL is configured and schema is loaded, you can set db_type to odbc on a case by case basis to choose MySQL for that module.

mysql replication without direct connection

I am trying to replicate a remote mysql database to my internal mysql server.
The problem is that I do not have a direct connection available between both mysql servers.
Internally, there is a custom server application (which I've developped my self). This server application allows incoming connections on 1 port only (with ssl encryption). Once the connection is made, custom written commands can be executed over that connection (like sending specific backup files, remote browsing, etc... just client/server stuff).
Now I need to add mysql replication, but there is no direct connection possible. I was thinking to write something like a PORTFORWARD command in my server app which would transfer the replication data to the mysql server interally, something like this:
remote mysql server replication process->remote client application->internal server application-> internal mysql server.
That would probably work, but I think that's gonna be a fragile solution, all connect/disconnect events will need to be forwarded in all circumstances.
Any better ideas for this?
Thanks,
Vincent
Replication in the sense do you want the Remote server database data's to your Internal server?
if So you could follow Backup and Restore MySQL Database Using mysqldump
Or If want your client server application to access the remote server database follow this Can't remotely connect through SQL Server Management Studio

Securely connect MS Access database front-end to MySQL back-end on web host?

We have a fairly simple M$ Access db, split into front-end (forms, reports, etc.) and back-end (tables). Currently looking for a way to get the tables with all the critical data off of one desktop and hopefully into a MySQL database on our web host, and be able to connect to it from multiple PCs (still probably only one or two people connecting to it at any give time), and eventually, hopefully, migrate to a web application when time allows. Many of the examples I've read about people connecting an Access db front-end to a MySQL back-end seem to imply that they are doing so on a LAN, probably behind a firewall, etc.
Is it at all safe to connect a M$ Access front-end to a MySQL backend when that mysql server is running on a remote web host? Does the ODBC connector take care of encryption?
TIA,
Monte
You could use putty to mount a ssh tunnel to your mysql server and redirect the remote mysql port to your machine.
Using putty is pretty straightforward:
Give it your mysql server dns name as the host and go to "Connection/SSH/Tunnels", there you define the local port to connect in the "Source Port" field (e.g. 3307).
In the the "Destination" field put the dns name of your mysql server followed by a colon and the port mysqld is running in (e.g. mysql.example.org:3306).
Save this as a profile then connect and the remote mysql port will be availbable locally on port 3307.
Just make sure you restrict the user because by default he will have an ssh shell on the server.
Setting up key authentication would also be practical because you won't have to enter a password to connect to the server (but be sure to protect your key on disk by encrypting it).
EDIT: It seems the mysql odbc connector support ssl, you could use that too but I'd personnally choose to use SSH anyway as you will have it already on your mysql server.