wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.25-73.1/binary/tarball/Percona-Server-5.6.25-rel73.1-TokuDB.Linux.x86_64.ssl101.tar.gz

 

 

wget https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-5.6.25-73.1/binary/tarball/Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101.tar.gz

 

安装前的一些准备

yum -y install libssl.so.6 numactl jemalloc compat-readline5-devel
yum install sysbench
yum -y install openssl*
 
禁用大内存页面:
#echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag
#echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled
#echo never > /sys/kernel/mm/transparent_hugepage/enabled
#echo never > /sys/kernel/mm/transparent_hugepage/defrag
 
禁用SELinux:
 
 

[root@dbtest opt]# groupadd mysql 

[root@dbtest opt]# useradd mysql -g mysql -s /sbin/nologin

[root@dbtest opt]# mkdir -p /data/mysql/log

[root@dbtest opt]# mkdir -p /data/mysql/data

[root@dbtest opt]# mkdir -p /data/mysql/tokudb_data

[root@dbtest opt]# mkdir -p /data/mysql/tokudb_log

[root@dbtest opt]# mkdir -p /data/mysql/tokudb_tmp

 

安装mysql(版本号请自行选择,需要对应修改即可)

[root@dbtest opt]# tar -zxvf Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101.tar.gz

[root@dbtest opt]# tar -zxvf Percona-Server-5.6.25-rel73.1-TokuDB.Linux.x86_64.ssl101.tar.gz

[root@dbtest opt]# mv Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101 /usr/local/mysql

[root@dbtest opt]# cd /usr/local

[root@dbtest opt]# ln -s mysql Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101

[root@dbtest opt]# cd /usr/local/mysql

[root@dbtest opt]# ln -s lib lib64

 

 

配置文件my.cnf (vim /usr/local/mysql/etc/my.cnf),具体参数根据实际情况调整

[mysqld_safe]
malloc_lib =/usr/local/mysql/lib/mysql/libjemalloc.so
#malloc_lib =/usr/local/lib/libjemalloc.so
 
[client]
port = 3306
socket = /data/mysql/log/mysql.sock
 
[mysqld]
#skip-grant-tables
wait_timeout=31536000
interactive_timeout=31536000
port = 3306
socket = /data/mysql/log/mysql.sock
explicit_defaults_for_timestamp
basedir = /usr/local/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/log/mysql.pid
user = mysql
 
#thread_handling = pool-of-threads
 
server-id = 8
performance_schema = 0
#event_scheduler = 1
log_bin_trust_function_creators=1
lower_case_table_names = 1
init-connect = 'SET NAMES utf8'
character-set-server = utf8
 
skip-name-resolve
skip-external-locking
 
#sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES
#sql_mode=STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION #haiziwang sql_mode
max_connections = 4000
max_connect_errors=10000
lower_case_table_names = 1
open_files_limit = 65535
#table_open_cache = 128
max_allowed_packet = 512M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_size = 8M
query_cache_limit = 2M
 
 
 
####binlog
log_bin=/data/mysql/log/bin
binlog_format = row
log-slave-updates
sync_binlog=1
expire_logs_days = 7
binlog_checksum = CRC32
slave_allow_batching = 1
master_verify_checksum = 1
slave_sql_verify_checksum = 1
relay_log_purge = 1
relay_log_recovery = 1
binlog_row_image=minimal
binlog_rows_query_log_events = 1
#slave_skip_errors=all,ddl_exist_errors #only slave
#slave_skip_errors=1062,1053,1146
#slave_skip_errors=1062
 
 
 
