I have installed and configured MySQL(ndbcluster engine) in two machines. Such as ip of those machines are xxx.xxx.xxx.1 and xxx.xxx.xxx.2.
I have created a db and some tables. I have created the tables only in one machine(xxx.xxx.xxx.1) with mentioning engine as ndbcluster. So I can see the tables in both machine(also in xxx.xxx.xxx.2).
But while I create a view in one machine. It doesn't show in the other machine!
What should I do to see the view in both machine by creating once in one machine.
Isn't it possible?
Or, do I need to create the view in both machine?
Another question: Can I create a view in mysql specifying the db engine(i.e: innodb, ndbcluster)?
N.B: My MySQL is server is configured as ndbcluster.
Related
I was doing this process in a same server but different databases.
Insert data into a table in dev database
Check the data
If the data is fine, insert into a same table in prd database
but now I separated those databases into different servers. development server, production server.
I didn't want to edit so many existing queries, so I created federated tables that connected to the production server. but every time when I alter production tables.. I had to recreate federated tables again.
Is there a way to not recreate federated tables every time when I alter the original table?
Can I make a linked database?
This answer is assuming you have federatedX plugin available instead or in addition to federated.
You should try the following :
uninstall soname 'ha_federated.so' ;
install soname 'ha_federatedx.so' ;
If this is the case, the engine federatedx (used only for the plugin name, the engine name in DDL statements is still federated) you can use the following statements :
You create a server, as follow :
create server 'server_one' foreign data wrapper 'mysql' options
(HOST '192.168.1.123',
DATABASE 'first_db',
USER 'patg',
PASSWORD '',
PORT 3306,
SOCKET '',
OWNER 'root');
of course, you have to replace the values using your remote server ip, user, password, database, etc.
Later on, if anything change in your remote server properties, you just have to alter the server (no alter table are required anymore).
Then you create your local table using federated engine and the server you've created, as follow :
create table test_fed engine = federated connection = 'server_one' ;
Creating your local table like this will activate federatedx discovery mode, making your local table structure as the exact copy of the remote one.
What if your remote table structure change : unfortunately it's not automatic (the federatedx discovery mode is activated one time when the local table is created and it's not kept up to date), however, it's quiet easy as you just have to re-create your local table the same way
create or replace table test_fed engine = federated connection = 'server_one' ;
And you're done !
The drawback of this local tables declaration method, is to require your local tables' names to be exactly the same as remote ones
If you absolutely need different names for your local and remote tables, you can use the "old" connection syntax used in the create table (finishing with <remote_db_name>/<remote_table_name>)
I'm moving from MySql to MariaDB and I have several databases using federated tables. Everything works fine in the MariaDB but when the server restarts, all federated tables stop working as if the remote server's entry doesn't exists on the local MariaDB server.
After every restart the servers' entries remain in the servers table in the mysql db. If I try to add them again with the CREATE SERVER command, I get an error as if they exist. If I try to drop them with DROP SERVER, I get an error as if they don't exist.
The only way to make it work again is to manually remove the entries from the server table with DELETE FROM servers and create them again with the command CREATE SERVER. How can I make those configurations persistent?
I've searched extensible and couldn't find any solution or mention about this issue. The tables work fine in MySql. The logs doesn't mention anything related to the FederatedX engine between restarts. I'm using MariaDB 10.3.18 on CentOS 7.
I just found that this issue only occurs if the servers table is using the InnoDB engine. Changing it to MyISAM or Aria solves the problem.
For some reason my server was installed with the wrong engine for this table.
Edit: bug report here.
I am attempting to run a single MySQL query, joining two databases on two servers.
I am aware of the potential poor performance, but would like to test regardless.
The purpose of this test, I am working on a Windows domain, with a development (local) server and a live (remote) server.
The local server has FEDERATED engine enabled and the remote server, which stores the actual data but FEDERATED engine is disabled.
Both tables (live and federated) have the same definition/schema, and the federated table on the local server has been defined:
ENGINE=FEDERATED
DEFAULT CHARSET=utf8
CONNECTION='mysql://remote_user#remote_server/remote_database/remote_table';
The local server table creates fine, and although the remote_user and remote_user#'MY-PC-NAME' has the correct GRANTS, I am getting an error:
ERROR 1429 (HY000): Unable to connect to foreign data source: Access denied for user 'remote_user'#'MY-PC-NAME' (using password
My question is do both the local and remote servers require the FEDERATED engine to be enabled?
If not, is there anything else I need to do to get the federated table
to work?
FEDERATED engine option is not required to be enabled on both servers, in this case, only the local server where the federated table is stored, requires to be enabled.
It turns out that the remote_user user requires the PASSWORD option.
I used this to get the connection to work:
CONNECTION='mysql://remote_user:password#remote_server/remote_database/remote_table';
I am using Mysql, I have two DB in two different system. I want my local DB to be synced with remote DB. both the Schema will be having same table and column.
whenever a change occurs in remote DB that change / Update should happen in my Local DB.
How to do it???
Thanks in Advance.
What you'd need is a replication setup using a multi-source setup as described in the MySQL Documentation.
I confused by posts ,
that Federated engine copies a table from Remote database to local
database
(or)
Federated engine creates virtual table in local database from remote
database
.
can some one support what it actually does.?
Federated engine creates virtual table in local database from remote database ,
To copy entire table from remote database use replication , follow http://dev.mysql.com/doc/refman/5.1/en/replication-howto.html