本文共 6072 字,大约阅读时间需要 20 分钟。
命令:
wget -c https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7.23-23/binary/tarball/Percona-Server-5.7.23-23-Linux.x86_64.ssl102.tar.g
yum -y updateyum install libatomic.x86_64 atomic.x86_64
1) 检查GLIBCXX版本
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXXGLIBCXX_3.4GLIBCXX_3.4.1GLIBCXX_3.4.2GLIBCXX_3.4.3GLIBCXX_3.4.4GLIBCXX_3.4.5GLIBCXX_3.4.6GLIBCXX_3.4.7GLIBCXX_3.4.8GLIBCXX_3.4.9GLIBCXX_3.4.10GLIBCXX_3.4.11GLIBCXX_3.4.12GLIBCXX_3.4.13GLIBCXX_3.4.14GLIBCXX_3.4.15GLIBCXX_3.4.16GLIBCXX_3.4.17GLIBCXX_3.4.18GLIBCXX_3.4.19GLIBCXX_DEBUG_MESSAGE_LENGTH
2) 如果检索出来GLIBCXX版本低于3.4.21,则添加更新源
vim /etc/yum.repos.d/FedoraRepo.repo[warning:fedora]name=fedoramirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-23&arch=$basearchenabled=1gpgcheck=1gpgkey=https://getfedora.org/static/34EC9CBA.txt
3) 更新GCC
yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel vim-common
4) 检查GLIBCXX版本
$ strings /usr/lib64/libstdc++.so.6 | grep LIBCXXGLIBCXX_3.4GLIBCXX_3.4.1GLIBCXX_3.4.2GLIBCXX_3.4.3GLIBCXX_3.4.4GLIBCXX_3.4.5GLIBCXX_3.4.6GLIBCXX_3.4.7GLIBCXX_3.4.8GLIBCXX_3.4.9GLIBCXX_3.4.10GLIBCXX_3.4.11GLIBCXX_3.4.12GLIBCXX_3.4.13GLIBCXX_3.4.14GLIBCXX_3.4.15GLIBCXX_3.4.16GLIBCXX_3.4.17GLIBCXX_3.4.18GLIBCXX_3.4.19GLIBCXX_3.4.20GLIBCXX_3.4.21GLIBCXX_DEBUG_MESSAGE_LENGTH
5) 删除刚才添加的源
rm /etc/yum.repos.d/FedoraRepo.repo
wget https://www.openssl.org/source/openssl-1.1.1.tar.gztar zcvf openssl-1.1.1.tar.gzcd openssl-1.1.1./configmakemake installln -s /usr/local/lib64/libssl.so.1.1 /usr/lib64/libssl.so.1.1ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib64/libcrypto.so.1.1
groupadd mysqluseradd -g mysql -d /usr/local/mysql -s /sbin/nologin -M mysql
tar zxvf Percona-Server-5.7.23-23-Linux.x86_64.ssl102.tar.gzmv Percona-Server-5.7.23-23-Linux.x86_64.ssl102 /opt
1) 创建符号链接
ln -s /opt/Percona-Server-5.7.23-23-Linux.x86_64.ssl102 /usr/local/mysql
2) 修改系统环境变量
vim /etc/profile
在文件末尾添加export PATH="/usr/local/mysql/bin/:$PATH"
3) 使环境变量生效
source /etc/profile
cd /usr/local/mysql./bin/mysqld --defaults-file=/etc/my.cnf --initialize
cp /opt/Percona-Server-5.7.23-23-Linux.x86_64.ssl102/support-files/mysql.server /etc/init.d/mysqld
把文件中的Percona-Server-5.7.23-23-Linux.x86_64.ssl102都替换成mysql
/etc/init.d/mysqld restart
1) 获取初始密码
grep "temporary password" /data/mysql/mysql3306/data/error.log
2) 修改root密码
cd /usr/local/mysql./bin/mysql_secure_installation
echo never > /sys/kernel/mm/transparent_hugepage/defragecho never > /sys/kernel/mm/transparent_hugepage/enabled
如果不修改,使用tokudb引擎的时候,会在error.log中报错
Transparent huge pages are enabled, according to /sys/kernel/mm/redhat_transparent_hugepage/enabledTransparent huge pages are enabled, according to /sys/kernel/mm/transparent_hugepage/enabled
ps_tokudb_admin --enable -uroot -p
1) 拷贝MySQL版本对应的jemalloc
cp /usr/local/mysql/lib/mysql/libjemalloc.so* /usr/lib64/
2) 在/etc/my.cnf中添加malloc库使用jemalloc
[mysqld_safe]thp-setting=nevermalloc-lib=/usr/lib64/libjemalloc.so
3) 配置tokudb参数
plugin-dir = /usr/local/mysql/lib/mysql/pluginplugin-load=ha_tokudb.sotokudb_row_format = tokudb_zlibtokudb_cache_size = 1Gtokudb_commit_sync = 1tokudb_directio = 1tokudb_read_block_size = 128Ktokudb_read_buf_size = 128Ktokudb_support_xa = 1tokudb_directio = 0#tokudb_pk_insert_mode = ONtokudb_hide_default_row_format = ONtokudb_lock_timeout_debug = 1
/etc/init.d/mysqld restart
登陆云服务器,使用wget下载数据备份文件,命令格式如下:
wget -c ' <数据备份文件内网下载地址> ' -O (大写的O) <自定义文件名> .tar.gz 自定义文件名> 数据备份文件内网下载地址>
/etc/init.d/mysqld stop
如: rm -r /data/mysql/var/3306/
tar -izxvf <数据备份文件名> .tar.gz -C /data/mysql/var/3306/ 数据备份文件名>
gzip -d -c <数据备份文件名> .xb.gz | xbstream -x -v -C /data/mysql/var/3306/ 数据备份文件名>
git clone https://github.com/xelabs/tokudb-xtrabackup.git
1) 安装依赖
yum install cmake gcc gcc-c++ libaio libaio-devel automake autoconf bison libtool ncurses-devel libgcrypt-devel libev-devel libcurl-devel vim-common
2) 编译安装tokudb-xtrabackup
cmake .\ -DBUILD_CONFIG=xtrabackup_release\ -DWITH_BOOST=extra/boost/boost_1_59_0.tar.gz\ -DWITH_MAN_PAGES=OFF\ -DCMAKE_INSTALL_PREFIX=/usr/local/xtrabackup_xelabs/makemake install
/usr/local/xtrabackup_xelabs/bin/innobackupex --defaults-file=/data/mysql/var/3306/backup-my.cnf --apply-log /data/mysql/var/3306/
/etc/init.d/mysqld start
mysql -uroot -h127.0.0.1 -p
如果登陆失败,需按照如下步骤进行:1) 在MySQL配置文件中添加skip-grant-tables,然后重启MySQL2) 使用mysql -uroot -p -h127.0.0.13) 修改root密码: update mysql.user set authentication_string=password('密码') where user='root' and Host = '127.0.0.1';4) 删除RDS多余的表: drop table rds_extra;5) 更新权限: flush privileges;
由于备份文件是RDS MySQL5.6,而自建数据库是MySQL5.7,所以需要使用更新命令更新一下数据库表,命令如下
mysql_upgrade -u root -h 127.0.0.1 -p --force
/etc/init.d/mysqld start
1) 查看triggers
use 数据库;show triggers;
2) 删除trigger
drop trigger trigger_名字
cat /data/mysql/var/3306/xtrabackup_info # 获取GTID of the last change值
1) 重置复制
stop slave;reset slave all;reset master;
2) 设置复制
set global gtid_purged='gtid值';CHANGE MASTER TO MASTER_HOST='xxxxx.mysql.rds.aliyuncs.com', MASTER_USER='dt_repl', MASTER_PASSWORD='xxxxx', MASTER_PORT=3306, MASTER_AUTO_POSITION=1, MASTER_CONNECT_RETRY=10;
3) 启动复制
start slave;
4) 查看复制状态
show slave status\G;
转载地址:http://sytla.baihongyu.com/