frame

Sveiki apsilankę!

Jei forume lankaisi pirmą kartą, kviečiame registruotis ir prisijungti prie diskusijų.

Prisijungti Registruotis

MySQL migravimas į MariaDB CentOS 6 aplinkoje

IV_VygandasSIV_VygandasS Serverių ekspertas (-ė)
edited 2013 birželio 21 Į Duomenų bazių serveriai
Šioje pamokoje aprašysime kaip migruoti iš MySQL į MariaDB serverį CentOS 6 aplinkoje.

Prieš atliekant migravimą rekomenduojama atsižvelgti ar migravimas neįtakos kitų serveryje veikiančių tarnybų.

Ši pamoka ištestuota CentOS 6 versijoje.

1. Eksportuojame MySQL duomenų bazes:
mysqldump -u root -p --all-databases > alldb.sq
[COLOR="DarkSlateGray"]-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.l[/COLOR]

taip pat galime pasidaryti papildomą duomenų bazių kopiją:
cp -r /var/lib/mysql /var/lib/mysql.bak

2. Sustabdome mysqld tarnybą:
service mysqld stop
[COLOR="DarkSlateGray"]Stopping mysqld:                                           [  [COLOR="Lime"]OK[/COLOR]  ][/COLOR]
chkconfig mysqld off

3. Pasidarome atsarginę MySQL konfigūracijos kopiją:
cp /etc/my.cnf /etc/my.cnf.old

4. Pašaliname MySQL paketus:
yum remove mysql* mysql-server mysql-devel mysql-libs

5. Sukuriame MariaDB repozitoriją, priklausomai nuo naudojamos operacinės sistemos tipo:
  • 32bit sistemoms:
    vi /etc/yum.repos.d/mariadb.repo
    
    Įterpiame:
    # MariaDB 5.5 CentOS repository list - created 2013-06-06 07:42 UTC
    # http://mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/5.5/centos6-x86
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    
  • 64bit sistemoms:
    vi /etc/yum.repos.d/mariadb.repo
    
    Įterpiame:
    # MariaDB 5.5 CentOS repository list - created 2013-06-06 07:53 UTC
    # http://mariadb.org/mariadb/repositories/
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/5.5/centos6-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
    

7. Atliekame sistemos atnaujinimą:
yum update

8. Įdiegiame MariaDB:
yum install MariaDB-devel MariaDB-client MariaDB-server -y

9. Paleidžiame MariaDB tarnybą:
service mysql start 
[COLOR="DarkSlateGray"]Starting MySQL...... SUCCESS! [/COLOR]
chkconfig mysql on

10. Nustatome MySQL root vartotojo slaptažodį:
/usr/bin/mysql_secure_installation 

[COLOR="DarkSlateGray"]/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] [COLOR="Black"]y[/COLOR] 
New password: 
Re-enter new password: 
Password updated successfully! 
Reloading privilege tables..  
... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] [COLOR="Black"]y[/COLOR]
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] [COLOR="Black"]y[/COLOR]
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] [COLOR="Black"]y[/COLOR]
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] [COLOR="Black"]y[/COLOR]
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB![/COLOR]

11. Atstatome /etc/my.cnf konfigūracinį failą:
[root@server ~]# cp /etc/my.cnf.old /etc/my.cnf
[COLOR="DarkSlateGray"]cp: overwrite `/etc/my.cnf'?[/COLOR] y

arba atliekame atstatymą iš automatiškai sukurtos atsarginės kopijos po mysql tarnybos pašalinimo:
cp /etc/my.cnf.rpmsave /etc/my.cnf
[COLOR="DarkSlateGray"]cp: overwrite `/etc/my.cnf'[/COLOR]? y

12. Importuojame duomenų bazes:
mysql -u root -p < alldb.sql
[COLOR="DarkSlateGray"]Enter password:[/COLOR]

13. Perkrauname MariaDB tarnybą:
[root@server ~]# service mysql restart 
[COLOR="DarkSlateGray"]Shutting down MySQL.. SUCCESS! 
Starting MySQL...... SUCCESS![/COLOR]

14. Prisijungiame root vartotoju patikrinti ar diegimas atliktas korektiškai:
mysql -u root -p
[COLOR="DarkSlateGray"]Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: [B]5.5.31-MariaDB MariaDB Server[/B]

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> [/COLOR]

15. Patikriname duomenų bazes:
MariaDB [(none)]> show databases;
[COLOR="DarkSlateGray"]+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
| wordpress          |
+--------------------+
4 rows in set (0.00 sec)[/COLOR]

16. Patikriname duomenų bazių serverio statusą:
MariaDB [(none)]> status;
[COLOR="DarkSlateGray"]--------------
mysql  Ver 15.1 Distrib 5.5.31-MariaDB, for Linux (x86_64) using readline 5.1

Connection id:		2
Current database:	
Current user:		root@localhost
SSL:			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server:			[B]MariaDB[/B]
Server version:		[B]5.5.31-MariaDB MariaDB Server[/B]
Protocol version:	10
Connection:		Localhost via UNIX socket
Server characterset:	latin1
Db     characterset:	latin1
Client characterset:	utf8
Conn.  characterset:	utf8
UNIX socket:		/var/lib/mysql/mysql.sock
Uptime:			4 min 6 sec

Threads: 1  Questions: 182  Slow queries: 0  Opens: 9  Flush tables: 2  Open tables: 17  Queries per second avg: 0.739
--------------[/COLOR]

17. Patikriname lenteles:
MariaDB [(none)]> use wordpress;
[COLOR="DarkSlateGray"]Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [wordpress]> show tables;
+-----------------------+
| Tables_in_wordpress   |
+-----------------------+
| wp_commentmeta        |
| wp_comments           |
| wp_links              |
| wp_options            |
| wp_postmeta           |
| wp_posts              |
| wp_term_relationships |
| wp_term_taxonomy      |
| wp_terms              |
| wp_usermeta           |
| wp_users              |
+-----------------------+
11 rows in set (0.00 sec)[/COLOR]

Rezultatas. Jeigu visi duomenys yra matomi kaip priklauso - migravimas atliktas korektiškai.
Norėdami palikti komentarą, turite prisijungti arba registruokis.