В свете различных произошедших событий одна из лучших баз данных — MySQL постепенно растрачивает накопленный потенциал.
Бывшие разработчики MySQL уже достаточно продолжительное время развивают проектMariaDB, призванный послужить полноценной «прозрачной» заменой MySQL, с бОлее высоким быстродействием и оптимизированностью работы.
На высоконагруженных проектах переход на MariaDB даст ощутимый прирост скорости работы с БД.
Переход достаточно прост:
1. Настраиваем репозиторий:
Импортируем gpg ключ репозитория:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 1BB943DB
Генерируем нужные ключи для файла /etc/apt/sources.list.d/mariadb.list с помощью онлайн генератора.
Заносим сгенерированные ссылки в файл /etc/apt/sources.list.d/mariadb.list
Выполняем команду
sudo nano /etc/apt/sources.list.d/mariadb.list
2. Обновляем список приложений:
sudo apt-get update
3. Устанавливаем MariaDB:
sudo apt-get install mariadb-server-5.2
apt-get install mariadb-server-5.2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libmariadbclient16 libmysqlclient16 mariadb-client-5.2
mariadb-client-core-5.2 mariadb-server-core-5.2 mysql-common
Suggested packages:
tinyca mariadb-test
The following packages will be REMOVED:
mysql-client-5.0 mysql-server-5.0
The following NEW packages will be installed:
libmariadbclient16 libmysqlclient16 mariadb-client-5.2
mariadb-client-core-5.2 mariadb-server-5.2 mariadb-server-core-5.2
The following packages will be upgraded:
mysql-common
1 upgraded, 6 newly installed, 2 to remove and 20 not upgraded.
Need to get 20.8MB of archives.
After this operation, 56.0MB disk space will be freed.
Do you want to continue [Y/n]?
Get:1 https://mirrors.supportex.net lenny/main mysql-common 5.2.9-mariadb102~lenn y [10.6kB]
Get:2 https://mirrors.supportex.net lenny/main libmysqlclient16 5.2.9-mariadb102~ lenny [4304B]
Get:3 https://mirrors.supportex.net lenny/main libmariadbclient16 5.2.9-mariadb10 2~lenny [1428kB]
Get:4 https://mirrors.supportex.net lenny/main mariadb-client-core-5.2 5.2.9-mari adb102~lenny [84.9kB]
Get:5 https://mirrors.supportex.net lenny/main mariadb-client-5.2 5.2.9-mariadb10 2~lenny [1720kB]
Get:6 https://mirrors.supportex.net lenny/main mariadb-server-core-5.2 5.2.9-mari adb102~lenny [4210kB]
Get:7 https://mirrors.supportex.net lenny/main mariadb-server-5.2 5.2.9-mariadb10 2~lenny [13.3MB]
Fetched 20.8MB in 14s (1451kB/s)
Preconfiguring packages ...
(Reading database ... 46361 files and directories currently installed.)
Removing mysql-server-5.0 ...
ok: down: mysql: 0s, normally up
Removing mysql-client-5.0 ...
Processing triggers for man-db ...
(Reading database ... 44370 files and directories currently installed.)
Preparing to replace mysql-common 5.0.51a-24+lenny5 (using .../mysql-common_5.2. 9-mariadb102~lenny_all.deb) ...
Unpacking replacement mysql-common ...
Selecting previously deselected package libmysqlclient16.
Unpacking libmysqlclient16 (from .../libmysqlclient16_5.2.9-mariadb102~lenny_i38 6.deb) ...
Selecting previously deselected package libmariadbclient16.
Unpacking libmariadbclient16 (from .../libmariadbclient16_5.2.9-mariadb102~lenny _i386.deb) ...
Selecting previously deselected package mariadb-client-core-5.2.
Unpacking mariadb-client-core-5.2 (from .../mariadb-client-core-5.2_5.2.9-mariad b102~lenny_i386.deb) ...
Selecting previously deselected package mariadb-client-5.2.
Unpacking mariadb-client-5.2 (from .../mariadb-client-5.2_5.2.9-mariadb102~lenny _i386.deb) ...
Selecting previously deselected package mariadb-server-core-5.2.
Unpacking mariadb-server-core-5.2 (from .../mariadb-server-core-5.2_5.2.9-mariad b102~lenny_i386.deb) ...
Processing triggers for man-db ...
Setting up mysql-common (5.2.9-mariadb102~lenny) ...Configuration file `/etc/mysql/my.cnf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : background this process to examine the situation
The default action is to keep your current version.
*** my.cnf (Y/I/N/O/D/Z) [default=N] ? n
Selecting previously deselected package mariadb-server-5.2.
(Reading database ... 44511 files and directories currently installed.)
Unpacking mariadb-server-5.2 (from .../mariadb-server-5.2_5.2.9-mariadb102~lenny _i386.deb) ...
ok: down: mysql: 11s, normally up
Processing triggers for man-db ...
Setting up libmysqlclient16 (5.2.9-mariadb102~lenny) ...
Setting up libmariadbclient16 (5.2.9-mariadb102~lenny) ...
Setting up mariadb-client-core-5.2 (5.2.9-mariadb102~lenny) ...
Setting up mariadb-client-5.2 (5.2.9-mariadb102~lenny) ...
Setting up mariadb-server-core-5.2 (5.2.9-mariadb102~lenny) ...
Setting up mariadb-server-5.2 (5.2.9-mariadb102~lenny) ...
Installing new version of config file /etc/mysql/debian-start ...
ok: down: mysql: 13s, normally up
update-rc.d: warning: /etc/init.d/mysql missing LSB information
update-rc.d: see <https://wiki.debian.org/LSBInitScripts>
ok: run: mysql: (pid 26873) 0s
MariaDB версий 5.1, 5.2 и 5.3 (beta) базируется на коде MySQL 5.1, но с рядом нововведений и улучшений. Link
4. Проверяем:
server:~# mysql -V
mysql Ver 14.16 Distrib 5.2.5-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
5. Настройка:
my.cnf можно взять по адресу https://pastebin.com/QG9dZm5R
Конфигурационный файл находиться в папке /etc/mysql/
Либо скопировать от сюда:
#
# MariaDB database server configuration file.
#
# =================================================================
# Base configuration courtesy of Open Query (https://openquery.com/)
# For production use, case-specific preparation is still required.
# 2009-10-07
#
# This is *not* an optimised config, merely a more sane baseline:
# - InnoDB default (e.g., ACID out-of-the-box, same as on Windows)
# - strict mode (for proper input checks, same as on Windows)
# - various other useful settings
# - make use of MariaDB/Percona/OurDelta enhancements/extensions
#
# For tuning assistance, please see https://openquery.com/services
# =================================================================
#
# You can copy this file to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# https://dev.mysql.com/doc/mysql/en/server-system-variables.html
# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain «#» chars…
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
# Default is Latin1, if you need UTF-8 set this (also in server section)
default-character-set = utf8
# Here is entries for some specific programs
# The following values assume you have at least 32M ram
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[server]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/english
skip-external-locking
#
# * Character sets
#
# Default is Latin1, if you need UTF-8 set all this (also in client section)
#
#default-character-set = utf8
#default-collation = utf8_general_ci
character_set_server = utf8
collation_server = utf8_general_ci
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
#
# * Fine Tuning
#
max_connections = 75
connect_timeout = 5
wait_timeout = 30
interactive_timeout = 120
thread_concurrency = 6
max_allowed_packet = 4M
thread_cache_size = 8
sort_buffer_size = 1M
bulk_insert_buffer_size = 512K
tmp_table_size = 512K
max_heap_table_size = 2M
thread_stack = 192K
#
# * MyISAM
#
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched. On error, make copy and try a repair.
myisam_recover = BACKUP
key_buffer_size = 32M
table_open_cache = 128
myisam_sort_buffer_size = 1M
concurrent_insert = 2
read_buffer_size = 256K
read_rnd_buffer_size = 256K
#
# * Query Cache Configuration
#
# Cache only tiny result sets, so we can fit more in the query cache.
query_cache_limit = 256K
query_cache_size = 8M
# for more write intensive setups, set to DEMAND or OFF
#query_cache_type = DEMAND
#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file = /var/log/mysql/mysql.log
#general_log = 1
#
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
#
# we do want to know about network errors and such
log_warnings = 2
#
# Enable the slow query log to see queries with especially long duration
slow_query_log = 1 #[={0|1}]
slow_query_log_file = /var/log/mysql/mariadb-slow.log
long_query_time = 5
#log_slow_rate_limit = 1000
log_slow_verbosity = query_plan
#log-queries-not-using-indexes
#log_slow_admin_statements
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
# other settings you may need to change.
#server-id = 1
#report_host = master1
#auto_increment_increment = 2
#auto_increment_offset = 1
#log_bin = /var/log/mysql/mariadb-bin
#log_bin_index = /var/log/mysql/mariadb-bin.index
# not fab for performance, but safer
#sync_binlog = 1
expire_logs_days = 10
max_binlog_size = 100M
# slaves
#relay_log = /var/log/mysql/relay-bin
#relay_log_index = /var/log/mysql/relay-bin.index
#relay_log_info_file = /var/log/mysql/relay-bin.info
#log_slave_updates
#read_only
#
# If applications support it, this stricter sql_mode prevents some
# mistakes like inserting invalid dates etc.
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
#
# * InnoDB
#
## InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
## Read the manual for more InnoDB related options. There are many!
#default_storage_engine = InnoDB
## you can’t just change log file size, requires special procedure
##innodb_log_file_size = 50M
#innodb_buffer_pool_size = 256M
#innodb_log_buffer_size = 8M
#innodb_file_per_table = 1
#innodb_open_files = 400
#innodb_io_capacity = 400
#innodb_flush_method = O_DIRECT
skip-innodb
skip-federated
skip-archive
skip-pbxt
skip-blackhole
skip-csv
skip-mrg_myisam
skip-pbxt_statistics
skip-innodb_rseg
skip-innodb_buffer_pool_pages
skip-innodb_buffer_pool_pages_index
skip-innodb_buffer_pool_pages_blob
skip-innodb_trx
skip-innodb_locks
skip-innodb_lock_waits
skip-innodb_cmp
skip-innodb_cmp_reset
skip-innodb_cmpmem
skip-innodb_cmpmem_reset
skip-innodb_table_stats
skip-innodb_index_stats
skip-innodb_sys_tables
skip-innodb_sys_indexes
skip-innodb_sys_stats
skip-xtradb_admin_command
skip-xtradb_enhancements
#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates I recommend the OpenSSL GUI «tinyca».
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
[mysqldump]
quick
quote-names
max_allowed_packet = 16M
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
[isamchk]
key_buffer = 16M
#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with ‘.cnf’, otherwise they’ll be ignored.
#
!includedir /etc/mysql/conf.d/
6. Проверка на включение не нужных плагинов:
Нашел на этом сайте https://answers.launchpad.net/maria/+question/162766
В консоли вводим команду
mysql -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 30
Server version: 5.2.7-MariaDB-
[…]
MariaDB [(none)]> show plugins;
+——
| Name | Status | Type | Library | License |
+——
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_
| mysql_old_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| ARCHIVE | DISABLED | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | DISABLED | STORAGE ENGINE | NULL | GPL |
| CSV | DISABLED | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| Maria | ACTIVE | DAEMON | NULL | GPL |
| Aria | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | DISABLED | STORAGE ENGINE | NULL | GPL |
| PBXT | DISABLED | STORAGE ENGINE | NULL | GPL |
| PBXT_STATISTICS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| InnoDB | DISABLED | STORAGE ENGINE | NULL | GPL |
| INNODB_RSEG | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_
| INNODB_
| INNODB_
| INNODB_TRX | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCK_WAITS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_RESET | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM_RESET | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_TABLE_STATS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_INDEX_STATS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_
| INNODB_SYS_TABLES | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_INDEXES | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_STATS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_ENHANCEMENTS | DISABLED | INFORMATION SCHEMA | NULL | GPL |
+——
34 rows in set (0.00 sec)
Опять же, я не уверен, что мой метод определения памяти является точной, поэтому я отправил другие показатели здесь. Я также не уверен, что отключение всех MariaDB плагинов является то, что я должен делать, но это только кажется, что MariaDB расслоений и активизирует намного больше по умолчанию (поэтому я попытался отключить вещи мне не нужно для некоторых RAM сбережения , если это то, что он делает). Это не кажется, что работает «перепрыгнуть-арии» в файле конфигурации, поэтому я не могу отключить двигатель Ария хранения.
Я надеюсь, что представленная здесь информация является полезной. Пожалуйста, не стесняйтесь обратиться за любой дополнительной информации или указать на недостатки в своей методологии и т.д.
Готово. На всякий случай, в используемых CMS чистим кеш, и запускаем проверку целостности БД.
На своем хостинге я получил 10% прироста на чтение.
Источник: https://kb.askmonty.org/en/installing-mariadb-deb-files
Просмотров: 4099
Здравствуйте, а почему MariaDB нет в пакетной базе Debian и Ubuntu (или в Ubuntu Software Center)? Почему на официальном сайте MariaDB нет сборки под Ubuntu? Появятся ли эти пакеты когда-нибудь в указанных дистрибутивах и как можно помочь, чтобы они там появились? Хотелось бы пользоваться этой СУБД из коробки. Это поможет распространению MariaDB, добавит легкости и просты в установку 🙂
С Уважением, Сергей.