<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://wiki.parspooyesh.com/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fa">
		<id>http://wiki.parspooyesh.com/index.php?action=history&amp;feed=atom&amp;title=DMYSQL_Replication</id>
		<title>DMYSQL Replication - تاریخچهٔ ویرایش‌ها</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.parspooyesh.com/index.php?action=history&amp;feed=atom&amp;title=DMYSQL_Replication"/>
		<link rel="alternate" type="text/html" href="http://wiki.parspooyesh.com/index.php?title=DMYSQL_Replication&amp;action=history"/>
		<updated>2026-06-24T10:45:45Z</updated>
		<subtitle>تاریخچهٔ ویرایشهای صفحه در ویکی</subtitle>
		<generator>MediaWiki 1.19.0</generator>

	<entry>
		<id>http://wiki.parspooyesh.com/index.php?title=DMYSQL_Replication&amp;diff=1068&amp;oldid=prev</id>
		<title>Behnaz: صفحه‌ای جدید حاوی '&lt;div dir=ltr lang=en&gt; Database Replication  To manage Database on both server should setup Replication. Debian  * '''On Master Server:'''   '...' ایجاد کرد</title>
		<link rel="alternate" type="text/html" href="http://wiki.parspooyesh.com/index.php?title=DMYSQL_Replication&amp;diff=1068&amp;oldid=prev"/>
				<updated>2012-11-27T13:31:00Z</updated>
		
		<summary type="html">&lt;p&gt;صفحه‌ای جدید حاوی &amp;#039;&amp;lt;div dir=ltr lang=en&amp;gt; Database Replication  To manage Database on both server should setup Replication. Debian  * &amp;#039;&amp;#039;&amp;#039;On Master Server:&amp;#039;&amp;#039;&amp;#039;   &amp;#039;...&amp;#039; ایجاد کرد&lt;/p&gt;
&lt;p&gt;&lt;b&gt;صفحهٔ جدید&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div dir=ltr lang=en&amp;gt;&lt;br /&gt;
Database Replication&lt;br /&gt;
&lt;br /&gt;
To manage Database on both server should setup Replication.&lt;br /&gt;
Debian&lt;br /&gt;
&lt;br /&gt;
* '''On Master Server:'''&lt;br /&gt;
&lt;br /&gt;
 '''Edit the conf file /etc/mysql/my.cnf'''&lt;br /&gt;
Comment bind-address line:&lt;br /&gt;
        # bind-address          = 127.0.0.1&lt;br /&gt;
&lt;br /&gt;
Uncomment the following and change the server-id if required:&lt;br /&gt;
&lt;br /&gt;
        server-id = 1&lt;br /&gt;
        log_bin                 = /var/log/mysql/mysql-bin.log&lt;br /&gt;
&lt;br /&gt;
'''Restart MySQL'''&lt;br /&gt;
&lt;br /&gt;
    /etc/init.d/mysql restart&lt;br /&gt;
    Stopping MySQL database server: mysqld.&lt;br /&gt;
    Starting MySQL database server: mysqld.&lt;br /&gt;
    Checking for corrupt, not cleanly closed and upgrade needing tables..&lt;br /&gt;
&lt;br /&gt;
'''Enter MySQL shell to create a save user account and password.'''&lt;br /&gt;
&lt;br /&gt;
    mysql -u root -ppassw0rd&lt;br /&gt;
&lt;br /&gt;
'''Create a slave user account in MySQL Shell'''&lt;br /&gt;
&lt;br /&gt;
    CREATE USER 'rep1'@'%' IDENTIFIED BY 'slavepassword';&lt;br /&gt;
    GRANT REPLICATION SLAVE ON *.* TO 'rep1'@'%' IDENTIFIED BY 'slavepassword';&lt;br /&gt;
    FLUSH PRIVILEGES;&lt;br /&gt;
&lt;br /&gt;
'''Check the master status in MySQL shell'''&lt;br /&gt;
&lt;br /&gt;
    SHOW MASTER STATUS;&lt;br /&gt;
&lt;br /&gt;
You should then be presented with something similar to this:&lt;br /&gt;
&lt;br /&gt;
+------------------+----------+--------------+------------------+&lt;br /&gt;
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |&lt;br /&gt;
+------------------+----------+--------------+------------------+&lt;br /&gt;
| mysql-bin.000001 |      106 |              |                  |&lt;br /&gt;
+------------------+----------+--------------+------------------+&lt;br /&gt;
&lt;br /&gt;
'''On Slave Server'''&lt;br /&gt;
&lt;br /&gt;
'''Edit the file /etc/mysql/my.cnf and uncomment and modify the following to suite:'''&lt;br /&gt;
&lt;br /&gt;
    server-id = 2&lt;br /&gt;
&lt;br /&gt;
'''Restart MySQL'''&lt;br /&gt;
&lt;br /&gt;
    /etc/init.d/mysql restart&lt;br /&gt;
&lt;br /&gt;
'''Enter MYSQL shell to create a connection to the master:'''&lt;br /&gt;
&lt;br /&gt;
    mysql -u root -ppassw0rd&lt;br /&gt;
&lt;br /&gt;
'''Create a connection with the master database in MySQL Shell.'''&lt;br /&gt;
&lt;br /&gt;
    CHANGE MASTER TO MASTER_HOST='X.X.X.X',&lt;br /&gt;
    MASTER_USER='rep1',&lt;br /&gt;
    MASTER_PASSWORD='slavepassword',&lt;br /&gt;
    MASTER_LOG_FILE='mysql-bin.000001',&lt;br /&gt;
    MASTER_LOG_POS=106;&lt;br /&gt;
&lt;br /&gt;
Note: Replace X.X.X.X with Master's IP address, mysql-bin.000001 with Master's log file name and 106 with Master's log file position.&lt;br /&gt;
&lt;br /&gt;
“Query OK, 0 rows affected” should be displayed at the end of the command.&lt;br /&gt;
&lt;br /&gt;
* Issue further commands in MySQL shell to start the slave.&lt;br /&gt;
&lt;br /&gt;
    SLAVE START;&lt;br /&gt;
    SHOW SLAVE STATUS \G&lt;br /&gt;
&lt;br /&gt;
The status should then be displayed and if all went well we should have the following contained within that output.&lt;br /&gt;
&lt;br /&gt;
  Slave_IO_Running: Yes &lt;br /&gt;
  Slave_SQL_Running: Yes&lt;br /&gt;
&lt;br /&gt;
The last thing you should do is to dump main database, and import it into backup database.&lt;br /&gt;
&lt;br /&gt;
Source:  http://home.exetel.com.au/widget/blog/tag/debian-mysql-database-replication/&lt;br /&gt;
&lt;br /&gt;
Note: Slave_SQL_Running will show No if any (I think) error occurs in Master. This document may help you:&lt;br /&gt;
 http://www.ducea.com/2008/02/13/mysql-skip-duplicate-replication-errors/&lt;br /&gt;
'''CentOS'''&lt;br /&gt;
&lt;br /&gt;
To enable Replication :&lt;br /&gt;
&lt;br /&gt;
* '''On Master Server'''&lt;br /&gt;
'''Edit /etc/my.cnf and change these lines :'''&lt;br /&gt;
&lt;br /&gt;
        [mysqld]&lt;br /&gt;
        bind-address = 0.0.0.0&lt;br /&gt;
        server-id=1&lt;br /&gt;
        log-bin=/var/run/mysqld/mysqld-bin&lt;br /&gt;
&lt;br /&gt;
 '''Restart mysql server'''&lt;br /&gt;
&lt;br /&gt;
  /etc/init.d/mysqld restart&lt;br /&gt;
&lt;br /&gt;
 '''open mysql console and run commands'''&lt;br /&gt;
&lt;br /&gt;
        mysql-&amp;gt;CREATE USER 'slave_user' IDENTIFIED BY 'Hdfk@2@2js@h';&amp;quot; &lt;br /&gt;
        mysql-&amp;gt;GRANT REPLICATION SLAVE ON *.* TO slave_user IDENTIFIED BY 'Hdfk@2@2js@h' ;&lt;br /&gt;
        mysql&amp;gt; use asterisk ;&lt;br /&gt;
        Database changed&lt;br /&gt;
        mysql&amp;gt; SHOW MASTER STATUS ;&lt;br /&gt;
        +-------------------+----------+--------------+------------------+&lt;br /&gt;
        | File              | Position | Binlog_Do_DB | Binlog_Ignore_DB |&lt;br /&gt;
        +-------------------+----------+--------------+------------------+&lt;br /&gt;
        | mysqld-bin.000001 |     2335 |              |                  | &lt;br /&gt;
        +-------------------+----------+--------------+------------------+&lt;br /&gt;
        1 row in set (0.00 sec)&lt;br /&gt;
&lt;br /&gt;
* '''On Slave Server'''&lt;br /&gt;
'''Edit /etc/my.cnf and change this lines'''&lt;br /&gt;
&lt;br /&gt;
        [mysqld]&lt;br /&gt;
        master-host=192.168.1.17&lt;br /&gt;
        master-user=slave_user&lt;br /&gt;
        master-password=Hdfk@2@2js@h&lt;br /&gt;
        relay-log=/var/run/mysqld/mysqld-relay-bin&lt;br /&gt;
        server-id=2&lt;br /&gt;
&lt;br /&gt;
'''Restart mysql server'''&lt;br /&gt;
&lt;br /&gt;
        /etc/init.d/mysqld restart&lt;br /&gt;
&lt;br /&gt;
'''Restore database which you want to Replication'''&lt;br /&gt;
'''Open mysql console and run these commands :'''&lt;br /&gt;
&lt;br /&gt;
        mysql&amp;gt; use asterisk ;&lt;br /&gt;
        Database changed&lt;br /&gt;
        mysql&amp;gt; SHOW SLAVE STATUS\G&lt;br /&gt;
        mysql&amp;gt; CHANGE MASTER TO MASTER_LOG_FILE='mysqld-bin.000001' , MASTER_LOG_POS=2335 ;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Behnaz</name></author>	</entry>

	</feed>