####other logs
log_error = /data/mysql/log/mysql_error.log
#slow_query_log = 1
#long_query_time = 5
#slow_query_log_file = /data/mysql3310/log/slow_sql.log
#log_slow_admin_statements
#log_queries_not_using_indexes
#log_throttle_queries_not_using_indexes = 60
#general_log = 1
#general_log_file = /data/mysql3310/log/mysql_general.log
#log_output=TABLE,FILE #Notice the disk space and mysql'db CVS table size
 
 
####innodb
#default_storage_engine = InnoDB
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 2G
#innodb_write_io_threads = 4
#innodb_read_io_threads = 4
#innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 16M
innodb_log_files_in_group = 3
innodb_log_file_size = 256M
innodb_flush_method=O_DIRECT
innodb_data_file_path = innodb_data:256M:autoextend
 
 
####tokudb
plugin_dir =/usr/local/mysql/lib/mysql/plugin/
plugin_load=ha_tokudb.so
tokudb_cache_size = 1G
tokudb_row_format = tokudb_zlib
#tokudb_fsync_log_period=1000
tokudb_commit_sync = 0
tokudb_create_index_online = 1
#tokudb_checkpointing_period = 60
tokudb_fsync_log_period = 1000
#tokudb_directio = 0
tokudb_disable_hot_alter= 0
tokudb_disable_slow_alter = 0
#tokudb_fs_reserve_percent= 10
tokudb_lock_timeout = 4000
#tokudb_killed_time = 4000
#tokudb_lock_timeout_debug = 1
tokudb_optimize_index_fraction = 1
tokudb_data_dir = /data/mysql/tokudb_data
tokudb_log_dir = /data/mysql/tokudb_log
tokudb_tmp_dir = /data/mysql/tokudb_tmp
default_storage_engine = TokuDB
 
####myisam
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 2G
myisam_repair_threads=4
myisam-recover-options
ft_min_word_len=4
ft_max_word_len=20
interactive_timeout = 28800
wait_timeout = 28800
 
 
####rep params
#auto-increment-increment = 2
#auto-increment-offset = 2
#replicate-wild-ignore-table=mysql.%
#replicate-wild-ignore-table=test.%
#replicate-wild-ignore-table=information_schema.%
#master_info_repository = TABLE
#relay_log_info_repository = TABLE
 
#gtid
#gtid_mode=on
#enforce_gtid_consistency=on
#report_host=hostname
#master-info-repository=TABLE
#relay-log-info-repository=TABLE
#report_host=test02
 
[mysqldump]
quick
max_allowed_packet = 64M
 
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
 
[mysql]
prompt=\\u@\\d \\r:\\m:\\s>
no-auto-rehash

 

[root@dbtest opt]# chmod 644 /usr/local/mysql/etc/my.cnf
 

修改MySQL路径归属

chown -R mysql.mysql /data/mysql

chown -R mysql.mysql /usr/local/mysql

 

初始化数据字典

[root@Mysql1 mysql]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --defaults-file=/usr/local/mysql/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql/data
 
Installing MySQL system tables...2017-06-14 11:55:36 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25-73.1-log) starting as process 17233 ...
OK
 
Filling help tables...2017-06-14 11:55:59 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.25-73.1-log) starting as process 17260 ...
OK
 
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
 
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h 10.27.17.67 password 'new-password'
 
Alternatively you can run:
 
/usr/local/mysql/bin/mysql_secure_installation
 
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
 
See the manual for more instructions.
 
You can start the MySQL daemon with:
 
cd . ; /usr/local/mysql/bin/mysqld_safe &
 
You can test the MySQL daemon with mysql-test-run.pl
 
cd mysql-test ; perl mysql-test-run.pl
 
Please report any problems at
 
The latest information about Percona Server is available on the web at
 
Support Percona by buying support at
 
 

[root@dbtest mysql]# cd /data/mysql/data

[root@iZm5e3840wx55hq4ajy1nkZ data]# ll
total 110604
-rw-rw---- 1 mysql mysql 12582912 Jun 14 10:38 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Jun 14 10:38 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Jun 14 10:38 ib_logfile1
drwx------ 2 mysql mysql 4096 Jun 14 10:38 mysql
drwx------ 2 mysql mysql 4096 Jun 14 10:38 performance_schema
drwx------ 2 mysql mysql 4096 Jun 14 10:38 test

 

 

