SHARE
TWEET

ahihi aws rds

a guest May 21st, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mysql> show create procedure rds_set_external_master\G;
  2. *************************** 1. row ***************************
  3.            Procedure: rds_set_external_master
  4.             sql_mode: NO_ENGINE_SUBSTITUTION
  5.     Create Procedure: CREATE DEFINER=`rdsadmin`@`localhost` PROCEDURE `rds_set_external_master`(host VARCHAR(255),
  6. port INT,
  7. user TEXT,
  8. passwd TEXT,
  9. name TEXT,
  10. pos LONG ,
  11. enable_ssl_encryption BOOLEAN
  12. )
  13. BEGIN
  14. DECLARE v_rdsrepl INT;
  15. DECLARE v_mysql_version VARCHAR(20);
  16. DECLARE v_called_by_user VARCHAR(50);
  17. DECLARE v_sleep int;
  18. DECLARE sql_logging BOOLEAN;
  19. SET @regex = '.*"[[:space:]]*,[[:space:]]*[a-zA-Z_]+[[:space:]]*=[[:space:]]*".*';
  20. IF host REGEXP @regex
  21. OR user REGEXP @regex
  22. OR passwd REGEXP @regex
  23. OR name REGEXP @regex THEN
  24. SELECT "Invalid arguments" as Message;
  25. ELSE
  26. select @@sql_log_bin into sql_logging;
  27. Select count(1) into v_rdsrepl from mysql.rds_history where action = 'disable set master' and master_user = 'rdsrepladmin';
  28. Select user() into v_called_by_user;
  29. select version() into v_mysql_version;
  30. set @@sql_log_bin=off;
  31. IF v_rdsrepl > 0 and  v_called_by_user != 'rdsadmin@localhost'
  32. THEN
  33. Select 'RDS_SET_EXTERNAL_MASTER is disabled on this host.' as Message;
  34. ELSE
  35. SET @cmd = CONCAT('CHANGE MASTER TO ',
  36. CONCAT_WS(', ',
  37. CONCAT('MASTER_HOST = "', trim(both from host), '"'),
  38. CONCAT('MASTER_PORT = ', port),
  39. CONCAT('MASTER_USER = "', trim(both from user), '"'),
  40. CONCAT('MASTER_PASSWORD = "', trim(both from passwd), '"'),
  41. CONCAT('MASTER_LOG_FILE = "', trim(both from name), '"'),
  42. CONCAT('MASTER_LOG_POS = ', pos),
  43. CONCAT('MASTER_SSL = ', enable_ssl_encryption),
  44. CONCAT('MASTER_AUTO_POSITION = 0')));
  45. PREPARE rds_set_master FROM @cmd;
  46. update mysql.rds_replication_status set called_by_user=v_called_by_user, action='set master', mysql_version=v_mysql_version , master_host=trim(both from host), master_port=port where action is not null;
  47. commit;
  48. call mysql.rds_clean_replication_status;
  49. EXECUTE rds_set_master;
  50. DEALLOCATE PREPARE rds_set_master;
  51. INSERT into mysql.rds_history(called_by_user, action, mysql_version, master_host, master_port, master_user, master_log_file, master_log_pos, master_ssl, auto_position)
  52. values (v_called_by_user,'set master', v_mysql_version, trim(both from host), port, trim(both from user), trim(both from name), pos, enable_ssl_encryption, 0);
  53. commit;
  54.  END IF;
  55. set @@sql_log_bin=sql_logging;
  56. END IF;
  57. END
  58. character_set_client: latin1
  59. collation_connection: latin1_swedish_ci
  60.   Database Collation: latin1_swedish_ci
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top