首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Percona Server 的安装及tokudb引擎的安装笔记

Percona Server 的安装及tokudb引擎的安装笔记

作者头像
保持热爱奔赴山海
发布2019-09-18 15:49:24
7670
发布2019-09-18 15:49:24
举报
文章被收录于专栏:饮水机管理员饮水机管理员

Percona Server 的安装及tokudb引擎的安装笔记

2017年7月7日

安装percona server:

yum localinstall Percona-Server-client-57-5.7.18-15.1.el6.x86_64.rpm  Percona-Server-shared-57-5.7.18-15.1.el6.x86_64.rpm Percona-Server-server-57-5.7.18-15.1.el6.x86_64.rpm  Percona-Server-tokudb-57-5.7.18-15.1.el6.x86_64.rpm

安装过程中,会自动安装jmelloc组件。

/etc/my.cnf 内容如下:

[client]

port    = 3306

socket   = /tmp/mysql.sock

[mysqld]

port    = 3306

socket   = /tmp/mysql.sock

datadir  = /var/lib/mysql

innodb_file_per_table=ON

character-set-server = utf8

server_id=1000

join_buffer_size = 256K

thread_stack = 256K

default_storage_engine = InnoDB

max_connections = 2000 

#slave-skip-errors  = 1032,1062

#性能相关调节

#跳过外部锁定,用于多进程条件下为MyISAM数据表进行锁定

skip-external-locking

sort_buffer_size = 4M

read_buffer_size = 4M

read_rnd_buffer_size = 4M

myisam_sort_buffer_size = 64M

#自适应哈希索引,在高并发复杂sql场景下有可能引发系统资源不足,大量spin waits ,lock waits 锁等待,导致崩溃

skip-innodb_adaptive_hash_index

#为所有线程打开表的数量

table_open_cache = 2048

#索引块的缓冲区大小

key_buffer_size = 128M

#MySQL查询结果缓冲区的大小

query_cache_type = OFF

query_cache_size = 0

#处理大的信息包量

max_allowed_packet = 16M

#1G=>8 2G=>16 3G=>32 >3G=>64

#缓存可重用的线程数

thread_cache_size = 64

event_scheduler = 1

long_query_time = 1

slow_query_log=1

slow_query_log_file = /var/lib/mysql/log-slow-queries.log

log-error   = /var/lib/mysql/error.log

max_binlog_size = 256m

transaction_isolation = READ-COMMITTED

#innodb_io_capacity=1000

master_info_repository = TABLE

relay_log_info_repository = TABLE

relay_log_recovery = 1 #crash safe

log-bin=mysql-bin

binlog_format=row

sync_binlog =1  

log-slave-updates

log_bin_trust_function_creators = 1

binlog_rows_query_log_events=ON

expire_logs_days = 5

auto_increment_increment=1

auto_increment_offset=1

skip-slave-start

skip-name-resolve

binlog_cache_size = 16M

binlog_stmt_cache_size=16M

########innodb settings########

innodb_buffer_pool_instances = 4  #小于逻辑CPU个数,尽可能调大一点

innodb_log_buffer_size = 16777216

innodb_read_io_threads = 4 #小于逻辑CPU个数/2,尽可能调大一点

innodb_write_io_threads=4 # <=(逻辑CPU个数 -read_io_threads)  ,尽可能调大一点

innodb_purge_threads = 2

innodb_flush_method=O_DIRECT

# Timeout

connect_timeout = 20

wait_timeout = 14400

interactive_timeout = 14400

net_write_timeout = 180

lock_wait_timeout = 120

tmp_table_size=200M

max_heap_table_size=200M

sql_mode = 'NO_ENGINE_SUBSTITUTION,NO_AUTO_CREATE_USER'

[mysqldump]

quick

max_allowed_packet = 16M

[mysql]

no-auto-rehash

# Remove the next comment character if you are not familiar with SQL

#safe-updates

prompt ='[\\u@\\h:\\d] >'

[myisamchk]

key_buffer_size = 512M

