D
D
Dilik Pulatov2018-04-23 09:20:06
MySQL
Dilik Pulatov, 2018-04-23 09:20:06

How to connect to a database that is located on another server?

Hello!
There is such a task .... there is a working project that works with clients and with android applications
recently bought their VDS and we want to move the project to it ... the problem is that when changing DNS addresses, it takes at least 24 hours, maybe less, but still the project should work stably
. So I came up with this: I
will create a database on a new server and connect the project to it (I don’t know how to do it yet, but they said that this is possible)
and set up a new server so that when the DNS address of our site changes, it works automatically....
so it turns out when the DNS addresses were changed, the project will work stably,
did I come up with the right one? If something is wrong, please advise how to solve this problem?
(sorry if I wrote it wrong)

Answer the question

In order to leave comments, you need to log in

4 answer(s)
F
forspamonly2, 2018-04-23
@forspamonly2

raskochegarit everything on the new server, set up a reverse proxy on the old one so that it transfers requests to the new one (by IP address), then switch dns to the new server and turn off the old server in three days.

S
Sergey Savostin, 2018-04-23
@savostin

I did this:
1. Created a database on the new server.
2. Opened an ssh gateway from the old one to the new one (let's say on port 3307).
3. Copied php scripts to the new server.
4. Stopped the service (unfortunately, in this case, there is no way to stop, but there are options, for example, with a slave).
5. Transferred data to a new server (mysqldump)
6. On the old one in php scripts, fixed the port connection from 3306 to 3307. Started the service.
7. Changed DNS. Now, to whom the records reached, they worked completely on the new server, to whom they did not reach - on the old one, but in the new database.
But that's all if your project does not write anything other than the base. So you still have to synchronize the files, and this task is not trivial and highly dependent on the project.

A
Arman, 2018-04-23
@Arik

to connect scripts to a DB not on the domain, and on IP? if local database then unix socket or localhost. For users, look at what they are connecting to, if to a web server, say nginx, then we simply proxy the request to a new server, when all DNS are updated, then turn off the old web server

O
OnYourLips, 2018-04-23
@OnYourLips

the problem is that when changing DNS addresses, it takes at least 24 hours
A minute is enough. Set the normal TTL for the desired zones. Therefore, your crutches are not needed.
https://habrahabr.ru/company/varonis/blog/324024/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question