一、简介

  二进制安装方式,升级版本相对简单可靠。本案例基于二进制安装方式进行升级演示。

  先完整的安装mariadb10.4版本,然后在此基础上升级到10.5版本。

二、Centos7.6最小化安装依赖包

yum install -y net-tools
yum install -y wget

#切换aliyun的yum源
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak 
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 
# 重建源数据缓存 
yum clean all
yum makecache 

yum -y install vim-enhanced wget net-tools telnet vim lrzsz ntp
yum -y install lshw pciutils gdisk system-storage-manager 
yum -y install bash-completion zip unzip bzip2 tree tmpwatch pinfo man-pages
yum -y install nano vim-enhanced tmux screen
yum -y install net-tools psmisclsof sysstat
yum -y install yum-plugin-security yum-utils createrepo
yum -y install get wget curl eliks lynx lftp mailx mutt reync 
yum -y install libaio make cmake gcc-c++ gcc zib zlib-devel open openssl-devel pcre pcre-devel

三、创建用户

useradd -M -r -s  /bin/nologin mysql
echo "mysql"|passwd --stdin mysql

四、下载安装

wget https://downloads.mariadb.org/interstitial/mariadb-10.4.11/bintar-linux-systemd-x86_64/mariadb-10.4.11-linux-systemd-x86_64.tar.gz/from/http%3A//mariadb.mirror.nucleus.be/
tar -zxvf mariadb-10.4.11-linux-systemd-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-10.4.11-linux-systemd-x86_64/ mysql
echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh

五、配置文件

cat >/etc/my.cnf<<"EOF"
[client]
port    = 3306
socket    = /data/mysql/data/mysql.sock
default-character-set=utf8mb4

[mysql]
prompt="\u@MariaDB0 \R:\m:\s [\d]> "
no-auto-rehash
default-character-set=utf8mb4

[mysqld]
user    = mysql
port    = 3306
extra_port=13306
socket  = /data/mysql/data/mysql.sock
basedir= /usr/local/mysql
datadir= /data/mysql/data
log-error=/data/mysql/logs/mysql-error.log
pid-file=/data/mysql/data/mariadb.pid
character-set-server = utf8mb4
skip_name_resolve = 1
open_files_limit = 65535
back_log = 1024
max_connections = 512
max_connect_errors = 1000000
table_open_cache = 1024
table_definition_cache = 1024
thread_stack = 512K
external-locking = FALSE
max_allowed_packet = 32M
sort_buffer_size = 4M
join_buffer_size = 4M
thread_cache_size = 768
query_cache_size = 0
query_cache_type = 0
interactive_timeout = 600
wait_timeout = 600
tmp_table_size = 32M
max_heap_table_size = 32M
slow_query_log = 1
slow_query_log_file = /data/mysql/logs/slow.log
long_query_time = 0.1
log_queries_not_using_indexes =1
min_examined_row_limit = 100
log_slow_admin_statements = 1
log_slow_slave_statements = 1
server-id = 3306
log-bin = /data/mysql/logs/mybinlog
sync_binlog = 1
binlog_cache_size = 4M
max_binlog_cache_size = 2G
max_binlog_size = 1G
expire_logs_days = 30
log_slave_updates
binlog_format = row
binlog_checksum = 1
relay_log_recovery = 1
relay-log-purge = 1
key_buffer_size = 32M
read_buffer_size = 8M
read_rnd_buffer_size = 4M
bulk_insert_buffer_size = 64M
myisam_sort_buffer_size = 128M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
lock_wait_timeout = 3600
innodb_thread_concurrency = 0
innodb_sync_spin_loops = 100
innodb_spin_wait_delay = 30

transaction_isolation = REPEATABLE-READ
#innodb_additional_mem_pool_size = 16M
innodb_buffer_pool_size = 5734M
innodb_buffer_pool_instances = 8
innodb_data_file_path = ibdata1:1G:autoextend
innodb_flush_log_at_trx_commit = 1
innodb_log_buffer_size = 32M
innodb_log_file_size = 2G
innodb_log_files_in_group = 2

# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 8000
innodb_write_io_threads = 8
innodb_read_io_threads = 8
innodb_purge_threads = 1
innodb_open_files = 65535
innodb_max_dirty_pages_pct = 50
innodb_flush_method = O_DIRECT
#innodb_checksums = 1
#innodb_file_format = Barracuda
#innodb_file_format_max = Barracuda
innodb_lock_wait_timeout = 10
innodb_rollback_on_timeout = 1
innodb_print_all_deadlocks = 1
innodb_file_per_table = 1
innodb_stats_on_metadata = 0
symbolic-links=0
innodb_status_file = 1

#performance_schema
performance_schema = 1

# 字符集设定utf8mb4
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
init-connect='SET NAMES utf8mb4'

# 优化
optimizer_switch = "mrr=on,mrr_cost_based=on,mrr_sort_keys=on"
deadlock_search_depth_short = 3 
deadlock_search_depth_long = 10 
deadlock_timeout_long = 10000000 
deadlock_timeout_short = 5000
slave-parallel-threads=8

# gtid
gtid_strict_mode=1
wsrep_gtid_mode=1

[mysqld_safe]
nice=-19
open-files-limit=65535

[mysqldump]
quick
max_allowed_packet = 64M

EOF

SERVIER_ID=`date +%S`
sed -i "s/server-id = 3306/server-id = 3306"${SERVIER_ID}"/" /etc/my.cnf
my.cnf

相关文章: