2023年的mariadb 有了很多惊人的特性 ,来尝尝鲜 !(配置文件及推荐配置)
Posted 19 months ago mariadb cli linux bash docker
很久没看 mariadb 了 发现多了很多好玩的特性
就像mysql语法版本的postgresql
特性 | 名称 | 简介 |
---|---|---|
分片 | Spider | 分片用的 但是我不感兴趣 |
存储 | MyRocks | RocksDB的存储 拿来代替InnoDB !!!! |
外置数据库 | CONNECT | 类似pg!!!!! |
搜索 | Mroonga | 如果可以!拿来代替狗日的es |
图查询 | OQGRAPH | 没试过,坐等stable |
这里用的alpine (最近是越来越爱他 了 有机会替换线上的ubuntu)
apk add mariadb mariadb-client mariadb-plugin-rocksdb mysql mysql-client mariadb-openrc openrc
我这里用的是docker 如果不是docker 默认有openrc 就不需要执行
openrc
touch /run/openrc/softlevel
然后
mysql_install_db --user=mysql --datadir=/var/lib/mysql
rc-service mariadb start
mysqladmin -u root password toor
如果不想手动配置可以mariadb-secure-installation但是更推荐后面手动操作
首先是 /etc/my.cnf
# This group is read by the server
[mysqld]
bind-address=0.0.0.0
port=3306
socket=/run/mysqld/mysqld.sock
collation_server = utf8mb4_unicode_ci
character_set_server = utf8mb4
symbolic-links=0
plugin_load_add = ha_rocksdb
max_connections=100
max_heap_table_size=32M
tmp_table_size=32M
join_buffer_size=64M
max_allowed_packet=100M
innodb_file_format=Barracuda
innodb_large_prefix=1
innodb_buffer_pool_size=456M
innodb_read_io_threads=32
innodb_write_io_threads=32
innodb_buffer_pool_instances=4
innodb_io_capacity=1200
innodb_io_capacity_max=2500
log-bin = /var/lib/mysql/binlog/mariadb.log
log-bin = /var/lib/mysql/binlog/mariadb_log.index
expire-logs-days = 7
server-id = 1
binlog-format = row
max-binlog-size = 100M
[mysql]
default-character-set = utf8mb4
!includedir /etc/my.cnf.d
搞定后
rc-service mariadb restart
让root可以对外登录 线上不要这么搞
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'free' WITH GRANT OPTION;
alpine 提供的改密码方法
rc-service mysql stop
kill `cat /run/mysqld/mysqld.pid`
/usr/bin/mysqld --datadir=/var/lib/mysql --pid-file=/run/mysqld/mysqld.pid --skip-grant-tables --skip-networking &
mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';FLUSH PRIVILEGES;ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';FLUSH PRIVILEGES;set password = password('MyNewPass');"
kill `cat /run/mysqld/mysqld.pid`
rc-service mariadb restart
后面我要试试 mysql5.5做主 mariadb 10 做从 看看mariadb的伪线上性能如何 !