问题起源:MysqL创建集群需要maria-galera版本
删除数据库,数据导出导入功能
2.1.1 删除StorOS的数据库
[root@localhost etc]# rpm -aq |grep maria
mariadb-libs-5.5.35-3.el7.x86_64
mariadb-5.5.35-3.el7.x86_64
mariadb-server-5.5.35-3.el7.x86_64
mariadb-devel-5.5.35-3.el7.x86_64
删除:
# rpm -e --nodeps mariadb-libs mariadbmariadb-server mariadb-devel
[root@localhost etc]# rpm -aq |grep maria
[root@localhost etc]#
清理文件:
# rm /usr/share/MysqL/ -rf
2.1.2 安装非galera版本的数据库
yum install mariadbmariadb-server MysqL-python
[root@localhost yum.repos.d]# rpm -aq |grepmaria
mariadb-libs-5.5.44-2.el7.centos.x86_64
mariadb-server-5.5.44-2.el7.centos.x86_64
mariadb-5.5.44-2.el7.centos.x86_64
启动:
# systemctlenable mariadb.service
# systemctl startmariadb.service
2.1.3 创建数据表
创建密码:
#MysqL_secure_installation
Root密码为1,其他全部选择Y
#MysqL -uroot -p1
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.44-MariaDB MariaDBServer
Copyright (c) 2000,2015,Oracle,MariaDBCorporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
创建数据库表:nova
MysqL -u root –p
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO'nova'@'localhost' IDENTIFIED BY '1';
GRANT ALL PRIVILEGES ON nova.* TO'nova'@'%' IDENTIFIED BY '1';
FLUSH PRIVILEGES;
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| nova |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)
这里只有nova是新增的,其他都是自带的。
在nova中创建一些表:
MariaDB [(none)]> use nova;
MariaDB [nova]> create table compute(idint(4),name char(20));
MariaDB [nova]> insert into computevalues(1,'compute1');
MariaDB [nova]> select * from compute;
+------+----------+
| id| name |
+------+----------+
|1 | compute1 |
+------+----------+
1 row in set (0.00 sec)
2.1.4 导出数据库
MysqLdump -uroot -p1 nova > nova.sql
# ls -l nova.sql
-rw-r--r-- 1 root root 1857 May 30 14:58nova.sql
2.1.6 删除非galera版本数据库
[root@localhost ~]# rpm -aq |grep maria
mariadb-libs-5.5.44-2.el7.centos.x86_64
mariadb-server-5.5.44-2.el7.centos.x86_64
mariadb-5.5.44-2.el7.centos.x86_64
# rpm -e --nodeps mariadb-libsmariadb-server mariadb
[root@localhost ~]# cd /usr
[root@localhost usr]# find ./ -name MysqL
[root@localhost usr]# cd /var/
[root@localhost var]# find ./ -name MysqL
./lib/MysqL
[root@localhost var]# rm lib/MysqL/ -rf
2.1.7 安装galera版本数据库
#yum install mariadb-galera-server galera
[root@localhost var]# rpm -aq |grep maria
mariadb-galera-common-5.5.40-3.el7.x86_64
mariadb-libs-5.5.44-2.el7.centos.x86_64
mariadb-5.5.44-2.el7.centos.x86_64
mariadb-galera-server-5.5.40-3.el7.x86_64
[root@localhost var]# rpm -aq |grep galera
mariadb-galera-common-5.5.40-3.el7.x86_64
galera-25.3.5-7.el7.x86_64
mariadb-galera-server-5.5.40-3.el7.x86_64
# systemctlenable mariadb.service
# systemctl startmariadb.service
设置密码:
#MysqL_secure_installation
Root密码为1,其他全部选择Y
2.1.8 导入数据
导入nova.sql
首先要创建nova数据库:
CREATE DATABASE nova;
GRANT ALL PRIVILEGES ON nova.* TO'nova'@'localhost' IDENTIFIED BY '1';
GRANT ALL PRIVILEGES ON nova.* TO'nova'@'%' IDENTIFIED BY '1';
FLUSH PRIVILEGES;
然后导入数据库nova:
MysqL -uroot -p1 nova < /root/nova.sql
查看:
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| MysqL |
| nova |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)
MariaDB [(none)]> use nova;
Reading table information for completion oftable and column names
You can turn off this feature to get aquicker startup with -A
Database changed
MariaDB [nova]> show tables;
+----------------+
| Tables_in_nova |
+----------------+
| compute |
+----------------+
1 row in set (0.00 sec)
MariaDB [nova]> select * from compute;
+------+----------+
| id| name |
+------+----------+
|1 | compute1 |
+------+----------+
1 row in set (0.00 sec)
OK,一切数据正常。