Re: Replication pointers
Posted by:
Theo Viset
Date: August 30, 2005 05:32AM
Hiall,
maybe I represented my replication incorrectly. I have an A and a B database. When I change data in A it occurs also in B, and vice versa. In operational status, updates will only be done at 1 database, preferrably A which updates B accoringly. In any way, when A dies, B takes over and when A comes back on, B should update A.
However, this discussion did not answer my initial question :-)
Can I setup a replicating database by executing only a script, without the need to execute the "SHOW MASTER STATUS" and "CHANGE MASTER TO MASTER_HOST='hostb', MASTER_USER='repl', MASTER_PASSWORD='someword', MASTER_LOG_FILE='ffidsb-bin.000002', MASTER_LOG_POS=2575;" statements?
These are the my.cnf settings
(Master host)
[mysqld]
log-bin
log-slave-updates
server-id=1
master-host=hostb
master-port=3306
master-user=repl
master-password=someword
(Slave host)
[mysqld]
log-bin
log-slave-updates
server-id=2
master-host=hosta
master-port=3306
master-user=repl
master-password=someword
These are the statements I have in mind to create the db:
FLUSH PRIVILEGES;
CREATE USER MyUSER IDENTIFIED BY 'someword';
CREATE USER repl IDENTIFIED BY 'someword';
CREATE DATABASE MyDB;
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%' IDENTIFIED BY 'someword';
GRANT SUPER, RELOAD, SELECT ON *.* TO 'repl'@'%' IDENTIFIED BY 'someword';
GRANT ALL ON *.* TO 'root'@'%' IDENTIFIED BY 'someword';
GRANT ALL ON MyDB.* TO 'MyUSER'@'%' IDENTIFIED BY 'someword';
GRANT ALL ON *.* TO 'repl'@'%' IDENTIFIED BY 'someword';
USE FFIDS;
SOURCE SETUP_MyDB.SQL; //Create MyDB structure and tables
SOURCE FIXEDFILES.SQL; // Load initial data
USE MYSQL;
SELECT HOST, USER FROM USER;
UPDATE USER SET HOST = '%' WHERE HOST = 'hosta';
// Setup done
Now, when I do this in both my databases (with crosslinked hostnames of course), do I have to set the pointers correctly, or will the db be replicated correc tly by default?
Greetz, T