日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

mysql-5.5.31主从复制

發布時間:2023/12/9 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql-5.5.31主从复制 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
給數據庫用戶配置groupadd mysqluseradd -g mysql mysql -s /sbin/nologinrm -rf /home/mysqlmkdir -p /opt/mysqlchmod -R 755 /opt/mysql

chown -R mysql:mysql /opt/mysql

準備工作:安裝基本依賴包,先用yum安裝cmake、automake 、autoconf ,另MySQL 5.5.x需要最少安裝的包有:bison,gcc、gcc-c++、ncurses-devel

yum -y install gcc gcc-c++ autoconf bison automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel*

安裝cmake(mysql5.5以后是通過cmake來編譯的)

axel -n ?10 http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gztar zxvf cmake-2.8.4.tar.gz./bootstrapgmake install下載解壓mysql 5.5.11axel ?-n 10 http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.30.tar.gztar zxfv ?mysql-5.5.30.tar.gz

cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/opt/mysql \

-DSYSCONFDIR=/etc \

-DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \

-DMYSQL_USER=mysql \

-DMYSQL_TCP_PORT=3306 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_ARCHIVE_STORAGE_ENGINE=1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \

-DWITH_FEDERATED_STORAGE_ENGINE=0 \

-DWITH_PARTITION_STORAGE_ENGINE=1 \

-DENABLED_LOCAL_INFILE=1 \

-DWITH_SSL=no \

-DEXTRA_CHARSETS=all \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_READLINE=1 \

-DWITH_ZLIB=system \

-DINSTALL_PLUGINDIR=lib64/mysql/plugin \

-DINSTALL_LIBDIR=lib64/mysql \

-DINSTALL_INCLUDEDIR=include/mysql \

-DWITH_DEBUG=0

碰到了錯誤:-- Could NOT find Curses (missing: ?CURSES_LIBRARY CURSES_INCLUDE_PATH) CMake Error at cmake/readline.cmake:83 (MESSAGE): ?Curses library not found. ?Please install appropriate package, ? ? ?remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.Call Stack (most recent call first): ?cmake/readline.cmake:127 (FIND_CURSES) ?cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT) ?CMakeLists.txt:269 (MYSQL_CHECK_READLINE)-- Configuring incomplete, errors occurred!是因為少了ncurses-devel這個包。用yum安裝后,然后把目錄下的CMakeCache.txt 刪除,否則還是報之前的錯誤然后就是make ?&& make ?install cp support-files/my-medium.cnf /etc/my.cnf chown -R mysql:mysql mysql/opt]# /opt/mysql/scripts/mysql_install_db --user=mysql ?--defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/opt/data/usr/local/mysql/bin/mysqld_safe --user=mysql & ?啟動mysqlcp ?mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqldchmod +x ?/etc/init.d/mysqldchown .mysql ?/etc/init.d/mysqld

chkconfig --add ?mysqld

chkconfig mysqld ?on


接下來開始部署主從環境


在主服務器上配置mysql的配置文件

確保/etc/my.cnf中有如下參數,沒有的話需手工添加,并重啟mysql服務。[mysqld]log-bin=mysql-bin 啟動二進制文件server-id=1 服務器ID


然后進入到mysql數據庫里進行授權

grant replication slave on *.* to 'backup'@'x.x.x.x' identified by 'backup';


查詢主數據庫狀態,并記下FILE及Position的值,這個在后面配置從服務器的時候要用到

show master status;

+------------------+----------+--------------+------------------+

| File ? ? ? ? ? ? | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000010 | ? ? ?264 | ? ? ? ? ? ? ?| ? ? ? ? ? ? ? ? ?|

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)


主數據庫的操作就到這里,下面的操作在從服務器上操作

確保/etc/my.cnf中有log-bin=mysql-bin和server-id=1參數,并把server-id=1修改為server-id=10。修改之后如下所示:[mysqld]log-bin=mysql-bin 啟動二進制文件server-id=10 服務器ID

重啟mysql服務。登錄mysql,執行如下語句change master to master_host='o.o.o.o',master_user='backup',master_password='backup',master_log_file='mysql-bin.000010',master_log_pos=264;


啟動slave同步。start slave;檢查主從同步,如果您看到Slave_IO_Running和Slave_SQL_Running均為Yes,則主從復制連接正常。show slave status\G


注: 刪除mysql日志文件后報I/O error reading the header from the binary log, errno=175, io cache

data目錄下日志文件很多,很煩,把mysql-bin.000001~mysql-bin.0000018都刪掉了。結果報以下錯誤:


120914 10:23:31 [ERROR] I/O error reading the header from the binary log, errno=175, io cache code=0

120914 10:23:31 [ERROR] I/O error reading the header from the binary log

120914 10:23:31 [ERROR] Can't init tc log

120914 10:23:31 [ERROR] Aborting


解決辦法:

把剩下的有關日志的文件都刪掉。把ibdata1,ib_logfile0,ib_logfile1,mysql-bin.index,再啟動就可以了


轉載于:https://blog.51cto.com/sunway/1224903

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的mysql-5.5.31主从复制的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。