"Reprint" MySQL Replication environment Installation and configuration

Source: Internet
Author: User
Tags iptables

Installation
[email protected] ~]# Yum install Mysql-server
Installed:
Mysql-server.x86_64 0:5.1.73-3.el6_5

Dependency installed:
Mysql.x86_64 0:5.1.73-3.el6_5
Perl-dbd-mysql.x86_64 0:4.013-3.el6
Perl-dbi.x86_64 0:1.609-4.el6

Start and change your password
[[Email protected] ~]# service mysqld start

Problems with The/usr/bin/mysqlbug script!

[OK]
Starting mysqld: [OK]
[Email protected] ~]#/usr/bin/mysqladmin-u root password ' mysqlpass '
[Email protected] ~]#
View the default MY.CNF configuration
[Email protected] ~]# CAT/ETC/MY.CNF
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
[Email protected] ~]#

Modifying the primary server MY.CNF configuration
[Email protected] ~]# VI/ETC/MY.CNF
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0

Server-id=1
Log-bin=mysql-bin
Binlog-ignore-db=mysql

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Increase replication users in the primary database and authorize
mysql> grant replication Slave on * * to ' msrslave ' @ ' 192.168.197.86 ' identified by ' slavepasswd ';
Query OK, 0 rows Affected (0.00 sec)

Mysql>
Mysql> Show master status;
+ —————— + ———-+ ———— –+ —————— +
| File | Position | binlog_do_db | binlog_ignore_db |
+ —————— + ———-+ ———— –+ —————— +
| mysql-bin.000001 | 106 | | MySQL |
+ —————— + ———-+ ———— –+ —————— +
1 row in Set (0.00 sec)

Mysql> exit

Modify the MY.CNF configuration file from the server
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
User=mysql
# Disabling Symbolic-links is recommended to prevent assorted security risks
Symbolic-links=0

server-id=2
Log-bin=mysql-bin
Replicate-ignore-db=mysql

[Mysqld_safe]
Log-error=/var/log/mysqld.log
Pid-file=/var/run/mysqld/mysqld.pid
Stop slave threads and configure connection Master
mysql> stop Slave;
Query OK, 0 rows affected, 1 Warning (0.00 sec)

mysql> Change Master to master_host= ' 192.168.197.85′,master_user= ' msrslave ', master_password= ' slavepasswd ';
Query OK, 0 rows affected (0.16 sec)

Mysql>

Turn on port 3306 on the primary server
[Email protected] ~]# iptables-i input-p tcp–dport 3306-j ACCEPT
[[Email protected] ~]# service Iptables Save
iptables:saving firewall rules to/etc/sysconfig/iptables:[OK]
[Email protected] ~]#

Restarting the slave server
mysql> start slave;
Query OK, 0 rows Affected (0.00 sec)

View slave Run status
Mysql> show Slave status\g;
1. Row ***************************
Slave_io_state:connecting to Master
master_host:192.168.197.85
Master_user:msrslave
master_port:3306
Connect_retry:60
Master_log_file:
Read_master_log_pos:4
relay_log_file:mysqld-relay-bin.000001
Relay_log_pos:4
Relay_master_log_file:
Slave_io_running:no
Slave_sql_running:yes
replicate_do_db:
Replicate_ignore_db:mysql
Replicate_do_table:
Replicate_ignore_table:
Replicate_wild_do_table:
Replicate_wild_ignore_table:
last_errno:0
Last_error:
skip_counter:0
exec_master_log_pos:0
relay_log_space:106
Until_condition:none
Until_log_file:
until_log_pos:0
Master_ssl_allowed:no
Master_ssl_ca_file:
Master_ssl_ca_path:
Master_ssl_cert:
Master_ssl_cipher:
Master_ssl_key:
Seconds_behind_master:null
Master_ssl_verify_server_cert:no
last_io_errno:2013
Last_io_error:error connecting to master ' [email protected]:3306′–retry-time:60 retries:86400
last_sql_errno:0
Last_sql_error:
1 row in Set (0.00 sec)

ERROR:
No query specified

Mysql>
Create a new database and import data on the primary server
mysql> CREATE DATABASE Linuxcache;
Query OK, 1 row Affected (0.00 sec)

Mysql> Grant all on linuxcache.* to Linuxcache;
Query OK, 0 rows affected (0.02 sec)

Mysql> Grant all on linuxcache.* to [email protected] '% ';
Query OK, 0 rows affected (0.01 sec)

mysql> Set password for [email protected] '% ' =password (' lcpasswd ');
Query OK, 0 rows Affected (0.00 sec)

mysql> flush Privileges;
Query OK, 0 rows affected (0.01 sec)
[Email protected] ~]# mysql-u Root-pmysqlpass Linuxcache < Linuxcache.05_06_14.sql

To view replication-generated databases from the server
[Email protected] ~]# mysql-u root-p
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 13
Server Version:5.1.73-log Source Distribution

Copyright (c) and/or, Oracle, its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> show databases;
+ —————— –+
| Database |
+ —————— –+
| Information_schema |
| MySQL |
| Linucache |
| Test |
+ —————— –+
4 rows in Set (0.00 sec)

Mysql>

Original address: http://www.linuxcache.com/archives/2663

Reprint please specify the original address

"Reprint" MySQL Replication environment Installation and configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.