Centos7 YUM安装MariaDB 10.0
安装步骤(新装)
-
配置添加yum源文件
vim /etc/yum.repos.d/mariadb.repoMariaDB 10.0 CentOS repository list - created 2016-05-30 02:16 UTC# http://downloads.mariadb.org/mariadb/repositories/
[mariadb] name = MariaDB #baseurl = http://yum.mariadb.org/10.0/centos7-amd64 baseurl = http://archive.mariadb.org/mariadb-10.0.10/yum/centos6-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck= 0
其他版本请参照官网修改版本号
-
查配置yum源对应的mariadb版本是否正确
yum makecache yum info MariaDB-server
-
安装MariaDB-server和Client
yum install MariaDB-server MariaDB-client MariaDB-devel -y 注:如果有提示和以前安装的版本冲突,您可能需要先移除以前安装的包,例如: yum remove mariadb-libs.
-
新建数据目录并创建mysql用户
mkdir -p /data/dbdata/data/ && useradd mysql -s /sbin/nologin
-
初始化数据库目录
mysql_install_db --datadir='/data/dbdata/data/'
-
修改权限并手工命令启动
chown mysql:mysl /data/dbdata/data/ -R cd '/usr' ; /usr/bin/mysqld_safe --datadir='/data/dbdata/data/' &
-
初始化数据库权限
mysql_secure_installation
安装步骤(在同一台MYSQL服务器上安装)
-
配置添加yum源文件
vim /etc/yum.repos.d/mariadb.repoMariaDB 10.0 CentOS repository list - created 2016-05-30 02:16 UTC# http://downloads.mariadb.org/mariadb/repositories/
[mariadb] name = MariaDB #baseurl = http://yum.mariadb.org/10.0/centos7-amd64 baseurl = http://archive.mariadb.org/mariadb-10.0.10/yum/centos6-amd64/ gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck= 0
其他版本请参照官网修改版本号
-
查配置yum源对应的mariadb版本是否正确
yum makecache yum info MariaDB-server
-
安装MariaDB-server和Client
yum install MariaDB-server MariaDB-client MariaDB-devel -y 注:如果有提示和以前安装的版本冲突,您可能需要先移除以前安装的包,例如: yum remove mariadb-libs.
-
新建数据目录并创建mysql用户
mkdir -p /data/dbdata/data/ && useradd mysql -s /sbin/nologin
-
初始化数据库目录
mysql_install_db --datadir='/data/dbdata/data/'
或者
mysql_install_db --defaults-file=/etc/mariadb/etc/my.cnf
6. 修改权限并手工命令启动
1chown mysql:mysl /data/dbdata/data/ -R 2cd '/usr' ; /usr/bin/mysqld_safe --datadir='/data/dbdata/data/' &
或者
mysqld_safe --defaults-file=/etc/mariadb/etc/my.cnf &
7. 初始化数据库权限
mysql_secure_installation --defaults-file=/etc/mariadb/etc/my.cnf
或者
1mysql -h 127.0.0.1 -uroot -p -P3307 2grant all privileges on *.* to 'root'@'localhost' identified by 'password'; 3grant all privileges on *.* to 'root'@'127.0.0.1' identified by 'password'; 4flush privileges ;
生产数据库配置(仅供参考)
1[mysqld] 2port = 3307 3socket = /tmp/mysql_mariadb.sock 4character-set-server = utf8 5collation-server = utf8_general_ci 6innodb_page_size=16384 7lower_case_table_names=1 8server-id=10 9innodb_buffer_pool_size=10G 10skip-name-resolve 11datadir = /data/dbdata/data/ 12relay-log = /data/dblogs/relay/relay.log 13log-error = /data/dblogs/mysqld.err 14tmpdir = /data/dbdata/tmpdir 15innodb_flush_log_at_trx_commit = 0 16sync_binlog = 0 17query_cache_type = 0 18query_cache_size = 0 19bulk_insert_buffer_size = 2G 20innodb_log_buffer_size = 256M 21innodb_log_file_size = 1G 22innodb_write_io_threads = 16 23innodb_doublewrite=0 24auto_increment_increment = 1 25auto_increment_offset = 1 26autocommit = ON 27character_set_server = utf8 28connect_timeout = 10 29default_week_format = 0 30delay_key_write = ON 31delayed_insert_limit = 100 32delayed_insert_timeout = 300 33delayed_queue_size = 1000 34div_precision_increment = 4 35event_scheduler = OFF 36group_concat_max_len = 1024 37innodb_concurrency_tickets = 5000 38innodb_large_prefix = OFF 39innodb_lock_wait_timeout = 7200 40innodb_max_dirty_pages_pct = 70 41innodb_old_blocks_pct = 37 42innodb_old_blocks_time = 1000 43innodb_purge_batch_size = 300 44innodb_read_ahead_threshold = 56 45innodb_stats_method = nulls_equal 46innodb_stats_on_metadata = OFF 47innodb_stats_sample_pages = 8 48innodb_strict_mode = OFF 49innodb_table_locks = ON 50innodb_thread_concurrency = 0 51innodb_thread_sleep_delay = 10000 52interactive_timeout = 43200 53key_cache_age_threshold = 300 54key_cache_block_size = 1024 55key_cache_division_limit = 100 56lock_wait_timeout = 7200 57log_queries_not_using_indexes = OFF 58long_query_time = 1.000000 59low_priority_updates = OFF 60max_allowed_packet = 1G 61max_binlog_size = 104857600 62max_connect_errors = 2000 63max_connections = 4096 64max_prepared_stmt_count = 16382 65myisam_sort_buffer_size = 4194304 66net_buffer_length = 16384 67net_read_timeout = 30 68net_retry_count = 10 69net_write_timeout = 300 70query_alloc_block_size = 8192 71#query_cache_limit = 1048576 72#query_cache_size = 67108864 73#query_cache_type = 0 74query_prealloc_size = 8192 75slow_launch_time = 2 76#sort_buffer_size = 6291456 77sort_buffer_size = 2M 78table_definition_cache = 400 79table_open_cache = 10240 80myisam_max_sort_file_size=10G 81myisam_sort_buffer_size=2048M 82tmp_table_size = 256M 83thread_cache_size=10000 84open_files_limit = 10240 85 86 87long_query_time = 10 88slow-query-log = on 89slow-query-log-file = /data/dblogs/slow/slow.log 90log-bin= /data/dbdata/binlog/mysql-bin 91binlog_format = mixed 92expire_logs_days = 30 93##从库设置 94#row从库复制安全,从库主键,复制速度加快 95#binlog_format=row 96#全局事物ID 便于主从搭建和访问 97#gtid-mode=on 98#是否强制GTID的一致性 99#enforce-gtid-consistency=true 100#是否记录从服务器同步数据动作 101log_slave_updates=1 102#崩溃时保证二进制和服务器安全 103#master信息的记录位置 MariaDB没有该参数 104#master-info-repository=TABLE 105#中继日志信息的记录位置 MariaDB没有该参数 106#relay-log-info-repository=TABLE 107#启用之后确保无信息丢失 108sync-master-info=1 109#设置从服务器复制线程数 MariaDB没有该参数 110#slave-parallel-workers=8 111#启用之可用于在二进制日志记录事件相关的信息,可降低故障排除的复杂度 MariaDB没有该参数 112#binlog-rows-query-log-events=1 113#设置binlog校验算法(循环冗余校验码) 114binlog-checksum=CRC32 115#设置主服务器是否校验 116master-verify-checksum=1 117#设置从服务器是否校验 118slave-sql-verify-checksum=1