I'm currently using tomcat7 configured with it's own jdbc-pool as described here: http://www.tomcatexpert.com/blog/2010/04/01/configuring-jdbc-pool-high-concurrency .
I also have a master/master configuration for mysql (replicated) and I was wondering on how to (if possible..) configure tomcat to failover between the 2 mysql's . so for example if mysql1 goes down, open all the pool again against mysql2 .
Any ideas on how to achieve that?
I also don't mind switching to another jdbc implementation if not tomcat's.
You can try C-JDBC and its doc.
HA-JDBC seems to fit the bill. Its a library which provides high availability and fail-over features among many listed on the website. Connection pooling is one aspect which needs to be looked upon.
Related
mysql is a common database and it supports kinds of configuration and tune parameters such as character_set_server, innodb_log_file_size and so on. These backend parameters are set under e.g. /etc/mysql/mysql.cnf configuration file and below the [mysqld] section, and take effect after service mysql restart.
There exists a situation where a single mysql server is providing database service for more than one application (on the same physical machine), and each of the applications may has its own officially recommended backend parameter settings.
However, it may happens when the parameters of different applications differ from each other and it may become worse when there are conflicts between application settings, for example, app A needs utf8 as the character encoding method and app B is using another one.
So, is there any mysqld configuration method to support this situation, or the right way is to start multiple mysql instances with each tuned for one application.
Thanks a lot!
I found the mysqld_multi solution from mysql official site solved my problems, which can start multiple mysqld processes and each one could has its own configurations.
Please forgive my ignorance but I do not have a ton of experience with MySQL. I am a web developer but overall I have pretty much just installed MySQL or spun up an RDS instance, connected to it and everything just works. However I am currently being tasked with creating a complete backup of our primary server (essentially high availability with a load balancer etc). So I thought now might be a good time to change how I haver our MySQL setup to take advantage of having 2 servers. Currently our MySQL lives on our primary servers and that will probably stay that way for now, however my goal with this new setup is to have 2 identical servers, both running the application and both having the exact same MySQL data structure / data. I want to be able to essentially open up the web application on one server, make a change, see it on the other or vica versa.
From my research it looks like what I want is called "Master-Master Replication" however it seems as if this is an older / more outdated approach? Every article I read is from ~2010-2012 and most people say it is depreciated and I should use Percona XtraDB Cluster, MySQL Group Replication, or Galera Cluster etc. I basically have no idea what any of that means and I am looking for the easiest way to get Master-Master type setup working. On top of that even if I wanted to use regular Master-Master replication it seems as if this is something specific to MySQL and not Percona which is what I actually use.
I know plenty about dev ops and can get everything but the MySQL up and running in no time but I would love some insight on the best way to do this. Currently servers are running Centos 7, Percona 5.7, Apache 2.4.
The easiest way to start is to setup a percona xtradb cluster with proxysql.
Percona xtradb cluster handles all the problems that are present in basic MySQL Master-Master Replication.
Both Galera and Percona Xtradb CLuster are same, as they use the same galera plugin, Only that Percona has customized it and added some extra features like in built proxysql( kind of load balancer for database).
Let's clear up one thing first. Percona is MySQL. If a feature is available on Oracle MySQL (the community version is what I am referring to here), then it is also available on Percona. Think of the two like a cake: MySQL is the base "cake" and Percona is the frosting/sprinkles/etc that go on top.
That being said you can absolutely do Master/Master using Percona MySQL. The standard/best practice is to configure this in active/hot-standby. Meaning, do not write to both nodes at the same time. Your application, or your middleware/proxy, must isolate writes to only one node. This will save you insane headaches when/if replication breaks.
ProxySQL is not a Percona product, but we do support it 100%. You can place ProxySQL in front of your M/M and setup the correct query rules to only route to one MySQL.
You are correct that the most modern solution here, and in my opinion, an easier solution, is to set up a 3-node Percona XtraDB Cluster (PXC). Again, Galera MySQL is the "cake" and PXC is all the extras on top. Group Replication is pie (just to continue the analogy.)
We consider a 3-node PXC fronted with ProxySQL to be one of the best HA solutions out there for MySQL. It is still best practice to only write to one node, and utilize the other 2 for read-only queries. If the primary node goes down, each of the other two have an up-to-the-transaction copy of the data. Again, ProxySQL helps route the traffic if primary goes down.
Backups can be taken from any PXC node using Percona XtraBackup in a non-blocking/hot fashion.
The MySQL 5.7 documentation makes reference to, and describes, a program called mysql_ssl_rsa_setup, which is supposed to make SSL certificate and key generation for encryption much "easier".
I cannot find this anywhere in the source distribution, so my guess is that it hasn't been added to the 5.7 distribution yet. Has anyone had any luck finding such a program or, failing that, can describe the process it takes in generating certificates? I have tried doing this via multiple methods without much luck (right now I'm getting ERROR 2026).
The code can be found here:
https://github.com/mysql/mysql-server/blob/5.7/client/mysql_ssl_rsa_setup.cc
How mysql_rsa_ssl_setup fits into the larger picture of enabling easier TLS connections is described here:
http://mysqlblog.fivefarmers.com/2015/04/09/ssltls-in-mysql-5-7/
The mysql_ssl_rsa_setup executable attempts to generate key material required for TLS connections to MySQL Server. It is typically invoked by package deployment scripts, rather than directly called by end users. It is part of the larger effort in MySQL Server 5.7 to enable TLS connections by default
I'm needing to replicate data from a primary Amazon RDS MySQL database to another local server that acts as backup and a dev testing db, but I'm not sure which approach to take. I know that there are advantages and disadvantages of running Master-Master and Master-Slave, but I'm not sure of all of the pros and cons.
I was hoping that someone could enumerate these as well as to actually offer an example of setting up the recommended scenario appropriately in terms of config files and the what ports need to communicate (I'm guessing 3306 will have to be forwarded), etc.
So as noted below, since an actual Amazon RDS to remote replication isn't an option, what about SymmetricDS? I've heard some wonderful things about this and perhaps this is the right solution in this scenario.
Still looking for some input in this scenario. In particular, I think this can be done with SymetricDS, but could use some additional example input in this scenario.
Amazon RDS cannot currently be replicated off-RDS, as Amazon does not give you access to the binary logs.
I use doctrine 2 PDO with mysql.
When stress testing the server, mysql reports a lot of aborted connections (up-to 20%).
I am trying to locate the issue.
Mysql manual suggests to ensure that connections to the database are closed properly.
http://dev.mysql.com/doc/refman/5.0/en/communication-errors.html
I can't find any information if doctrine actually closes connections or not, or uses persistent connections.
Also, is there anything else that can account for aborted connections? I am at loss here.
PS. Server is ubuntu 10.04, nginx 1.x, php 5.3.5 (fpm) and mysql 5.1.41
From what I've observed, Doctrine uses persistent connections.
We've stumbled upon a problem, launching unit tests in symfony2, where the database was spammed with connections in "Sleep" status. The solution that worked for us:
$entityManager->getConnection()->close();
I have the same problem and
$entityManager->getConnection()->close();
seems to work, but works 'better' in some php versions if you add
gc_collect_cycles()
after closing connections.
I'm still having that kind of issues in older php version, may be something related with the garbage collector I guess.
Will keep you updated if I find a final solution for all php versions
I have found this tweak:
https://sroze.io/phpunit-mysql-too-many-connections-error-ab52cd5798c5
Setting processIsolation="true" option in PhpUnit XML options file seems to do the trick.