diff options
Diffstat (limited to 'extra/mariabackup/backup_mysql.cc')
-rw-r--r-- | extra/mariabackup/backup_mysql.cc | 340 |
1 files changed, 179 insertions, 161 deletions
diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index 843ebf2663e..d5d0c90376e 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -326,194 +326,212 @@ check_server_version(unsigned long version_number, /*********************************************************************//** Receive options important for XtraBackup from MySQL server. @return true on success. */ -bool -get_mysql_vars(MYSQL *connection) +bool get_mysql_vars(MYSQL *connection) { - char *gtid_mode_var = NULL; - char *version_var = NULL; - char *version_comment_var = NULL; - char *innodb_version_var = NULL; - char *have_backup_locks_var = NULL; - char *log_bin_var = NULL; - char *lock_wait_timeout_var= NULL; - char *wsrep_on_var = NULL; - char *slave_parallel_workers_var = NULL; - char *gtid_slave_pos_var = NULL; - char *innodb_buffer_pool_filename_var = NULL; - char *datadir_var = NULL; - char *innodb_log_group_home_dir_var = NULL; - char *innodb_log_file_size_var = NULL; - char *innodb_log_files_in_group_var = NULL; - char *innodb_data_file_path_var = NULL; - char *innodb_data_home_dir_var = NULL; - char *innodb_undo_directory_var = NULL; - char *innodb_page_size_var = NULL; - char *innodb_undo_tablespaces_var = NULL; - char *page_zip_level_var = NULL; - char *endptr; - unsigned long server_version = mysql_get_server_version(connection); - - bool ret = true; - - mysql_variable mysql_vars[] = { - {"have_backup_locks", &have_backup_locks_var}, - {"log_bin", &log_bin_var}, - {"lock_wait_timeout", &lock_wait_timeout_var}, - {"gtid_mode", >id_mode_var}, - {"version", &version_var}, - {"version_comment", &version_comment_var}, - {"innodb_version", &innodb_version_var}, - {"wsrep_on", &wsrep_on_var}, - {"slave_parallel_workers", &slave_parallel_workers_var}, - {"gtid_slave_pos", >id_slave_pos_var}, - {"innodb_buffer_pool_filename", - &innodb_buffer_pool_filename_var}, - {"datadir", &datadir_var}, - {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, - {"innodb_log_file_size", &innodb_log_file_size_var}, - {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, - {"innodb_data_file_path", &innodb_data_file_path_var}, - {"innodb_data_home_dir", &innodb_data_home_dir_var}, - {"innodb_undo_directory", &innodb_undo_directory_var}, - {"innodb_page_size", &innodb_page_size_var}, - {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, - {"innodb_compression_level", &page_zip_level_var}, - {NULL, NULL} - }; - - read_mysql_variables(connection, "SHOW VARIABLES", - mysql_vars, true); + char *gtid_mode_var= NULL; + char *version_var= NULL; + char *version_comment_var= NULL; + char *innodb_version_var= NULL; + char *have_backup_locks_var= NULL; + char *log_bin_var= NULL; + char *lock_wait_timeout_var= NULL; + char *wsrep_on_var= NULL; + char *slave_parallel_workers_var= NULL; + char *gtid_slave_pos_var= NULL; + char *innodb_buffer_pool_filename_var= NULL; + char *datadir_var= NULL; + char *innodb_log_group_home_dir_var= NULL; + char *innodb_log_file_size_var= NULL; + char *innodb_log_files_in_group_var= NULL; + char *innodb_data_file_path_var= NULL; + char *innodb_data_home_dir_var= NULL; + char *innodb_undo_directory_var= NULL; + char *innodb_page_size_var= NULL; + char *innodb_undo_tablespaces_var= NULL; + char *page_zip_level_var= NULL; + char *ignore_db_dirs= NULL; + char *endptr; + unsigned long server_version= mysql_get_server_version(connection); + + bool ret= true; + + mysql_variable mysql_vars[]= { + {"have_backup_locks", &have_backup_locks_var}, + {"log_bin", &log_bin_var}, + {"lock_wait_timeout", &lock_wait_timeout_var}, + {"gtid_mode", >id_mode_var}, + {"version", &version_var}, + {"version_comment", &version_comment_var}, + {"innodb_version", &innodb_version_var}, + {"wsrep_on", &wsrep_on_var}, + {"slave_parallel_workers", &slave_parallel_workers_var}, + {"gtid_slave_pos", >id_slave_pos_var}, + {"innodb_buffer_pool_filename", &innodb_buffer_pool_filename_var}, + {"datadir", &datadir_var}, + {"innodb_log_group_home_dir", &innodb_log_group_home_dir_var}, + {"innodb_log_file_size", &innodb_log_file_size_var}, + {"innodb_log_files_in_group", &innodb_log_files_in_group_var}, + {"innodb_data_file_path", &innodb_data_file_path_var}, + {"innodb_data_home_dir", &innodb_data_home_dir_var}, + {"innodb_undo_directory", &innodb_undo_directory_var}, + {"innodb_page_size", &innodb_page_size_var}, + {"innodb_undo_tablespaces", &innodb_undo_tablespaces_var}, + {"innodb_compression_level", &page_zip_level_var}, + {"ignore_db_dirs", &ignore_db_dirs}, + {NULL, NULL}}; + + read_mysql_variables(connection, "SHOW VARIABLES", mysql_vars, true); + + if (have_backup_locks_var != NULL && !opt_no_backup_locks) + { + have_backup_locks= true; + } - if (have_backup_locks_var != NULL && !opt_no_backup_locks) { - have_backup_locks = true; - } + if (opt_binlog_info == BINLOG_INFO_AUTO) + { + if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) + opt_binlog_info= BINLOG_INFO_ON; + else + opt_binlog_info= BINLOG_INFO_OFF; + } - if (opt_binlog_info == BINLOG_INFO_AUTO) { - if (log_bin_var != NULL && !strcmp(log_bin_var, "ON")) - opt_binlog_info = BINLOG_INFO_ON; - else - opt_binlog_info = BINLOG_INFO_OFF; - } + if (lock_wait_timeout_var != NULL) + { + have_lock_wait_timeout= true; + } - if (lock_wait_timeout_var != NULL) { - have_lock_wait_timeout = true; - } + if (wsrep_on_var != NULL) + { + have_galera_enabled= true; + } - if (wsrep_on_var != NULL) { - have_galera_enabled = true; - } + /* Check server version compatibility and detect server flavor */ - /* Check server version compatibility and detect server flavor */ + if (!(ret= check_server_version(server_version, version_var, + version_comment_var, innodb_version_var))) + { + goto out; + } - if (!(ret = check_server_version(server_version, version_var, - version_comment_var, - innodb_version_var))) { - goto out; - } + if (server_version > 50500) + { + have_flush_engine_logs= true; + } - if (server_version > 50500) { - have_flush_engine_logs = true; - } + if (slave_parallel_workers_var != NULL && + atoi(slave_parallel_workers_var) > 0) + { + have_multi_threaded_slave= true; + } - if (slave_parallel_workers_var != NULL - && atoi(slave_parallel_workers_var) > 0) { - have_multi_threaded_slave = true; - } + if (innodb_buffer_pool_filename_var != NULL) + { + buffer_pool_filename= strdup(innodb_buffer_pool_filename_var); + } - if (innodb_buffer_pool_filename_var != NULL) { - buffer_pool_filename = strdup(innodb_buffer_pool_filename_var); - } + if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || + (gtid_slave_pos_var && *gtid_slave_pos_var)) + { + have_gtid_slave= true; + } - if ((gtid_mode_var && strcmp(gtid_mode_var, "ON") == 0) || - (gtid_slave_pos_var && *gtid_slave_pos_var)) { - have_gtid_slave = true; - } + msg("Using server version %s", version_var); - msg("Using server version %s", version_var); + if (!(ret= detect_mysql_capabilities_for_backup())) + { + goto out; + } - if (!(ret = detect_mysql_capabilities_for_backup())) { - goto out; - } + /* make sure datadir value is the same in configuration file */ + if (check_if_param_set("datadir")) + { + if (!directory_exists(mysql_data_home, false)) + { + msg("Warning: option 'datadir' points to " + "nonexistent directory '%s'", + mysql_data_home); + } + if (!directory_exists(datadir_var, false)) + { + msg("Warning: MySQL variable 'datadir' points to " + "nonexistent directory '%s'", + datadir_var); + } + if (!equal_paths(mysql_data_home, datadir_var)) + { + msg("Warning: option 'datadir' has different " + "values:\n" + " '%s' in defaults file\n" + " '%s' in SHOW VARIABLES", + mysql_data_home, datadir_var); + } + } - /* make sure datadir value is the same in configuration file */ - if (check_if_param_set("datadir")) { - if (!directory_exists(mysql_data_home, false)) { - msg("Warning: option 'datadir' points to " - "nonexistent directory '%s'", mysql_data_home); - } - if (!directory_exists(datadir_var, false)) { - msg("Warning: MySQL variable 'datadir' points to " - "nonexistent directory '%s'", datadir_var); - } - if (!equal_paths(mysql_data_home, datadir_var)) { - msg("Warning: option 'datadir' has different " - "values:\n" - " '%s' in defaults file\n" - " '%s' in SHOW VARIABLES", - mysql_data_home, datadir_var); - } - } + /* get some default values is they are missing from my.cnf */ + if (datadir_var && *datadir_var) + { + strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); + mysql_data_home= mysql_real_data_home; + } - /* get some default values is they are missing from my.cnf */ - if (datadir_var && *datadir_var) { - strmake(mysql_real_data_home, datadir_var, FN_REFLEN - 1); - mysql_data_home= mysql_real_data_home; - } + if (innodb_data_file_path_var && *innodb_data_file_path_var) + { + innobase_data_file_path= my_strdup(innodb_data_file_path_var, MYF(MY_FAE)); + } - if (innodb_data_file_path_var && *innodb_data_file_path_var) { - innobase_data_file_path = my_strdup( - innodb_data_file_path_var, MYF(MY_FAE)); - } + if (innodb_data_home_dir_var) + { + innobase_data_home_dir= my_strdup(innodb_data_home_dir_var, MYF(MY_FAE)); + } - if (innodb_data_home_dir_var) { - innobase_data_home_dir = my_strdup( - innodb_data_home_dir_var, MYF(MY_FAE)); - } + if (innodb_log_group_home_dir_var && *innodb_log_group_home_dir_var) + { + srv_log_group_home_dir= + my_strdup(innodb_log_group_home_dir_var, MYF(MY_FAE)); + } - if (innodb_log_group_home_dir_var - && *innodb_log_group_home_dir_var) { - srv_log_group_home_dir = my_strdup( - innodb_log_group_home_dir_var, MYF(MY_FAE)); - } + if (innodb_undo_directory_var && *innodb_undo_directory_var) + { + srv_undo_dir= my_strdup(innodb_undo_directory_var, MYF(MY_FAE)); + } - if (innodb_undo_directory_var && *innodb_undo_directory_var) { - srv_undo_dir = my_strdup( - innodb_undo_directory_var, MYF(MY_FAE)); - } + if (innodb_log_files_in_group_var) + { + srv_n_log_files= strtol(innodb_log_files_in_group_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_files_in_group_var) { - srv_n_log_files = strtol( - innodb_log_files_in_group_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_log_file_size_var) + { + srv_log_file_size= strtoll(innodb_log_file_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_log_file_size_var) { - srv_log_file_size = strtoll( - innodb_log_file_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_page_size_var) + { + innobase_page_size= strtoll(innodb_page_size_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_page_size_var) { - innobase_page_size = strtoll( - innodb_page_size_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (innodb_undo_tablespaces_var) + { + srv_undo_tablespaces= strtoul(innodb_undo_tablespaces_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (innodb_undo_tablespaces_var) { - srv_undo_tablespaces = strtoul(innodb_undo_tablespaces_var, - &endptr, 10); - ut_ad(*endptr == 0); - } + if (page_zip_level_var != NULL) + { + page_zip_level= strtoul(page_zip_level_var, &endptr, 10); + ut_ad(*endptr == 0); + } - if (page_zip_level_var != NULL) { - page_zip_level = strtoul(page_zip_level_var, &endptr, 10); - ut_ad(*endptr == 0); - } + if (ignore_db_dirs) + xb_load_list_string(ignore_db_dirs, ",", register_ignore_db_dirs_filter); out: - free_mysql_variables(mysql_vars); + free_mysql_variables(mysql_vars); - return(ret); + return (ret); } /*********************************************************************//** |