设为首页 加入收藏

TOP

通过主从复制机制完成MySQL数据库服务迁移(四)
2015-11-21 01:24:51 来源: 作者: 【 】 浏览:3
Tags:通过 主从 复制 机制 完成 MySQL 数据库 服务 迁移
--------------+------------------+-------------------+1 row in set (0.00 sec)
?3)在新机器(B_IP)上创建主从同步
?
mysql> change master to master_host='A_IP',
? ? ? ? ? ? ? ? master_user='rep',
? ? ? ? ? ? ? ? master_password='heheheh',
? ? ? ? ? ? ? ? master_port=3306,
? ? ? ? ? ? ? ? master_log_file='mysql-bin.000001',
? ? ? ? ? ? ? ? master_log_pos=120,
? ? ? ? ? ? ? ? master_connect_retry=10;
参数详解:
?
master_host:主服务器的IP。
master_user:配置主服务器时建立的用户名
master_password:用户密码
master_port:主服务器mysql端口,如果未曾修改,默认即可。
master_log_file:日志文件名称,填写查看master状态时显示的Filemaster_log_pos:日志位置,填写查看master状态时显示的Positionmaster_connect_retry:重连次数
4)启动进程
?
mysql> start slave;
?
查看主从同步情况:
主要需要关注Slave_IO_Running: YES; Slave_SQL_Running: YES;Seconds_Behind_Master: 0?
mysql> show slave status \G;*************************** 1. row ***************************
Slave_IO_State:?
Master_Host: A_IPMaster_User: rep
Master_Port: 3306Connect_Retry: 60Master_Log_File: Tencent64-bin.000164Read_Master_Log_Pos: 107Relay_Log_File: WEBAPP_B_IP_HOST-relay-bin.000006Relay_Log_Pos: 270Relay_Master_Log_File: Tencent64-bin.000164Slave_IO_Running: YES
Slave_SQL_Running: YES
Replicate_Do_DB:?
Replicate_Ignore_DB:?
Replicate_Do_Table:?
Replicate_Ignore_Table:?
Replicate_Wild_Do_Table:?
Replicate_Wild_Ignore_Table:?
Last_Errno: 0Last_Error:?
Skip_Counter: 0Exec_Master_Log_Pos: 107Relay_Log_Space: 786Until_Condition: None
Until_Log_File:?
Until_Log_Pos: 0Master_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
主从信息查看的命令:
?
show slave hosts \G;主机上查看从机信息
show master status\G;主机上查看状态信息
show slave status \G;从机上查看主从状态信息
0x05 存储过程与权限的导入
?
?
1.存储过程和函数的导出
?
由于存储过程和数据库权限信息存储在mysql库中,通过mysqldump普通参数是不会导出的。
?
导出存储过程: mysqldump 加 -R (或 --routines)参数即可。
?
? -R, --routines ? ? ?Dump stored routines (functions and procedures).
? ? ? ? ? ? ? ? ? ? ? Add 'SET @@GLOBAL.GTID_PURGED' to the output. Possible ? ? ? ? ? ? ? ? ? ? ?@@GLOBAL.GTID_PURGED' is added to the output. If GTIDs
? ? ? ? ? ? ? ? ? ? ? statements: ALTER TABLE, DROP TABLE, RENAME TABLE,
? ? ? ? ? ? ? ? ? ? ? TRUNCATE TABLE, as consistent snapshot is not isolated
单独导出存储过程等内容:
?
mysqldump -uroot ?-n -d -t -R hehehehhe > procedure_name.sql
-- MySQL dump 10.10--
-- Host: localhost ? ?Database: hehehehhe
-- ------------------------------------------------------
-- Server version ? ? ? 5.5.3-m3-log
?
后期也发现,如果在导出时mysqldump指定 --databases 会自动将原DB的创建语句添加进去,但是有的时候我们希望自己指定DB创建语句,比如要指定默认字符集为utf8,而原来的用的是latin1,这个时候我们就不需要加这个参数了。
?
2.数据库权限的导出与导入
?
数据库的权限有针对全局的也有针对特定库和表的权限,无法直接导出再导入。
主要通过查出旧机器授权过的帐号和机器IP,在通过show grants语句来获取相应权限。
?
mysql> ?SELECT CONCAT("show grants for ",user,"@",host,";") from mysql.user;
+----------------------------------------------+
| CONCAT("show grants for ",user,"@",host,";") |
+----------------------------------------------+
| show grants for hehehehhe@10.136.12.216; ? ? ?|| show grants for hehehehhe@10.166.129.173; ? ? || show grants for hehehehhe@10.166.129.174; ? ? || show grants for adbreader@10.166.129.226; ? ?|| show grant
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Oracle 数据库日常巡检 下一篇MYSQL不能从远程连接的解决方法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: