반응형
OS 환경 : CentOS 7
DB 환경 : MariaDB 10.2
As-Is : MariaDB 10.2
To-Be : MariaDB 10.6
MariaDB 10.2 설치
저장소 변경
# 저장소 주소 등록
[root@host01 ~]# vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.2 CentOS repository list - created 2022-07-08 00:24 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://ftp.harukasan.org/mariadb/yum/10.2/centos7-amd64
gpgkey=https://ftp.harukasan.org/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
https://mariadb.org/download/?t=repo-config&d=CentOS+7+%28x86_64%29&v=10.2&r_m=harukasan
위 주소에서 해당 되는 저장소 가져와서 변경할 것
MariaDB 설치
# MariaDB 10.2 설치
[root@host01 ~]# yum install -y MariaDB-server MariaDB-client
my.cnf 파일 수정
[root@host01 ~]# vi /etc/my.cnf.d/server.cnf
[mysqld]
character-set-server=utf8mb3
MariaDB 서비스 시작
[root@host01 ~]# systemctl start mariadb
MariaDB 접속 후 테스트 용 데이터 생성
[root@host01 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.2.39-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
MariaDB [(none)]> create database testdb;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> use testdb
Database changed
MariaDB [testdb]> create table test(no int);
Query OK, 0 rows affected (0.00 sec)
MariaDB [testdb]> insert into test values(1);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> insert into test values(2);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> insert into test values(3);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> insert into test values(10);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> insert into test values(100);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> insert into test values(1000);
Query OK, 1 row affected (0.00 sec)
MariaDB [testdb]> commit;
Query OK, 0 rows affected (0.00 sec)
MariaDB [testdb]> select * from test;
+------+
| no |
+------+
| 1 |
| 2 |
| 3 |
| 10 |
| 100 |
| 1000 |
+------+
6 rows in set (0.00 sec)
MariaDB 업그레이드 (MariaDB 10.2 -> MariaDB 10.6)
기존 MariaDB 버전 확인
[root@host01 ~]# mysql -V
mysql Ver 15.1 Distrib 10.2.39-MariaDB, for Linux (x86_64) using readline 5.1
[root@host01 ~]#
DB 백업
# 작업을 하기전엔 항상 백업을 습관화 할것
[root@host01 ~]# mysqldump -uroot -p testdb > testdb.sql
Enter password:
[root@host01 ~]# ls
testdb.sql
- # 10.6 버전 설치 후 10.2 DB의 data를 가져와서 Upgrade를 진행하는 방식도 있지만 필자는 기존 DB 삭제 후 진행
기존 DB 삭제
[root@host01 ~]# yum remove -y MariaDB*
저장소 변경
# 저장소 주소 변경(MariaDB 10.6)
[root@host01 ~]# vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.6 CentOS repository list - created 2022-07-08 01:37 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
baseurl = https://ftp.harukasan.org/mariadb/yum/10.6/centos7-amd64
gpgkey=https://ftp.harukasan.org/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
MariaDB 설치
# MariaDB 10.6 설치
[root@host01 ~]# yum install -y MariaDB-server MariaDB-client
MariaDB 서비스 시작
[root@host01 ~]# systemctl start mariadb
MariaDB 업그레이드
[root@host01 ~]# mysql_upgrade -uroot -p
Enter password:
Phase 1/7: Checking and upgrading mysql database
Processing databases
mysql
mysql.column_stats OK
mysql.columns_priv OK
mysql.db OK
mysql.event OK
mysql.func OK
mysql.gtid_slave_pos OK
mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
mysql.plugin OK
mysql.proc OK
mysql.procs_priv OK
mysql.proxies_priv OK
mysql.roles_mapping OK
mysql.servers OK
mysql.table_stats OK
mysql.tables_priv OK
mysql.time_zone OK
mysql.time_zone_leap_second OK
mysql.time_zone_name OK
mysql.time_zone_transition OK
mysql.time_zone_transition_type OK
mysql.user OK
Phase 2/7: Installing used storage engines... Skipped
Phase 3/7: Fixing views
Phase 4/7: Running 'mysql_fix_privilege_tables'
Phase 5/7: Fixing table and database names
Phase 6/7: Checking and upgrading tables
Processing databases
information_schema
performance_schema
sys
sys.sys_config OK
testdb
testdb.test OK
Phase 7/7: Running 'FLUSH PRIVILEGES'
OK
# 생략 (버전이 업그레이드가 안될 시)
더보기
# 아래 리스트 조회 후 MariaDB-common 및 MariaDB-shared, 등..
아직 버전이 기존이면 따로 업그레이드 해줘야함
[root@host01 ~]# yum list | grep MariaDB*
[root@host01 ~]# yum upgrade MariaDB
MariaDB 업그레이드 후 확인
[root@host01 ~]# mysql -V
mysql Ver 15.1 Distrib 10.6.3-MariaDB, for Linux (x86_64) using readline 5.1
[root@host01 ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 18
Server version: 10.6.3-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [testdb]> select version();
+----------------+
| version() |
+----------------+
| 10.6.3-MariaDB |
+----------------+
1 row in set (0.000 sec)
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| testdb |
+--------------------+
5 rows in set (0.001 sec)
MariaDB [(none)]> use testdb
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 [testdb]> show tables;
+------------------+
| Tables_in_testdb |
+------------------+
| test |
+------------------+
1 row in set (0.000 sec)
MariaDB [testdb]> select * from test;
+------+
| no |
+------+
| 1 |
| 2 |
| 3 |
| 10 |
| 100 |
| 1000 |
+------+
6 rows in set (0.001 sec)
반응형
'MySQL' 카테고리의 다른 글
| [MariaDB] 기본 디렉토리(datadir) 변경 가이드 (0) | 2022.11.24 |
|---|---|
| [MariaDB] CentOS 7 에 MariaDB 10.6 설치 가이드 (0) | 2022.11.24 |
| [MariaDB] MariaDB 10.2 에서 MariaDB 10.6으로 바이너리 업그레이드 (tar.gz) (0) | 2022.07.11 |
| [MariaDB] CentOS 7 에 MariaDB 10.2 바이너리 설치 가이드 (tar.gz) (0) | 2022.07.08 |
| MySQL MHA(Master High Availability) 설치 (0) | 2021.09.06 |