• percona 5.7 + tokudb


    percona 5.7 + tokudb

    Percona + TokuDB 部署

    # 参考资料
    https://www.kancloud.cn/devops-centos/centos-linux-devops/395664

    1、安装依赖包
    yum -y install jemalloc-devel.x86_64 make gcc-c++ cmake bison-devel ncurses-devel  readline-devel  libaio-devel perl libaio wget lrzsz vim libnuma* bzip2 xz

    2、修改系统参数限制
    cat >> /etc/security/limits.conf <<"EOF"
    #
    ###custom
    #
    *           soft   nofile       20480
    *           hard   nofile       65535
    *           soft   nproc        20480
    *           hard   nproc        65535
    EOF

    cat >>/etc/sysctl.conf <<"EOF"
    # kernel_flag
    net.ipv4.ip_forward = 0
    net.ipv4.conf.default.rp_filter = 1
    net.ipv4.conf.default.accept_source_route = 0
    kernel.sysrq = 0
    kernel.core_uses_pid = 1
    net.ipv4.tcp_syncookies = 1
    kernel.msgmnb = 65536
    kernel.msgmax = 65536
    kernel.shmmax = 68719476736
    kernel.shmall = 4294967296
    net.ipv4.tcp_max_tw_buckets = 6000
    net.ipv4.tcp_sack = 1
    net.ipv4.tcp_window_scaling = 1
    net.ipv4.tcp_rmem = 4096 87380 4194304
    net.ipv4.tcp_wmem = 4096 16384 4194304
    net.core.wmem_default = 8388608
    net.core.rmem_default = 8388608
    net.core.rmem_max = 16777216
    net.core.wmem_max = 16777216
    net.core.netdev_max_backlog = 262144
    net.core.somaxconn = 262144
    net.ipv4.tcp_max_orphans = 3276800
    net.ipv4.tcp_max_syn_backlog = 262144
    net.ipv4.tcp_timestamps = 0
    net.ipv4.tcp_synack_retries = 1
    net.ipv4.tcp_syn_retries = 1
    net.ipv4.tcp_tw_recycle = 1
    net.ipv4.tcp_tw_reuse = 1
    net.ipv4.tcp_mem = 94500000 915000000 927000000
    net.ipv4.tcp_fin_timeout = 1
    net.ipv4.tcp_keepalive_time = 1200
    net.ipv4.ip_local_port_range = 1024 65535
    #net.ipv4.icmp_echo_ignore_all = 1  
    #禁ping,如果有nagios监控,这步可省去

    # 以下参数是对iptables防火墙的优化,防火墙不开,会有提示,可以忽略不理。
    #net.nf_conntrack_max=25000000
    #net.netfilter.nf_conntrack_tcp_timeout_established=180
    #net.netfilter.nf_conntrack_tcp_timeout_time_wait=120
    #net.netfilter.nf_conntrack_tcp_timeout_close_wait=60
    #net.netfilter.nf_conntrack_tcp_timeout_fin_wait=120
    vm.swappiness=0

    sysctl -p >/dev/null

    if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
        echo never > /sys/kernel/mm/transparent_hugepage/enabled
    fi
    if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
        echo never > /sys/kernel/mm/transparent_hugepage/defrag
    fi



    2、下载软件
    cd /opt/
    wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.26-29/binary/tarball/Percona-Server-5.7.26-29-Linux.x86_64.ssl101.tar.gz


    注意:此时不添加TokuDB配置,默认没有启用引擎

    3、创建用户
    groupadd mysql
    useradd -g mysql mysql -d /home/mysql -s /sbin/nologin


    mkdir -p /data/mysql3306
    cd /opt/
    tar -zxf Percona-Server-5.7.26-29-Linux.x86_64.ssl101.tar.gz
    mv Percona-Server-5.7.26-29-Linux.x86_64.ssl101 /usr/local/
    cd /usr/local/ && ln -s Percona-Server-5.7.26-29-Linux.x86_64.ssl101 mysql
    #编辑/etc/my.cnf,配置文件见结尾附件
    cd /usr/local/mysql/bin/ && ./mysqld --initialize-insecure --user=mysql
    cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
    /etc/init.d/mysqld start
    ln -s /tmp/mysql3306.sock /tmp/mysql.sock
    ln -s /usr/local/mysql/bin/* /usr/bin/

    # 启动成功后, 在/etc/my.cnf中 增加TokuDB配置文件
    [mysqld]
    # TokuDB settings #
    skip-host-cache
    tokudb_data_dir=/data/mysql3306
    tokudb_log_dir=/data/mysql3306
    tokudb_row_format=tokudb_fast
    tokudb_cache_size = 2G
    tokudb_commit_sync = 0
    tokudb_directio = 1
    tokudb_read_block_size = 128K
    tokudb_read_buf_size = 1M
    tokudb_commit_sync=OFF
    tokudb_fsync_log_period=1000

    [mysqld_safe]
    thp-setting=never
    malloc-lib= /usr/lib64/libjemalloc.so

    # 安装配置tukudb, 过程会检查THP,Selinux,jemalloc
    /usr/local/mysql/bin/ps-admin --enable -uroot -p -S /tmp/mysql3306.sock
    [root@localhost][(none)]> use dbtest;
    Database changed
    [root@localhost][dbtest]>  SELECT @@tokudb_version;
    +------------------+
    | @@tokudb_version |
    +------------------+
    | 5.7.26-29        |
    +------------------+
    1 row in set (0.00 sec)

    [root@localhost][dbtest]>

    [root@localhost][dbtest]> show engines;
    +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    | Engine             | Support | Comment                                                                    | Transactions | XA   | Savepoints |
    +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    | PERFORMANCE_SCHEMA | YES     | Performance Schema                                                         | NO           | NO   | NO         |
    | CSV                | YES     | CSV storage engine                                                         | NO           | NO   | NO         |
    | MEMORY             | YES     | Hash based, stored in memory, useful for temporary tables                  | NO           | NO   | NO         |
    | BLACKHOLE          | YES     | /dev/null storage engine (anything you write to it disappears)             | NO           | NO   | NO         |
    | MRG_MYISAM         | YES     | Collection of identical MyISAM tables                                      | NO           | NO   | NO         |
    | TokuDB             | YES     | Percona TokuDB Storage Engine with Fractal Tree(tm) Technology             | YES          | YES  | YES        |
    | MyISAM             | YES     | MyISAM storage engine                                                      | NO           | NO   | NO         |
    | ARCHIVE            | YES     | Archive storage engine                                                     | NO           | NO   | NO         |
    | InnoDB             | DEFAULT | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES          | YES  | YES        |
    | FEDERATED          | NO      | Federated MySQL storage engine                                             | NULL         | NULL | NULL       |
    +--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
    10 rows in set (0.00 sec)

    # 测试
    create table t_tokudb (id bigint not null auto_increment primary key,strs varchar(256)) engine=tokudb default charset utf8mb4;
    [root@localhost][dbtest]>  create table t_tokudb (id bigint not null auto_increment primary key,strs varchar(256)) engine=tokudb default charset utf8mb4;
    Query OK, 0 rows affected (0.11 sec)

    [root@localhost][dbtest]> show create table t_tokudbG;
    *************************** 1. row ***************************
           Table: t_tokudb
    Create Table: CREATE TABLE `t_tokudb` (
      `id` bigint(20) NOT NULL AUTO_INCREMENT,
      `strs` varchar(256) DEFAULT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=TokuDB DEFAULT CHARSET=utf8mb4
    1 row in set (0.38 sec)

    ERROR:
    No query specified

    [root@localhost][dbtest]>


    附录:
    cat >/etc/my.cnf<<"EOF"
    [mysql]
    prompt = [\u@\h][\d]>\_

    [mysqld]
    # base dir
    basedir  = /usr/local/mysql/
    socket = /tmp/mysql3306.sock
    datadir = /data/mysql3306
    pid_file  = /data/mysql3306/mysql3306.pid
    innodb_undo_directory = /data/mysql3306/undolog/

    ## basic settings #
    user = mysql
    port = 3306
    extra_port = 83306
    autocommit = 1
    character_set_server=utf8mb4
    explicit_defaults_for_timestamp = 1
    max_allowed_packet = 16777216

    # connection #
    interactive_timeout = 30
    wait_timeout = 30
    lock_wait_timeout = 5
    skip_name_resolve = 1
    max_connections = 1024

    # session memory settings #
    read_buffer_size = 8M
    read_rnd_buffer_size = 16M
    sort_buffer_size = 32M
    tmp_table_size = 16M
    join_buffer_size = 32M
    thread_cache_size = 64

    ## log settings #
    log_error = error.log
    slow_query_log = 1
    slow_query_log_file = slow.log
    log_queries_not_using_indexes = 1
    log_slow_admin_statements = 1
    log_slow_slave_statements = 1
    log_throttle_queries_not_using_indexes = 10
    expire_logs_days = 90
    long_query_time = 2
    min_examined_row_limit = 100
    binlog-rows-query-log-events = 1
    log-bin-trust-function-creators = 1
    log-slave-updates = 1
    log-bin=mysql-bin
    #general_log=on
    general_log_file=/data/mysql3306/general_log

    ## innodb settings #
    innodb_page_size = 16384
    innodb_buffer_pool_size = 1G
    innodb_buffer_pool_instances = 1
    innodb_buffer_pool_load_at_startup = 1
    innodb_buffer_pool_dump_at_shutdown = 1
    innodb_flush_method = O_DIRECT
    innodb_log_file_size = 536870912
    innodb_log_files_in_group = 2
    innodb_log_buffer_size = 16777216
    innodb_purge_threads = 1
    innodb_sort_buffer_size = 33554432
    innodb_write_io_threads = 2
    innodb_read_io_threads = 2
    innodb_file_per_table = 1

    # replication settings #
    master_info_repository = TABLE
    relay_log_info_repository = TABLE
    sync_binlog = 1
    binlog_format = ROW
    server-id=237
    EOF


    create user 'admin'@'%' identified by 'adminpwd';
    grant all on  *.* to 'admin'@'%' with grant option;
    mysql -h 192.168.142.132 -P 3306 -uadmin -p'adminpwd'
    mysql -h 192.168.142.132 -P 83306 -uadmin -p'adminpwd'

  • 相关阅读:
    Luogu3227 HNOI2013切糕
    Luogu1646 happiness
    Luogu5038 SCOI2012奇怪的游戏
    Luogu3324 星际战争
    Luogu2472 SCOI2007蜥蜴
    NOI Online#3 解题报告
    Luogu6478 游戏
    1,[VS入门教程] 使用Visual Studio写c语言 入门与技巧精品文~~~~下载安装篇
    Windows开机自动登陆 开/关:登录需按Ctrl+Alt+del的功能
    官方入门教程和文档 | Visual Studio
  • 原文地址:https://www.cnblogs.com/bjx2020/p/11157700.html
Copyright © 2020-2023  润新知