@@ -34,7 +34,7 @@ import kubernetes.client
34
34
import kubernetes .config
35
35
36
36
#set one name for all commands, avoid "magic names"
37
- MYSQL_BINARY_NAME = 'mysqld '
37
+ MYSQL_BINARY_NAME = 'mariadbd '
38
38
39
39
# Create logger, console handler and formatter
40
40
logger = logging .getLogger ('OpenStack-Helm Mariadb' )
@@ -182,8 +182,8 @@ def wait_mysql_status(delay=30):
182
182
i = 0
183
183
res = 1
184
184
while True :
185
- logger .info ("Checking mysql status {0}" .format (i ))
186
- res = run_cmd_with_logging (['mysqladmin ' , 'status' , "-u{0}" .format (mysql_dbadmin_username ),
185
+ logger .info ("Checking mariadb status {0}" .format (i ))
186
+ res = run_cmd_with_logging (['mariadb-admin ' , 'status' , "-u{0}" .format (mysql_dbadmin_username ),
187
187
"-p{0}" .format (mysql_dbadmin_password )], logger )
188
188
if res == 0 :
189
189
logger .info ("mariadb status check passed" )
@@ -195,8 +195,8 @@ def wait_mysql_status(delay=30):
195
195
196
196
197
197
def stop_mysqld ():
198
- """Stop mysqld , assuming pid file in default location."""
199
- logger .info ("Shutting down any mysqld instance if required" )
198
+ """Stop mariadbd , assuming pid file in default location."""
199
+ logger .info ("Shutting down any mariadbd instance if required" )
200
200
mysqld_pidfile_path = "/var/lib/mysql/{0}.pid" .format (local_hostname )
201
201
202
202
def is_pid_running (pid ):
@@ -213,7 +213,7 @@ def stop_mysqld():
213
213
return False
214
214
215
215
if not os .path .isfile (mysqld_pidfile_path ):
216
- logger .debug ("No previous pid file found for mysqld " )
216
+ logger .debug ("No previous pid file found for mariadbd " )
217
217
return
218
218
219
219
if os .stat (mysqld_pidfile_path ).st_size == 0 :
@@ -223,7 +223,7 @@ def stop_mysqld():
223
223
return
224
224
225
225
logger .info (
226
- "Previous pid file found for mysqld , attempting to shut it down" )
226
+ "Previous pid file found for mariadbd , attempting to shut it down" )
227
227
with open (mysqld_pidfile_path , "r" ) as mysqld_pidfile :
228
228
mysqld_pid = int (mysqld_pidfile .readlines ()[0 ].rstrip ('\n ' ))
229
229
@@ -235,11 +235,11 @@ def stop_mysqld():
235
235
return
236
236
if not is_pid_mysqld (mysqld_pid ):
237
237
logger .error (
238
- "pidfile process is not mysqld , removing pidfile and panic" )
238
+ "pidfile process is not mariadbd , removing pidfile and panic" )
239
239
os .remove (mysqld_pidfile_path )
240
240
sys .exit (1 )
241
241
242
- logger .info ("pid from pidfile is mysqld " )
242
+ logger .info ("pid from pidfile is mariadbd " )
243
243
os .kill (mysqld_pid , 15 )
244
244
try :
245
245
pid , status = os .waitpid (mysqld_pid , 0 )
@@ -283,7 +283,7 @@ def mysqld_write_cluster_conf(mode='run'):
283
283
cluster_config .write (configfile )
284
284
285
285
286
- # Function to setup mysqld
286
+ # Function to setup mariadbd
287
287
def mysqld_bootstrap ():
288
288
"""Bootstrap the db if no data found in the 'bootstrap_test_dir'"""
289
289
logger .info ("Boostrapping Mariadb" )
@@ -293,7 +293,7 @@ def mysqld_bootstrap():
293
293
stop_mysqld ()
294
294
mysqld_write_cluster_conf (mode = 'bootstrap' )
295
295
run_cmd_with_logging ([
296
- 'mysql_install_db ' , '--user=mysql' ,
296
+ 'mariadb-install-db ' , '--user=mysql' ,
297
297
"--datadir={0}" .format (mysql_data_dir )
298
298
], logger )
299
299
if not mysql_dbaudit_username :
@@ -310,7 +310,7 @@ def mysqld_bootstrap():
310
310
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{2}'@'127.0.0.1' ;\n "
311
311
"CREATE OR REPLACE USER '{4}'@'%' IDENTIFIED BY '{5}' ;\n "
312
312
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{4}'@'%' ;\n "
313
- # needed for mariabackup --history option
313
+ # needed for mariadb-backup --history option
314
314
"GRANT CREATE, INSERT ON PERCONA_SCHEMA.* TO '{4}'@'%';\n "
315
315
"FLUSH PRIVILEGES ;\n "
316
316
"SHUTDOWN ;" .format (mysql_dbadmin_username , mysql_dbadmin_password ,
@@ -328,7 +328,7 @@ def mysqld_bootstrap():
328
328
"GRANT SELECT ON *.* TO '{4}'@'%' ;\n "
329
329
"CREATE OR REPLACE USER '{6}'@'%' IDENTIFIED BY '{7}' ;\n "
330
330
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{6}'@'%' ;\n "
331
- # needed for mariabackup --history option
331
+ # needed for mariadb-backup --history option
332
332
"GRANT CREATE, INSERT ON PERCONA_SCHEMA.* TO '{6}'@'%';\n "
333
333
"FLUSH PRIVILEGES ;\n "
334
334
"SHUTDOWN ;" .format (mysql_dbadmin_username , mysql_dbadmin_password ,
@@ -847,7 +847,7 @@ def launch_leader_election():
847
847
848
848
849
849
def run_mysqld (cluster = 'existing' ):
850
- """Launch the mysqld instance for the pod. This will also run mysql upgrade
850
+ """Launch the mariadbd instance for the pod. This will also run mariadb upgrade
851
851
if we are the 1st replica, and the rest of the cluster is already running.
852
852
This senario will be triggerd either following a rolling update, as this
853
853
works in reverse order for statefulset. Or restart of the 1st instance, in
@@ -868,7 +868,7 @@ def run_mysqld(cluster='existing'):
868
868
mysql_data_dir = '/var/lib/mysql'
869
869
db_test_dir = "{0}/mysql" .format (mysql_data_dir )
870
870
if os .path .isdir (db_test_dir ):
871
- logger .info ("Setting the admin passwords to the current value and upgrade mysql if needed" )
871
+ logger .info ("Setting the admin passwords to the current value and upgrade mariadb if needed" )
872
872
if not mysql_dbaudit_username :
873
873
template = (
874
874
"CREATE OR REPLACE USER '{0}'@'%' IDENTIFIED BY \' {1}\' ;\n "
@@ -877,7 +877,7 @@ def run_mysqld(cluster='existing'):
877
877
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{2}'@'127.0.0.1' ;\n "
878
878
"CREATE OR REPLACE USER '{4}'@'%' IDENTIFIED BY '{5}' ;\n "
879
879
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{4}'@'%' ;\n "
880
- # needed for mariabackup --history option
880
+ # needed for mariadb-backup --history option
881
881
"GRANT CREATE, INSERT ON PERCONA_SCHEMA.* TO '{4}'@'%';\n "
882
882
"FLUSH PRIVILEGES ;" .format (mysql_dbadmin_username , mysql_dbadmin_password ,
883
883
mysql_dbsst_username , mysql_dbsst_password ,
@@ -892,7 +892,7 @@ def run_mysqld(cluster='existing'):
892
892
"GRANT SELECT ON mysql.user TO '{4}'@'%' ;\n "
893
893
"CREATE OR REPLACE USER '{6}'@'%' IDENTIFIED BY '{7}' ;\n "
894
894
"GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO '{6}'@'%' ;\n "
895
- # needed for mariabackup --history option
895
+ # needed for mariadb-backup --history option
896
896
"GRANT CREATE, INSERT ON PERCONA_SCHEMA.* TO '{6}'@'%';\n "
897
897
"FLUSH PRIVILEGES ;" .format (mysql_dbadmin_username , mysql_dbadmin_password ,
898
898
mysql_dbsst_username , mysql_dbsst_password ,
@@ -902,15 +902,15 @@ def run_mysqld(cluster='existing'):
902
902
with open (bootstrap_sql_file , 'w' ) as f :
903
903
f .write (template )
904
904
f .close ()
905
- # run mysqld as thread and check it's status in order to upgrade it
905
+ # run mariadbd as thread and check it's status in order to upgrade it
906
906
run_cmd_with_logging_thread = threading .Thread (target = run_cmd_with_logging , args = ([
907
907
MYSQL_BINARY_NAME , '--bind-address=127.0.0.1' , '--wsrep-on=false' ,
908
908
"--init-file={0}" .format (bootstrap_sql_file )
909
909
], logger ))
910
910
run_cmd_with_logging_thread .start ()
911
911
wait_mysql_status ()
912
- logger .info ("Upgrading local mysql instance" )
913
- upgrade_res = run_cmd_with_logging (['mysql_upgrade ' , '--skip-write-binlog' ,
912
+ logger .info ("Upgrading local mariadb instance" )
913
+ upgrade_res = run_cmd_with_logging (['mariadb-upgrade ' , '--skip-write-binlog' ,
914
914
"-u{0}" .format (mysql_dbadmin_username ), "-p{0}" .format (mysql_dbadmin_password )], logger )
915
915
if upgrade_res != 0 :
916
916
raise Exception ('Mysql upgrade failed, cannot proceed' )
@@ -930,14 +930,14 @@ def run_mysqld(cluster='existing'):
930
930
931
931
932
932
def mysqld_reboot ():
933
- """Reboot a mysqld cluster."""
933
+ """Reboot a mariadbd cluster."""
934
934
declare_myself_cluster_leader ()
935
935
set_grastate_val (key = 'safe_to_bootstrap' , value = '1' )
936
936
run_mysqld (cluster = 'new' )
937
937
938
938
939
939
def sigterm_shutdown (x , y ):
940
- """Shutdown the instance of mysqld on shutdown signal."""
940
+ """Shutdown the instance of mariadbd on shutdown signal."""
941
941
logger .info ("Got a sigterm from the container runtime, time to go." )
942
942
stop_event .set ()
943
943
stop_mysqld ()
0 commit comments