MariaDB10.5.16安装文档-v3

 

 

 

查看CPU个数

[root@iamc-prd-dsdb ~]# cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -     

8      32     131-

[root@iamc-prd-dsdb ~]# cat /proc/cpuinfo |grep "processor"|wc -l

8

[root@iamc-prd-dsdb ~]# cat /proc/cpuinfo |grep "cores"|uniq

cpu cores       : 1

 

8个物理CPU

 

查看内存

[root@iamc-prd-dsdb ~]# cat /proc/meminfo

MemTotal:       16251604 kB

 

内存16G

 

#查看CPU

 

查看系统版本号

[root@iamc-prd-dsdb ~]# cat /etc/redhat-release

 

Red Hat Enterprise Linux Server release 7.4 (Maipo)

 

系统为Red Hat 7.4

 

[root@iamc-prd-dsdb ~]# cat /proc/version

Linux version 3.10.0-693.el7.x86_64 (mockbuild@x86-038.build.eng.bos.redhat.com) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ) #1 SMP Thu Jul 6 19:56:57 EDT 2017

 

[root@iamc-prd-dsdb ~]# uname -a

Linux iamc-prd-dsdb 3.10.0-693.el7.x86_64 #1 SMP Thu Jul 6 19:56:57 EDT 2017 x86_64 x86_64 x86_64 GNU/Linux

 

系统为64

 

查看glibc版本

[root@iamc-prd-dsdb ~]# ldd --version

ldd (GNU libc) 2.17

 

ldd (GNU libc) 2.17

Copyright (C) 2012 Free Software Foundation, Inc.

This is free software; see the source for copying conditions.  There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Written by Roland McGrath and Ulrich Drepper.

 

glibc版本为2.17

 

查看磁盘空间

