[root@master linux]# tar fzvx mysql-5.6.16-linux-x86_64.tar.gz -C /usr/local/
[root@master linux]# mv mysql-5.6.16-linux-x86_64 mysql
[root@master local]# cd mysql/
[root@master mysql]# chown -R root:mysql .
[root@master mysql]# chown -R mysql:mysql data/
[root@master mysql]# ./scripts/mysql_install_db --user=mysql \
> --basedir=/usr/local/mysql/ \
> --datadir=/usr/local/mysql/data/
WARNING: The host 'master' could not be looked up with /usr/local/mysql//bin/resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...2014-04-26 19:57:06 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-04-26 19:57:06 1258 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-04-26 19:57:06 1258 [Note] InnoDB: The InnoDB memory heap is disabled
2014-04-26 19:57:06 1258 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-04-26 19:57:06 1258 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-04-26 19:57:06 1258 [Note] InnoDB: Using Linux native AIO
2014-04-26 19:57:06 1258 [Note] InnoDB: Using CPU crc32 instructions
2014-04-26 19:57:06 1258 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-04-26 19:57:07 1258 [Note] InnoDB: Completed initialization of buffer pool
2014-04-26 19:57:07 1258 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2014-04-26 19:57:07 1258 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2014-04-26 19:57:07 1258 [Note] InnoDB: Database physically writes the file full: wait...
2014-04-26 19:57:07 1258 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2014-04-26 19:57:11 1258 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2014-04-26 19:57:15 1258 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2014-04-26 19:57:15 1258 [Warning] InnoDB: New log files created, LSN=45781
2014-04-26 19:57:15 1258 [Note] InnoDB: Doublewrite buffer not found: creating new
2014-04-26 19:57:15 1258 [Note] InnoDB: Doublewrite buffer created
2014-04-26 19:57:15 1258 [Note] InnoDB: 128 rollback segment(s) are active.
2014-04-26 19:57:15 1258 [Warning] InnoDB: Creating foreign key constraint system tables.
2014-04-26 19:57:16 1258 [Note] InnoDB: Foreign key constraint system tables created
2014-04-26 19:57:16 1258 [Note] InnoDB: Creating tablespace and datafile system tables.
2014-04-26 19:57:16 1258 [Note] InnoDB: Tablespace and datafile system tables created.
2014-04-26 19:57:16 1258 [Note] InnoDB: Waiting for purge to start
2014-04-26 19:57:16 1258 [Note] InnoDB: 5.6.16 started; log sequence number 0
2014-04-26 19:57:16 1258 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2014-04-26 19:57:16 1258 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2014-04-26 19:57:17 1258 [Note] Binlog end
2014-04-26 19:57:17 1258 [Note] InnoDB: FTS optimize thread exiting.
2014-04-26 19:57:17 1258 [Note] InnoDB: Starting shutdown...
2014-04-26 19:57:19 1258 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables...2014-04-26 19:57:19 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2014-04-26 19:57:19 1281 [Note] InnoDB: Using atomics to ref count buffer pool pages
2014-04-26 19:57:19 1281 [Note] InnoDB: The InnoDB memory heap is disabled
2014-04-26 19:57:19 1281 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2014-04-26 19:57:19 1281 [Note] InnoDB: Compressed tables use zlib 1.2.3
2014-04-26 19:57:19 1281 [Note] InnoDB: Using Linux native AIO
2014-04-26 19:57:19 1281 [Note] InnoDB: Using CPU crc32 instructions
2014-04-26 19:57:19 1281 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2014-04-26 19:57:19 1281 [Note] InnoDB: Completed initialization of buffer pool
2014-04-26 19:57:19 1281 [Note] InnoDB: Highest supported file format is Barracuda.
2014-04-26 19:57:19 1281 [Note] InnoDB: 128 rollback segment(s) are active.
2014-04-26 19:57:19 1281 [Note] InnoDB: Waiting for purge to start
2014-04-26 19:57:19 1281 [Note] InnoDB: 5.6.16 started; log sequence number 1625977
2014-04-26 19:57:19 1281 [Note] RSA private key file not found: /usr/local/mysql/data//private_key.pem. Some authentication plugins will not work.
2014-04-26 19:57:19 1281 [Note] RSA public key file not found: /usr/local/mysql/data//public_key.pem. Some authentication plugins will not work.
2014-04-26 19:57:19 1281 [Note] Binlog end
2014-04-26 19:57:19 1281 [Note] InnoDB: FTS optimize thread exiting.
2014-04-26 19:57:19 1281 [Note] InnoDB: Starting shutdown...
2014-04-26 19:57:21 1281 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql//bin/mysqladmin -u root password 'new-password'
/usr/local/mysql//bin/mysqladmin -u root -h master password 'new-password'
Alternatively you can run:
/usr/local/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; /usr/local/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/local/mysql//my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server.
[root@node1 mysql]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.16-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant replication slave on *.* to 'repl'@'192.168.1.11' identified by '12345';
Query OK, 0 rows affected (1.49 sec)
2)查询二进制日志
mysql> show master status;
+----------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+----------------+----------+--------------+------------------+-------------------+
| sql-bin.000001 | 120 | | | |
+----------------+----------+--------------+------------------+-------------------+
1 row in set (0.12 sec)
3)配置slave服务器
[root@slave ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> change master to[root@slave1 ~]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> change master to
-> master_host='192.168.1.254',
-> master_user='repl',
-> master_password='12345',
-> master_log_file='sql-bin.000001',
-> master_log_pos=120;
Query OK, 0 rows affected (0.25 sec)
4)启动slave检测是否同步成功
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.1.10
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: sql-bin.000001
Read_Master_Log_Pos: 120
Relay_Log_File: node2-relay-bin.000002
Relay_Log_Pos: 281
Relay_Master_Log_File: sql-bin.000001
Slave_IO_Running: Yes #为Yes说明成功
Slave_SQL_Running: Yes #为Yes说明成功
Replicate_Do_DB:
Replicate_Ignore_DB:
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: 120
Relay_Log_Space: 454
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: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 10
Master_UUID: 8c55a12b-cd22-11e3-bc81-0050563f4084
Master_Info_File: /usr/local/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.05 sec)
ERROR:
No query specified
[root@slave ~]# mysql -uuser -p -h192.168.1.12 --port=4040
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be 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 |
| performance_schema |
| test |
| user |
+--------------------+