1.卸载系统自带库
rpm -qa | egrep "mysql|mariadb" yum remove mysql* yum remove mariadb-libs-*
|
2.修改文件句柄
vim /etc/security/limits.conf # 修改 * soft nofile 65535 * hard nofile 65535
|
3.添加用户
useradd -r -s /usr/sbin/nologin mysql
|
4.创建数据目录
mkdir -p /home/mysql_data chown -R mysql:mysql /home/mysql_data
|
5.安装依赖包
yum install -y jemalloc perl-Data-Dumper perl-Test-Harness perl-Test-Simple openssl098e
|
5.1 下载二进制通用包
percona-Server-5.6.31-77.0-r5c1061c-el7-x86_64-bundle.tar
percona地址
5.2 percona yum源安装
yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
6.解压压缩包
tar xf Percona-Server-5.6.31-rel77.0-Linux.x86_64.ssl101.tar.gz -C /opt/ ln -sv /opt/Percona-Server-5.6.31-rel77.0-Linux.x86_64.ssl101 /opt/mysql chown -R mysql:mysql /opt/Percona-Server* /opt/mysql
|
7. 配置my.cnf
cat >> /etc/my.cnf << EOF # --------------------------- Start ----------------------- #my.cnf [client] port = 3306 socket = /tmp/mysql.sock
[mysql] prompt="\u@\h \D [\d] \n-->" # pager="less -i -n -S" # tee=/home/mysql_data/query.log # no-auto-rehash # 不使用自动补全 auto-rehash
[mysqld] user = mysql basedir = /opt/mysql datadir = /home/mysql_data port = 3306 socket = /tmp/mysql.sock # bind_address = 0.0.0.0
# 线程池 thread_handling=pool-of-threads thread_pool_size=50 # timeout interactive_timeout = 3000 wait_timeout = 3000
# character set character-set-server = utf8
open_files_limit = 65535 max_connections = 1000 max_connect_errors = 100000
#logs log-output=file slow_query_log = 1 slow_query_log_file = /home/mysql_data/slow.log log-error = /home/mysql_data/error.log log_warnings = 2 pid-file = /home/mysql_data/mysql.pid long_query_time = 1 #log-slow-admin-statements = 1 #log-queries-not-using-indexes = 1 log-slow-slave-statements = 1
# binlog binlog_format = mixed server-id = 1 log-bin = mybinlog binlog_cache_size = 4M max_binlog_size = 512M innodb_log_files_in_group = 2 max_binlog_cache_size = 512M sync_binlog = 1 expire_logs_days = 10 skip_name_resolve = 1 # for 5.6 explicit_defaults_for_timestamp = 1
# buffers & cache table_open_cache = 2048 table_definition_cache = 2048 table_open_cache = 2048 max_heap_table_size = 96M sort_buffer_size = 2M join_buffer_size = 2M thread_cache_size = 256 query_cache_size = 0 query_cache_type = 0 query_cache_limit = 256K query_cache_min_res_unit = 512 thread_stack = 192K tmp_table_size = 96M key_buffer_size = 8M read_buffer_size = 2M read_rnd_buffer_size = 16M bulk_insert_buffer_size = 32M
# myisam myisam_sort_buffer_size = 128M myisam_max_sort_file_size = 1G myisam_repair_threads = 1
# innodb # 注意修改 buffer pool大小 innodb_buffer_pool_size = 1G innodb_buffer_pool_instances = 1 innodb_data_file_path = ibdata1:1G:autoextend innodb_flush_log_at_trx_commit = 1 innodb_log_buffer_size = 64M innodb_log_file_size = 256M innodb_max_dirty_pages_pct = 50 innodb_file_per_table = 1 innodb_rollback_on_timeout innodb_status_file = 1 innodb_io_capacity = 2000 transaction_isolation = READ-COMMITTED innodb_flush_method = O_DIRECT # --------------------------- End ----------------------- EOF
|
8.初始化percona server
/opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/home/mysql_data --defaults-file=/etc/my.cnf
|
9.配置启动脚本
cp /opt/mysql/support-files/mysql.server /etc/init.d/mysqld
vim /etc/init.d/mysqld # 修改 46 47 行 basedir=/opt/mysql datadir=/home/mysql_data
chmod +x /etc/init.d/mysqld chkconfig --add mysqld chkconfig mysqld on
|
10.配置环境变量
vim /etc/profile.d/mysql.sh export PATH=/opt/mysql/bin:$PATH
source /etc/profile.d/mysql.sh # 导出头文件 cat >> /etc/ld.so.conf.d/mysql.conf <<EOF /opt/mysql/lib EOF
ldconfig
|
11.启动percona server
chown -R mysql:mysql /opt/mysql /home/mysql_data /opt/Percona-Server* /etc/init.d/mysqld start # 启动数据库 /etc/init.d/mysqld stop # 停止数据库
|