启动数据库

/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &

 
[root@Mysql1 bin]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &
[1] 16337
[root@Mysql1 bin]# 170528 11:12:07 mysqld_safe Adding '/usr/local/mysql/lib/mysql/libjemalloc.so' to LD_PRELOAD for mysqld
170528 11:12:07 mysqld_safe Logging to '/data/mysql/log/mysql_error.log'.
170528 11:12:07 mysqld_safe Starting mysqld daemon with databases from /data/mysql
 
[root@Mysql1 bin]# ps -ef |grep mysql
root 16337 1051 0 11:12 pts/4 00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf
mysql 17425 16337 3 11:12 pts/4 00:00:01 /usr/local/Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101/bin/mysqld --defaults-file=/usr/local/mysql/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/mysql/plugin/ --user=mysql --log-error=/data/mysql/log/mysql_error.log --open-files-limit=65535 --pid-file=/data/mysql/mysql.pid --socket=/data/mysql/mysql.sock --port=3308
root 17531 1051 0 11:12 pts/4 00:00:00 grep mysql

 

 

连接数据库

#cp /usr/local/mysql/bin/mysql /usr/local/bin/

#mysql -uroot

 

[root@Mysql1 etc]# mysql -uroot
Warning: World-writable config file '/etc/my.cnf' is ignored
Warning: World-writable config file '/usr/local/Percona-Server-5.6.25-rel73.1-Linux.x86_64.ssl101/etc/my.cnf' is ignored
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.25-73.1-log Percona Server (GPL), Release 73.1, Revision 07b797f
 
Copyright (c) 2009-2015 Percona LLC and/or its affiliates
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
mysql>

 