[root@iamc-prd-dsdb ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/rhel-root  450G   13G  438G   3% /

devtmpfs               7.8G     0  7.8G   0% /dev

tmpfs                  7.8G     0  7.8G   0% /dev/shm

tmpfs                  7.8G   17M  7.8G   1% /run

tmpfs                  7.8G     0  7.8G   0% /sys/fs/cgroup

/dev/sda1             1014M  178M  837M  18% /boot

/dev/mapper/rhel-home   34G   33M   34G   1% /home

tmpfs                  1.6G     0  1.6G   0% /run/user/0

tmpfs                  1.6G     0  1.6G   0% /run/user/1000

 

 

 

 

 

[root@iamc-prd-dsdb ~]# df -h /tmp

Filesystem      Size  Used Avail Use% Mounted on

/dev/mapper/rhel-root  450G   13G  438G   3% /

 

创建用户及所需目录

[root@iamc-prd-dsdb ~]# groupadd  mysql

[root@iamc-prd-dsdb ~]# useradd -g mysql mysql

[root@iamc-prd-dsdb ~]# mkdir -p /data/mariadb

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/data

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/log/iblog

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/log/binlog

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/log/relaylog

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/run

[root@iamc-prd-dsdb ~]# mkdir -p /data/my3306/tmp

[root@iamc-prd-dsdb ~]# chown -R mysql:mysql /data/my3306

[root@iamc-prd-dsdb ~]# chmod -R 755 /data/my3306

 

解包介质

[root@iamc-prd-dsdb ~]# cd /download

[root@iamc-prd-dsdb ~]# tar -xvf mariadb-10.5.16-linux-x86_64.tar.gz   

[root@iamc-prd-dsdb ~]# mv mariadb-10.5.16-linux-x86_64  /data/mariadb 

 

 

创建配置文件 my.cnf

[client]

port    = 3306

socket  =/data/my3306/run/mysql.sock

 

[mysql]

prompt="\u@ \R:\m:\s [\d]> "

no-auto-rehash

socket  =/data/my3306/run/mysql.sock

 

[mysqld]

user    = mysql

port    = 3306

basedir = /data/mariadb/

datadir = /data/my3306/data/

socket  =/data/my3306/run/mysql.sock

pid_file=/data/my3306/run/mysqld.pid 

character-set-server = utf8mb4

skip_name_resolve = 1

 

default_time_zone = "+8:00"

 

open_files_limit = 65535

back_log = 1024

max_connections = 8000

max_connect_errors = 1000000

table_open_cache = 1024

table_definition_cache = 1024

table_open_cache_instances = 64

thread_stack = 512K

external-locking = FALSE

max_allowed_packet = 32M

sort_buffer_size = 16M

join_buffer_size = 16M

thread_cache_size = 768

interactive_timeout = 600

wait_timeout = 600

tmp_table_size = 96M

max_heap_table_size = 96M

slow_query_log = 1

#log_timestamps = SYSTEM

slow-query-log-file = /data/my3306/log/mysql-slow.log

log-error = /data/my3306/log/alert_3306.log

long_query_time = 0.1

log_queries_not_using_indexes =1

log_throttle_queries_not_using_indexes = 60

min_examined_row_limit = 100

log_slow_admin_statements = 1

log_slow_slave_statements = 1

server-id = 195

log-bin=/data/my3306/log/binlog/log-bin

sync_binlog = 1

binlog_cache_size = 4M

max_binlog_cache_size = 2G

max_binlog_size = 1G

 

expire_logs_days = 7

 

master_info_repository = TABLE

relay_log_info_repository = TABLE

#gtid_mode = on

#enforce_gtid_consistency = 1

log_slave_updates

slave-rows-search-algorithms = 'INDEX_SCAN,HASH_SCAN'

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 = 16M

bulk_insert_buffer_size = 64M

myisam_sort_buffer_size = 128M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

lock_wait_timeout = 3600

explicit_defaults_for_timestamp = 1

innodb_thread_concurrency = 0

 

transaction_isolation = REPEATABLE-READ

innodb_buffer_pool_size = 875M

#innodb_buffer_pool_instances = 4

innodb_buffer_pool_load_at_startup = 1

innodb_buffer_pool_dump_at_shutdown = 1

innodb_data_home_dir = /data/my3306/data/

innodb_data_file_path = ibdata1:12M;ibdata2:12M:autoextend:max:500M

#innodb_data_file_path = ibdata1:1G:autoextend

innodb_flush_log_at_trx_commit = 1

innodb_log_buffer_size = 32M

innodb_log_file_size =12M

#innodb_log_files_in_group = 3

innodb_max_undo_log_size = 4G

innodb_undo_directory = /data/my3306/data/undolog

innodb_undo_tablespaces = 95

 

# ???????IOPS??????

# ?????SSD???,????? 10000 - 20000

# ????PCIe SSD???,????????,?? 50000 - 80000

innodb_io_capacity = 4000

innodb_io_capacity_max = 8000

innodb_flush_sync = 0

innodb_flush_neighbors = 0

innodb_write_io_threads = 8

innodb_read_io_threads = 8

innodb_purge_threads = 4

#innodb_page_cleaners = 4

innodb_open_files = 65535

innodb_max_dirty_pages_pct = 50

innodb_flush_method = O_DIRECT

innodb_lru_scan_depth = 4000

innodb_checksum_algorithm = crc32

innodb_lock_wait_timeout = 10

innodb_rollback_on_timeout = 1

innodb_print_all_deadlocks = 1

innodb_file_per_table = 1

innodb_online_alter_log_max_size = 4G

innodb_stats_on_metadata = 0

innodb_undo_log_truncate = 1

 

#??:MySQL 8.0.16

#internal_tmp_disk_storage_engine = InnoDB

 

# some var for MySQL 8

#log_error_verbosity = 3

#innodb_print_ddl_logs = 1

#binlog_expire_logs_seconds = 604800

#innodb_dedicated_server = 0

 

innodb_status_file = 1

#??: ?? innodb_status_output & innodb_status_output_locks

innodb_status_output = 0

innodb_status_output_locks = 1

 

innodb_sort_buffer_size = 67108864

innodb_autoinc_lock_mode = 1

 

#performance_schema

performance_schema = 1

#performance_schema_instrument = '%memory%=on'

#performance_schema_instrument = '%lock%=on'

 

#innodb monitor

innodb_monitor_enable="module_innodb"

innodb_monitor_enable="module_server"

innodb_monitor_enable="module_dml"

innodb_monitor_enable="module_ddl"

innodb_monitor_enable="module_trx"

innodb_monitor_enable="module_os"

innodb_monitor_enable="module_purge"

innodb_monitor_enable="module_log"

innodb_monitor_enable="module_lock"

innodb_monitor_enable="module_buffer"

innodb_monitor_enable="module_index"

innodb_monitor_enable="module_ibuf_system"

innodb_monitor_enable="module_buffer_page"

innodb_monitor_enable="module_adaptive_hash"

 

[mysqldump]

quick

max_allowed_packet = 32M

 

初始化mariadb

#进入mariadb可执行文件的父目录执行初始化操作

[root@iamc-prd-dsdb ~]# cd /data/mariadb

[root@iamc-prd-dsdb mariadb]# scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/data/mariadb --datadir=/data/my3306/data --user=mysql

 

 

以下为输出

Installing MariaDB/MySQL system tables in '/data/my3306' ...

OK

 

To start mysqld at boot time you have to copy

support-files/mysql.server to the right place for your system

 

 

Two all-privilege accounts were created.

One is root@localhost, it has no password, but you need to

be system 'root' user to connect. Use, for example, sudo mysql

The second is mysql@localhost, it has no password either, but

you need to be the system 'mysql' user to connect.

After connecting you can set the password, if you would need to be

able to connect as any of these users with a password and without sudo

 

See the MariaDB Knowledgebase at https://mariadb.com/kb

 

You can start the MariaDB daemon with:

cd '/data/mariadb' ; /data/mariadb/bin/mysqld_safe --datadir='/data/my3306'

 

You can test the MariaDB daemon with mysql-test-run.pl

cd '/data/mariadb/mysql-test' ; perl mysql-test-run.pl

 

Please report any problems at https://mariadb.org/jira

 

The latest information about MariaDB is available at https://mariadb.org/.

 

Consider joining MariaDB's strong and vibrant community:

https://mariadb.org/get-involved/

修改mariadb的启动文件

[root@iamc-prd-dsdb etc]# cd /data/mariadb/

[root@iamc-prd-dsdb etc]# cp support-files/mysql.server /etc/init.d/mysql

[root@iamc-prd-dsdb etc]# vi  /etc/init.d/mysql

 

修改如下的basedir  datadir  mariadbd_pid_file_path

 

basedir=/data/mariadb/

datadir=/data/my3306/data/

mariadbd_pid_file_path=/data/my3306/run/mysqld.pid

 

修改系统环境变量

[root@iamc-prd-dsdb etc]# echo "PATH=/data/mariadb/bin:\$PATH:/sbin" >> /etc/profile

 

[root@iamc-prd-dsdb etc]# source /etc/profile

 

此处/data/mariadb /为mariadb的安装路径,注意修改

 

启动mariadb 

[root@ iamc-prd-dsdb mariadb]# /etc/init.d/mysql status

 SUCCESS! MariaDB running (10332)

[root@ iamc-prd-dsdb mariadb]# /etc/init.d/mysql stop

Stopping mysql (via systemctl):  [  OK  ]

[root@ iamc-prd-dsdb mariadb]# /etc/init.d/mysql status

 ERROR! MariaDB is not running

[root@ iamc-prd-dsdb mariadb]# /etc/init.d/mysql start

Starting mysql (via systemctl):  [  OK  ]

[root@ iamc-prd-dsdb mariadb]# /etc/init.d/mysql status

 SUCCESS! MariaDB running (12485)

 

数据库创建业务用户

[root@iamc-prd-dsdb init.d]# /data/mariadb/bin/mysqld_safe --datadir='/data/my3306/data'

 

[root@iyoume07 mariadb]# mariadb  -uroot -p

Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 5

Server version: 10.5.16-MariaDB-log 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)]> Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 7

Server version: 10.5.16-MariaDB-log 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)]>

 

mysql> create user 'allianz'@'%' identified by 'aIAMDwixpTk8e';

Query OK, 0 rows affected (0.02 sec)

 

mysql> grant all on *.* to allianz@'%' ;

Query OK, 0 rows affected (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

 

allianz用户测试登录数据库

[root@iamc-prd-dsdb init.d]# mariadb  -uallianz -p

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 11

Server version: 10.5.16-MariaDB-log 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)]>

 

 

 

创建时间:2022-09-16 14:48
浏览量:0