sort_buffer_size = 512M

read_buffer = 8M

write_buffer = 8M

[mysqlhotcopy]

interactive-timeout

初始化数据库:

/usr/sbin/mysqld --initialize-insecure  --basedir=/usr/sbin/ --user=mysql --datadir=/var/lib/mysql/

# 说明:使用 --initialize-insecure参数,不让mysqld初始化时候生成随机密码,保持空密码

启动数据库:

/etc/init.d/mysql start

设置数据库密码:

mysql

> set password=PASSWORD('Abcd@1234');

> flush privileges;

> exit

然后,开始安装tokudb引擎:

官方详细的安装步骤: https://www.percona.com/doc/percona-server/5.7/tokudb/tokudb_installation.html

1 禁用Transparent huge pages

cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

always代表已启用

echo never > /sys/kernel/mm/transparent_hugepage/enabled

echo never > /sys/kernel/mm/transparent_hugepage/defrag

# 将设置写入到文件,防止重启配置丢失

echo 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' >> /etc/rc.local

echo 'echo never > /sys/kernel/mm/transparent_hugepage/defrag' >> /etc/rc.local

2、安装并启用tokudb引擎:

## 可以使用INSTALL PLUGIN方法安装,也可以使用ps_tokudb_admin这个工具进行配置(推荐使用ps_tokudb_admin)

执行 ps_tokudb_admin -uroot -pAbcd@1234 --enable

会自动在 /etc/my.cnf 在加入下面的1行配置

[mysqld_safe] 

thp-setting=never

然后再执行 ps_tokudb_admin -uroot -pAbcd@1234 --enable-backup

会自动在 /etc/my.cnf 在加入下面的1行配置

[mysqld_safe] 

preload-hotbackup

这样就完成了TokuDB engine plugin和TokuBackup plugin插件的安装。

重启mysqld进程。

/etc/init.d/mysql restart 

mysql -uroot -pAbcd@1234

> show engines;

> show plugins;

> SELECT @@tokudb_version;

都可以看到tokudb启用了。

这样的话,我们重启了mysqld或者整个服务器的话,tokudb引擎也能在mysql重启时候再次自动加载。

安装好tokudb引擎后,我们还可以自定义tokudb的参数在/etc/my.cnf里面。例如下面的2行:

### tokudb settings ########

tokudb_cache_size = 5G   # 这个参数根据自己服务中可能使用到tokudb引擎的表数量来设置

tokudb_row_format=tokudb_zlib   # 设置默认tokudb行格式,有tokudb_zlib 和 tokudb_lzma

此外,还有些tokudb特有的配置参数,可以补充到/etc/my.cnf 里面,例如下面的部分配置:

#TokuDB的行模式,建议用 FAST ,如果磁盘空间很紧张,建议用 SMALL

#tokudb_default: 设置默认的压缩行为。在 TokuDB 7.1.0版本,默认使用zlib 库进行压缩,未来版本可能会改变。

#tokudb_fast: 使用quicklz 库的压缩模式。

#tokudb_small: 使用 lzma 库的压缩模式。

#tokudb_zlib: 使用 zlib 库的压缩模式,提供了中等级别的压缩比和中等级别的CPU消耗。

#tokudb_quicklz: 使用 quicklz 库的压缩模式, 提供了轻量级的压缩比和较低基本的CPU消耗。

#tokudb_lzma: 使用lzma库压缩模式,提供了高压缩比和高CPU消耗。

#tokudb_uncompressed: 不使用压缩模式。

#tokudb_row_format = tokudb_small

tokudb_row_format = tokudb_fast

tokudb_cache_size = 1G ###建议内存的一半

tokudb_commit_sync = 0

tokudb_directio = 1

tokudb_read_block_size = 128K

tokudb_read_buf_size = 128K 

optimizer_switch = 'mrr=on,mrr_cost_based=off'

tokudb-data-dir = /mydata/3306/tokudbData

tokudb-log-dir = /mydata/3306/tokudbLog  

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017-07-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档