检查tokuDB引擎启用状态:
# mysql> SHOW ENGINES; (查看mysql现在已经提供的存储引擎)
mysql> SHOW ENGINES;
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| Engine | Support | Comment | Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
| InnoDB | YES | Percona-XtraDB, Supports transactions, row-level locking, and foreign keys | YES | YES | YES |
| CSV | YES | CSV storage engine | NO | NO | NO |
| MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO |
| TokuDB | DEFAULT | Tokutek TokuDB Storage Engine with Fractal Tree(tm) Technology | YES | YES | YES |
| PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO |
| ARCHIVE | YES | Archive storage engine | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine | NO | NO | NO |
| FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL |
+--------------------+---------+----------------------------------------------------------------------------+--------------+------+------------+
10 rows in set (0.00 sec)
# mysql> SHOW PLUGINS; (查看mysql的存储引擎)
mysql> SHOW PLUGINS;
+-------------------------------+----------+--------------------+--------------+---------+
| Name | Status | Type | Library | License |
+-------------------------------+----------+--------------------+--------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| mysql_old_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL |
| XTRADB_READ_VIEW | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_INTERNAL_HASH_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| XTRADB_RSEG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_PER_INDEX | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CMP_PER_INDEX_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_PAGE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_PAGE_LRU | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_BUFFER_POOL_STATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_METRICS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_DEFAULT_STOPWORD | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_BEING_DELETED | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_CONFIG | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_INDEX_CACHE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_FT_INDEX_TABLE | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLESTATS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_INDEXES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_COLUMNS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FIELDS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FOREIGN | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_FOREIGN_COLS | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_TABLESPACES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_SYS_DATAFILES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| INNODB_CHANGED_PAGES | ACTIVE | INFORMATION SCHEMA | NULL | GPL |
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| TokuDB | ACTIVE | STORAGE ENGINE | ha_tokudb.so | GPL |
| TokuDB_trx | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_lock_waits | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_locks | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_file_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_info | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
| TokuDB_fractal_tree_block_map | ACTIVE | INFORMATION SCHEMA | ha_tokudb.so | GPL |
+-------------------------------+----------+--------------------+--------------+---------+
53 rows in set (0.01 sec)
# mysql> show variables like '%toku%';
mysql> show variables like '%toku%';
+---------------------------------+-------------------------+
| Variable_name | Value |
+---------------------------------+-------------------------+
| tokudb_alter_print_error | OFF |
| tokudb_analyze_delete_fraction | 1.000000 |
| tokudb_analyze_time | 5 |
| tokudb_block_size | 4194304 |
| tokudb_bulk_fetch | ON |
| tokudb_cache_size | 17179869184 |
| tokudb_check_jemalloc | 1 |
| tokudb_checkpoint_lock | OFF |
| tokudb_checkpoint_on_flush_logs | OFF |
| tokudb_checkpointing_period | 60 |
| tokudb_cleaner_iterations | 5 |
| tokudb_cleaner_period | 1 |
| tokudb_commit_sync | OFF |
| tokudb_create_index_online | ON |
| tokudb_data_dir | /data/mysql/tokudb_data |
| tokudb_debug | 0 |
| tokudb_directio | OFF |
| tokudb_disable_hot_alter | OFF |
| tokudb_disable_prefetching | OFF |
| tokudb_disable_slow_alter | OFF |
| tokudb_disable_slow_update | OFF |
| tokudb_disable_slow_upsert | OFF |
| tokudb_empty_scan | rl |
| tokudb_fanout | 16 |
| tokudb_fs_reserve_percent | 5 |
| tokudb_fsync_log_period | 1000 |
| tokudb_hide_default_row_format | ON |
| tokudb_killed_time | 4000 |
| tokudb_last_lock_timeout | |
| tokudb_load_save_space | ON |
| tokudb_loader_memory_size | 100000000 |
| tokudb_lock_timeout | 4000 |
| tokudb_lock_timeout_debug | 1 |
| tokudb_log_dir | /data/mysql/tokudb_log |
| tokudb_max_lock_memory | 2147483648 |
| tokudb_optimize_index_fraction | 1.000000 |
| tokudb_optimize_index_name | |
| tokudb_optimize_throttle | 0 |
| tokudb_pk_insert_mode | 1 |
| tokudb_prelock_empty | ON |
| tokudb_read_block_size | 65536 |
| tokudb_read_buf_size | 131072 |
| tokudb_read_status_frequency | 10000 |
| tokudb_row_format | tokudb_zlib |
| tokudb_rpl_check_readonly | ON |
| tokudb_rpl_lookup_rows | ON |
| tokudb_rpl_lookup_rows_delay | 0 |
| tokudb_rpl_unique_checks | ON |
| tokudb_rpl_unique_checks_delay | 0 |
| tokudb_support_xa | ON |
| tokudb_tmp_dir | /data/mysql/tokudb_tmp |
| tokudb_version | tokudb-7.5.8 |
| tokudb_write_status_frequency | 1000 |
+---------------------------------+-------------------------+
53 rows in set (0.01 sec)
 

 

 

设置root密码:
# mysql -uroot
# mysql> select user,host,password from mysql.user;
# mysql> set password for root@localhost=password('rootroot');
# mysql> set password for root@127.0.0.1=password('rootroot');

 

 
 
 

 

 
删除匿名用户:
# mysql> delete from mysql.user where user='';

 

 
 
创建程序用户:
#mysql> grant all on *.* to iovuser@"%" identified by "!QAZ2wsx";

 

#mysql> grant all on *.* to iovuser@"localhost" identified by "!QAZ2wsx";

 

#mysql> grant all on *.* to iovuser@"127.0.0.1" identified by "!QAZ2wsx";
#mysql> grant all on *.* to iovuser@"192.168.15.%" identified by "!QAZ2wsx";
#mysql> flush privileges;
 

grant select on *.* to 'read'@'%';

 

 

grant all on *.* to root@"%" identified by "rootroot";给root用户授权,可以在自己本地访问

 

 

 

 

raQ3Zi#d

 

posted on 2018-06-13 12:00  sy靡不有初  阅读(285)  评论(0编辑  收藏  举报