Database high availability configuration

Hi all,

I would like to configure high availability both for MongoDB and for MySQL. I mean, to declare both the primary and the replica servers in the configuration so that when the primary fails, it tries to connect to the other.
Does anybody know how to do this?