mysqlµÄmaster/slaveÊý¾Ýͬ²½ÅäÖÃ[ת]
ÎҵIJâÊÔ»·¾³.»ù±¾ÉÏÊý¾ÝÊÇ˲¼äͬ²½£¬Ï£Íû¶Ô´ó¼ÒÓаïÖú
redhat 9.0
mysql3.23.57
mysqlÊý¾Ýͬ²½±¸·Ý
A·þÎñÆ÷£º 192.168.1.2 Ö÷·þÎñÆ÷master
B·þÎñÆ÷£º 192.168.1.3 ¸±·þÎñÆ÷slave
A·þÎñÆ÷ÉèÖÃ
#mysql –u root –p
mysql>GRANT FILE ON *.* TO backup@192.168.1.3 IDENTIFIED BY ‘1234’;
mysql>\exit
ÉÏÃæÊÇMaster¿ª·ÅÒ»¸öÕ˺ÅbackupÃÜÂë1234¸øIP:192.168.1.3Óеµ°¸´¦ÀíµÄȨÏÞ
mysqladmin –u root –p shutdown
±¸·ÝMasterËùÓÐÊý¾Ý¿â..ͨ³£¶¼ÓÃtarÖ¸Áî.
#tar –cvf /tmp/mysql.tar /var/lib/mysql
×¢Òâ:tarµÄʱºò,MySQLÊÇÒªÔÚstopÇé¿öÏÂ
ÔÚA»úÆ÷ÉÏÐÞ¸Ä/etc/my.cnf
ÔÚ[mysqld]Çø¶ÎÄÚ¼ÓÈë²ÎÊý
log-bin
server-id=1
sql-bin-update-same
binlog-do-db=vbb
ÖØÆôA·þÎñÆ÷mysql
´ËʱÒòΪÓмÓÈëlog-bin²ÎÊý,Òò´Ë¿ªÊ¼ÓÐindex²úÉúÁË,ÔÚ/var/lib/mysqlĿ¼ÏÂÓÐ.indexµµ°¸¼Í¼Êý¾Ý¿âµÄÒ춯log.
B·þÎñÆ÷ÉèÖÃ
É趨/etc/my.cnf
ÔÚ[mysqld]Çø¶Î¼ÓÈë
master-host=192.168.1.2
master-user=backup
master-password=1234
master-port=3306
server-id=2
master-connect-retry=60 Ô¤ÉèÖØÊÔ¼ä¸ô60Ãë
replicate-do-db=vbb ¸æËßslaveÖ»×övbbÊý¾Ý¿âµÄ¸üÐÂ
log-slave-updates
½«AÉϵÄmysql.tar copyµ½BÉÏ
ÓÃftp´«BµÄ/tmp
9.½âѹËõ
#cd /var/lib/
×´¿ö²âÊÔ
1.A¸úBÍøÂç¼°·þÎñ¶¼Õý³£Çé¿öÏÂ,ÓÉA¶Ë±ä»¯Êý¾Ýºó,µ½B¶Ëä¯ÀÀÊý¾Ý,¼ìÊÓÊÇ·ñÓнøÐÐreplication?!
2.Ä£ÄâBµ±»ú,»òÊÇB²»Ò»¶¨ÐèÒªÒ»Ö±¸úAÓÐÁ¬½Ó.
½«ÓÉA¶Ë±ä»¯Êý¾Ýºó,µ½B¶Ëä¯ÀÀÊý¾Ý£¬BµãÓ¦¸ÃÊÇûÓÐÊý¾Ý±ä»¯µÄ
#tar xvf /tmp/mysql-snapshot.tar
#chown –R mysql:mysql mysql
1ÖØÆôB·þÎñÆ÷µÄmysql
ÕâʱÔÚ/var/lib/mysqlĿ¼»á³öÏÖmaster.info,´Ëµµ°¸¼Í¼ÁËMaster MySQL serverµÄÐÅÏ¢.
×´¿ö²âÊÔ
1.A¸úBÍøÂç¼°·þÎñ¶¼Õý³£Çé¿öÏÂ,ÓÉA¶Ë±ä»¯Êý¾Ýºó,µ½B¶Ëä¯ÀÀÊý¾Ý,¼ìÊÓÊÇ·ñÓнøÐÐreplication?!
2.Ä£ÄâBµ±»ú,»òÊÇB²»Ò»¶¨ÐèÒªÒ»Ö±¸úAÓÐÁ¬½Ó.
½«ÓÉA¶Ë±ä»¯Êý¾Ýºó,µ½B¶Ëä¯ÀÀÊý¾Ý£¬BµãÓ¦¸ÃÊÇûÓÐÊý¾Ý±ä»¯µÄ
Ïà¹ØÎĵµ£º
/***************************by
garcon1986********************************/
1.´´½¨±í¸ñʱ´íÎó£º ERROR 1005: Can't
create table (errno: 150)
Õâ¸ö´íÎóÊÇÓÐÓÉÓÚÖ÷±íºÍÒýÓñíµÄÍâ¼ü¹ØÁª×ֶζ¨Òå²»Ò»ÖÂÒý·¢µÄ¡£
¼ì²éÁ½¸ö±íµÄ¹ØÁª×Ö¶ÎÊÇ·ñÀàÐͱàÂëÍêÈ«Ò»Ö¡£
ÁíÍ⻹ÓÐÒ»ÖÖ¿ÉÄܾÍÊǹØÁª×Ö¶ÎÔÚÒýÓñíÖÐ ......
Ò»¡¢Á¬½ÓMYSQL¡£
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £pÓû§ÃÜÂë
1¡¢Á¬½Óµ½±¾»úÉϵÄMYSQL¡£Ê×ÏÈ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼mysql\bin£¬ÔÙ¼üÈëÃüÁîmysql -u root -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂë.×¢ÒâÓû§ÃûÇ°¿ÉÒÔÓпոñÒ²¿ÉÒÔûÓпոñ£¬µ«ÊÇÃÜÂëÇ°±ØÐëûÓпոñ£¬·ñÔòÈÃÄãÖØÐÂÊäÈëÃÜÂë. Èç¹û¸Õ°²×°ºÃMYSQL£¬³¬¼¶Óû§rootÊÇûÓÐÃÜÂëµ ......
linuxÏ mysql µÄжÔغͰ²×°
¹Ø¼ü×Ö: linuxÏ mysql µÄжÔغͰ²×°
Ò»¡¢Ç°ÆÚ×¼±¸£º
1
.ÓÉÓÚredhat Enterprise 5 ÖÐ×Ô´øÒ»¸ömysqlµÄ°æ±¾£¬Èç¹ûÔÚ°²×°linuxǰδѡÔñmysqlµÄ°²×°´Ë²½¾Í¿ÉÌø¹ý£¬ÒòΪÎÒµ±Ê±°²×°ÁËÏÖÔÚ½«ÆäжÔØ
£¬²½ÖèÈçÏ£º
&nb ......
×î½üÔÚMySQLÉÏ×öÁ˵㹤×÷£¬·¢ÏֺܶàÈ˶¼ÔÚѯÎÊMySQLǶÌײéѯµÄÎÊÌ⣬Ðí¶àÈ˶¼¾õµÃMySQL²»Ö§³ÖǶÌײéѯ£¬ÆäʵMySQl´Ó4.11°æºóÒѾÍêÈ«Ö§³ÖǶÌײéѯÁË£¬ÄÇôÏÂÃæÎÒ¾ÙЩ¼òµ¥µÄǶÌײéѯµÄÀý×Ó°É£¨Ô´³ÌÐòÀ´×ÔMySQL User Manual£©£º
1. SELECTÓï¾äµÄ×Ó²éѯ:
Óï·¨: SELECT ... from (subquery) AS name ...
ÏÈ´´½¨Ò»¸ö±í:
......