標籤:版本升級 主機 local
主從架構[一主多從]升級步驟
1. 首先安裝最新版本的MySQL mysql-5.6.26.tar.gz
:每台主機分別安裝目錄:/usr/local/mysql-5.6
yum install libaio-devel
編譯參數
/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-5.6 \
-DMYSQL_DATADIR=/usr/local/mysql-5.6/data \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DENABLE_LOCAL_INFILE=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DMYSQL_TCP_PORT=3306 \
-DWITH_DEBUG=OFF \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DMYSQL_UNIX_ADDR=/tmp/mysql6.sock \
-DWITH_SSL=bundled \
-DENABLE_DTRACE=OFF
make;make install
軟體安裝OK
2. 停止其中一個從庫:
將原版本中的資料[data]目錄[/usr/local/mysql]拷貝到新版本對應的目錄下面[/usr/local/mysql-5.6]
cp -r /usr/local/mysql/data /usr/local/mysql-5.6/
3. 變更許可權:
chown -R root .
chown -R mysql data
4. 變更啟動指令碼
rm -f /etc/init.d/mysqld
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld-5.5
cp /usr/local/mysql-5.6/support-files/mysql.server /etc/init.d/mysqld-5.6
chmod +x /etc/init.d/mysqld-5.*
5.啟動新版本執行個體
注意:設定檔必須配置正確,如果配置了舊的參數,會導致執行個體無法啟動
/etc/init.d/mysqld-5.6 start
然後觀察錯誤檔案,會看到如下報錯:
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘setup_actors‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘setup_objects‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘table_io_waits_summary_by_index_usage‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘table_io_waits_summary_by_table‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘table_lock_waits_summary_by_table‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Column count of mysql.threads is wrong. Expected 14, found 3. Created with MySQL 50518, now running 50626. Please use mysql_upgrade to fix this error.
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_current‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_history‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_history_long‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_summary_by_thread_by_event_name‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_summary_by_account_by_event_name‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_summary_by_user_by_event_name‘ has the wrong structure
2015-08-04 13:16:31 18815 [ERROR] Native table ‘performance_schema‘.‘events_stages_summary_by_host_by_event_name‘ has the wrong structure
6. 運行新版本下的升級指令碼進行升級檢查,修複mysql庫中的主要表
/usr/local/mysql-5.6/bin/mysql_upgrade -u root -proot
Warning: Using a password on the command line interface can be insecure.
Looking for ‘mysql‘ as: /usr/local/mysql_5.6/bin/mysql
Looking for ‘mysqlcheck‘ as: /usr/local/mysql-5.6/bin/mysqlcheck
Running ‘mysqlcheck‘ with connection arguments: ‘--port=3306‘ ‘--socket=/tmp/mysql6.sock‘
Warning: Using a password on the command line interface can be insecure.
Running ‘mysqlcheck‘ with connection arguments: ‘--port=3306‘ ‘--socket=/tmp/mysql6.sock‘
Warning: Using a password on the command line interface can be insecure.
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.general_log OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.ndb_binlog_index OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.servers OK
mysql.slave_master_info OK
mysql.slave_relay_log_info OK
mysql.slave_worker_info OK
mysql.slow_log OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Running ‘mysql_fix_privilege_tables‘...
Warning: Using a password on the command line interface can be insecure.
Running ‘mysqlcheck‘ with connection arguments: ‘--port=3306‘ ‘--socket=/tmp/mysql6.sock‘
Warning: Using a password on the command line interface can be insecure.
Running ‘mysqlcheck‘ with connection arguments: ‘--port=3306‘ ‘--socket=/tmp/mysql6.sock‘
Warning: Using a password on the command line interface can be insecure.
babysitter.abc OK
babysitter.account_tactics_daily_availability OK
babysitter.andtlhz_new OK
7. 檢查完後重啟執行個體
/etc/init.d/mysqld-5.6 restart
設定檔
[client]
#default-character-set = utf8
port = 3306
socket = /tmp/mysql6.sock
[mysqld]
#skip-grant-tables
user = mysql
port = 3306
socket = /tmp/mysql6.sock
pid-file = /usr/local/mysql-5.6/data/mysql-upgrade-master.pid
#pid-file = /usr/local/mysql-5.6/data/[主機名稱].pid
#pid-file = /usr/local/mysql-5.6/data/[主機名稱].pid
##################
basedir = /usr/local/mysql-5.6
datadir = /usr/local/mysql-5.6/data
server-id = 1
#server-id = 2 #從庫1配置
#server-id = 3 #從庫2配置
log_slave_updates = 1
log_slave_updates = 0 #從庫配置
log-bin = mysql-bin
#log-bin = mysql-bin #從庫不需要開啟binlog
binlog_format = mixed
binlog_cache_size = 64M
max_binlog_cache_size = 128M
expire_logs_days = 2
max_binlog_size = 1G
binlog-ignore-db = mysql
binlog-ignore-db = test
binlog-ignore-db = information_schema
binlog-ignore-db = performance_schema
query_cache_type =0
key_buffer_size = 384M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 16M
join_buffer_size = 2M
thread_cache_size = 8
query_cache_size = 32M
query_cache_limit = 2M
query_cache_min_res_unit = 2K
thread_concurrency = 32
table_open_cache = 512
open_files_limit = 10240
back_log = 600
max_connections = 5000
max_connect_errors = 6000
external-locking = FALSE
max_allowed_packet = 10M
default-storage-engine = MYISAM
thread_stack = 192K
transaction_isolation = READ-COMMITTED
tmp_table_size = 256M
max_heap_table_size = 512M
bulk_insert_buffer_size = 64M
long_query_time = 2
slow_query_log
slow_query_log_file = /usr/local/mysql-5.6/data/slow_query.log
skip-name-resolve
explicit_defaults_for_timestamp = true #新版本關於時間戳記的新特性配置
innodb_buffer_pool_size = 512M
innodb_data_file_path = ibdata1:256M:autoextend
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_file_size = 128M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
innodb_file_per_table = 1
innodb_flush_method = O_DIRECT
[mysqldump]
quick
max_allowed_packet = 10M
[mysql]
no-auto-rehash
safe-updates
[mysqlhotcopy]
interactive-timeout
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
##################
以上操作順序為:從1》從2》主
特別注意設定檔的正確性
磁碟空間足夠存放兩份舊資料的大小
舊資料不動,以防升級失敗,可以回退到舊版本
本文出自 “影子騎士” 部落格,請務必保留此出處http://andylhz2009.blog.51cto.com/728703/1844007
MySQL主從架構由5.5版本升級到5.6方案