Created
October 22, 2012 20:38
-
-
Save dallasmarlow/3934017 to your computer and use it in GitHub Desktop.
consistent mysql server-id values based on mac address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert the last 4 octets of a mac address to base 10 for a numeric value between 0-4294967295 (which is the supported range for mysql's server-id) | |
# example mac address - "00:26:9E:2B:C7:36" | |
mac_address.split(':')[2..5].join.to_i(16) | |
# => 2653669174 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment