Fix backup of mysql variants on Centos

The switch to XtraBackup 2.3 was causing an issue on RHEL/Centos
related to is using the "mysql" user instead of "trove". The fix on
Ubuntu was to move the os_admin credentials to ~trove/.my.cnf. While
this is a better place to write the credentials anyway (i.e. they
shouldn't be stored in server my.cnf) this doesn't solve the whole
issue on Centos. This commit changes the XB backup strategy to pass
the user/password in on the innobackupex command line.

Also, it was noticed that the "socket" option wasn't being specified
in the config.template. This is causing some client connections,
such as XB to fail connect because it can't locate the socket.
Forcing the server/client to write/read the socket from a known
location fixes this.

Change-Id: Iea941ce60179ef4dc5c403c2fc374cc8eb7d1617
Closes-bug: 1649592
This commit is contained in:
Doug Shelley 2016-01-19 20:22:03 +00:00
parent 8adfb7e4f2
commit f5d1caea88
6 changed files with 24 additions and 4 deletions

View File

@ -22,7 +22,8 @@
"open_files_limit": 512,
"performance_schema": "ON",
"pid_file": "/var/run/mysqld/mysqld.pid",
"port": 3306,
"socket": "/var/run/mysqld/mysqld.sock",
"port": "3306",
"query_cache_limit": "1M",
"query_cache_size": "8M",
"query_cache_type": 1,

View File

@ -0,0 +1,5 @@
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 1151
Date: Mon, 18 Mar 2013 19:09:17 GMT

View File

@ -49,11 +49,18 @@ class InnoBackupEx(base.BackupRunner):
"""Implementation of Backup Strategy for InnoBackupEx."""
__strategy_name__ = 'innobackupex'
@property
def user_and_pass(self):
return (' --user=%(user)s --password=%(password)s ' %
{'user': ADMIN_USER_NAME,
'password': MySqlApp.get_auth_password()})
@property
def cmd(self):
cmd = ('sudo innobackupex'
' --stream=xbstream'
' %(extra_opts)s ' +
self.user_and_pass +
MySqlApp.get_data_dir() +
' 2>/tmp/innobackupex.log'
)
@ -109,6 +116,7 @@ class InnoBackupExIncremental(InnoBackupEx):
' --incremental'
' --incremental-lsn=%(lsn)s'
' %(extra_opts)s ' +
self.user_and_pass +
MySqlApp.get_data_dir() +
' 2>/tmp/innobackupex.log')
return cmd + self.zip_cmd + self.encrypt_cmd

View File

@ -1,5 +1,6 @@
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
nice = 0
@ -13,6 +14,7 @@ basedir = /usr
datadir = /var/lib/mysql/data
tmpdir = /var/tmp
pid_file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
skip-external-locking = 1
key_buffer_size = {{ (50 * flavor['ram']/512)|int }}M
max_allowed_packet = {{ (1024 * flavor['ram']/512)|int }}K

View File

@ -230,7 +230,8 @@ class BackupAgentTest(trove_testtools.TestCase):
self.assertIsNotNone(inno_backup_ex.cmd)
str_innobackup_cmd = ('sudo innobackupex'
' --stream=xbstream'
' %(extra_opts)s'
' %(extra_opts)s '
' --user=os_admin --password=123'
' /var/lib/mysql/data 2>/tmp/innobackupex.log'
' | gzip |'
' openssl enc -aes-256-cbc -salt '

View File

@ -77,13 +77,16 @@ ZIP = "gzip"
UNZIP = "gzip -d -c"
ENCRYPT = "openssl enc -aes-256-cbc -salt -pass pass:default_aes_cbc_key"
DECRYPT = "openssl enc -d -aes-256-cbc -salt -pass pass:default_aes_cbc_key"
XTRA_BACKUP_RAW = ("sudo innobackupex --stream=xbstream %(extra_opts)s"
XTRA_BACKUP_RAW = ("sudo innobackupex --stream=xbstream %(extra_opts)s "
" --user=os_admin --password=password"
" /var/lib/mysql/data 2>/tmp/innobackupex.log")
XTRA_BACKUP = XTRA_BACKUP_RAW % {'extra_opts': ''}
XTRA_BACKUP_EXTRA_OPTS = XTRA_BACKUP_RAW % {'extra_opts': '--no-lock'}
XTRA_BACKUP_INCR = ('sudo innobackupex --stream=xbstream'
' --incremental --incremental-lsn=%(lsn)s'
' %(extra_opts)s /var/lib/mysql/data'
' %(extra_opts)s '
' --user=os_admin --password=password'
' /var/lib/mysql/data'
' 2>/tmp/innobackupex.log')
SQLDUMP_BACKUP_RAW = ("mysqldump --all-databases %(extra_opts)s "
"--opt --password=password -u os_admin"