Rackspace API/Cloud Databases

From Christoph's Personal Wiki
Revision as of 06:21, 11 September 2014 by Christoph (Talk | contribs) (New page: ==Population timezone tables== In order to populate the timezone tables for a given Cloud Database, you must first enable root on your instance. However, this must be [http://docs.rackspac...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Population timezone tables

In order to populate the timezone tables for a given Cloud Database, you must first enable root on your instance. However, this must be done via the Rackspace API.

Please make sure you note the important caveat that accompanies this process:

"Changes you make as a root user may cause detrimental effects to the database instance and unpredictable behavior for API operations. When you enable the root user, you accept the possibility that we will not be able to support your database instance. While enabling root does not prevent us from a 'best effort' approach to helping you if something goes wrong with your instance, we cannot ensure that we will be able to assist you if you change core database settings. These changes can be (but are not limited to) turning off binlogs, removing users that we use to access your instance, and so forth."

So, for an example, to enable root on a Cloud Database instance named "foobar" (id: aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee; dc: DFW), you would run the following commands:

$ USERNAME=<YOUR_ACCOUNT_USERNAME>
$ API_KEY=<YOUR_API_KEY>
$ TOKEN=`curl -s -XPOST https://identity.api.rackspacecloud.com/v2.0/tokens \
  -d'{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$USERNAME'","apiKey":"'$API_KEY'"}}}' \
  -H"Content-type:application/json" | \
  python -c 'import sys,json;data=json.loads(sys.stdin.read());print data["access"]["token"]["id"]'`
$ REGION=dfw
$ ACCOUNT=<YOUR_ACCOUNT_NUMBER>
$ ENDPOINT=https://${REGION}.databases.api.rackspacecloud.com/v1.0/${ACCOUNT}
$ DB_UUID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee  # "foobar" instance ID
$ curl -XPOST -H "X-Auth-Token: $TOKEN" "$ENDPOINT/instances/${DB_UUID}/root.json" | python -m json.tool

That last commend will enable root and return the root password (note: If you ever forget your root password for a given instance, simply run that last command again and it will return your root password).

Now that root has been enabled on your Cloud Database instance, you can run the following commands from within a Cloud Server (it must be in the same region; "DFW" for this example):

$ DB_HOSTNAME=ffffffffffffffffffffffffffffffffffffffff.rackspaceclouddb.com # use your DB's real hostname
$ mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root -p -h $DB_HOSTNAME mysql

You can verify that the tables have been loaded by logging into your MySQL instance like so:

$ mysql -u root -p -h $DB_HOSTNAME mysql  # provide the root password given above

See also: "Managing the Time Zone with cURL".