https://downloads.mysql.com/archives/community/
Select Operating System 选择 Source Code
Select OS version 选择 All Operating Systems
选择带有boost的版本
apt -y install make cmake gcc g++ perl bison libaio-dev libncurses5 libncurses5-dev libnuma-dev libssl-dev
这里可能需要安装低版本的openssl
1、下载源码包:
wget http://www.openssl.org/source/openssl-1.1.0g.tar.gz
2、安装到/usr/local/ssl/目录下:
tar zxvf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g
./config --prefix=/usr/local/ssl
这里可能报错:
在 Configure文件和 test/build.info这个文件
use if $^O ne "VMS", 'File::Glob' => qw/glob/;
改成
use if $^O ne "VMS", 'File::Glob' => qw/:glob/;
make -j8
make install -j8
mv -f /usr/bin/openssl /usr/bin/openssl.old
mv -f /usr/include/openssl /usr/include/openssl.old
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl #修改软链,指向新版本的openssl路径
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo "/usr/local/ssl/lib">>/etc/ld.so.conf
#添加so库的路径,添加完成之后,运行ldconfig ,将新增的so 文件缓存到/etc/ld.so.cache中;
ldconfig -v
openssl version -a #确认版本是否为1.1.0g
groupadd mysql
useradd -r -g mysql mysql
mkdir -p /mnt/install # 存放安装后的软件
mkdir -p /mnt/data # 存放数据
mkdir -p /mnt/log # 存放日志
chown -R mysql:mysql /mnt
tar -zxf mysql-boost-5.7.28.tar.gz
cmake -DMYSQL_UNIX_ADDR=/mnt/install -DMYSQL_UNIX_ADDR=/mnt/install/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/mnt/data -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=boost -DWITH_SSL=/usr/local/ssl
# cmake -DMYSQL_UNIX_ADDR=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/mnt/data -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=boost -DWITH_SSL=/usr/local/ssl
编译参数的参考文档:https://dev.mysql.com/doc/refman/5.7/en/source-configuration-options.html
make -j8
指定安装目录
vim cmake_install.cmake
修改AKE_INSTALL_PREFIX "/mnt/install"为目标目录
make install -j8
chown -R mysql:mysql /mnt
/mnt/install/bin/mysqld --initialize --user=mysql
# /usr/local/mysql/bin/mysqld --initialize --user=mysql
打印初始密码:A temporary password is generated for root@localhost: Br-)u/%:=2:9
这个密码也会写入 /root/.mysql_secret中
/mnt/install/support-files/mysql.server start # 启动后,按回车回到命令行 /usr/local/mysql/support-files/mysql.server start
/mnt/install/bin/mysql -u root -p #/usr/local/mysql/bin/mysql -u root -p
Enter Password: # 这里输入刚才生成的密码
mysql> set password for root@localhost = password('123456');
这里可能会报错mysql.server: 259: cd: can’t cd to /usr/local/mysql
解决方案:
修改 /mnt/install/support-files/mysql.server,将文件中的datadir和basedir路径配置成自定义的路径 即basedir=/mnt/install datadir=/mnt/data
/mnt/install/support-files/mysql.server stop
# /usr/local/mysql/support-files/mysql.server stop
cp /mnt/install/support-files/mysql.server /etc/init.d/mysqld # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
/etc/init.d/mysqld start # 这一步自动注册成systemd服务了,可以使用systemctl管理mysql了
chmod +x /etc/init.d/mysqld
systemctl stop mysqld
systemctl start mysqld
systemctl enable mysqld
vim /etc/profile
PATH=$PATH:/mnt/install/bin
# PATH=$PATH:/usr/local/mysql/bin
source /etc/profile
mysql -u root -p
Enter password: 123456
curl -O --location https://github.com/brianfrankcooper/YCSB/releases/download/0.17.0/ycsb-0.17.0.tar.gz
tar xfvz ycsb-0.17.0.tar.gz
cd ycsb-0.17.0
sudo apt install openjdk-8-jdk -y
我的是5.7的用的mysql-connector-java-5.1.38-bin.jar
vim ycsb-0.17.0/jdbc-binding/conf/db.properties
db.driver=com.mysql.jdbc.Driver
# jdbc.fetchsize=20
db.url=jdbc:mysql://127.0.0.1:3306/ycsb?useSSL=false
db.user=root
db.passwd=123456
sudo apt install python2
#设置软连接
ln -s /usr/bin/python2 /usr/bin/python
mysql -u root -p
CREATE DATABASE ycsb;
USE ycsb;
CREATE TABLE usertable (YCSB_KEY VARCHAR(255) PRIMARY KEY, FIELD0 TEXT, FIELD1 TEXT, FIELD2 TEXT, FIELD3 TEXT, FIELD4 TEXT, FIELD5 TEXT, FIELD6 TEXT, FIELD7 TEXT, FIELD8 TEXT, FIELD9 TEXT);
bin/ycsb load jdbc -P workloads/workloada -P ./jdbc-binding/conf/db.properties -cp ./jdbc-binding/lib/mysql-connector-java-5.1.38-bin.jar
可能会报错,jdk问题:Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate
解决办法:
cp /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/lib/security /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/lib/security.bak
vim /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.275.b01-1.el8_3.x86_64/jre/lib/security
为了方便后续测试不再重新load,可以选择将/mnt/data目录copy到其他地方做备份,
当重新测试时, 先关闭mysql
sudo systemctl stop mysqld
删除/mnt/data/
然后复制回之前的版本,并修改所属者
sudo chown -R mysql:mysql /mnt/data
然后重启mysql
sudo systemctl start mysqld
bin/ycsb run jdbc -P workloads/workloada -P ./jdbc-binding/conf/db.properties -cp ./jdbc-binding/lib/mysql-connector-java-5.1.38-bin.jar
mysql -u root -p
mysql > drop database ycsb;
mysql > create database ycsb;
mysql > USE ycsb;
mysql > CREATE TABLE usertable (YCSB_KEY VARCHAR(255) PRIMARY KEY, FIELD0 TEXT, FIELD1 TEXT, FIELD2 TEXT, FIELD3 TEXT, FIELD4 TEXT, FIELD5 TEXT, FIELD6 TEXT, FIELD7 TEXT, FIELD8 TEXT, FIELD9 TEXT);
git clone https://github.com/Percona-Lab/tpcc-mysql.git
cd tpcc-mysql/src/
sudo apt-get install libmysqlclient-dev
make
配置数据库
cd ..
mysql -u root -p
mysql > create database tpcc1000
mysql > exit
也可以运行mysqladmin来创建数据库:
mysqladmin create tpcc1000
可能的问题:sudo: mysqladmin: command not found
解决办法:
直接输入命令mysql或mysqladmin会发现提示命令不存在,这是由于系统默认会查找/usr/bin下的命令,如果这个命令不在这个目录下,当然会找不到命令,我们需要做的就是映射一个链接到/usr/bin目录下,相当于建立一个链接文件。
首先得知道mysql命令或mysqladmin命令的完整路径,比如mysql的路径是:/usr/local/mysql/bin/mysql,我们则可以这样执行命令:
ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /usr/local/mysql/bin/mysqladmin /usr/bin
当提示mysqldump: command not found时同样可以通过此方法来解决。
#设置表
mysql -u root -p tpcc1000 < create_table.sql
mysql -u root -p tpcc1000 < add_fkey_idx.sql
./tpcc_load -h 127.0.0.1 -P 3306 -d tpcc1000 -u root -p "123456" -w 10
为了方便后续测试不再重新load,可以选择将/mnt/data目录copy到其他地方做备份,
当重新测试时, 先关闭mysql
sudo systemctl stop mysqld
删除/mnt/data/
然后复制回之前的版本,并修改所属者
sudo chown -R mysql:mysql /mnt/data
然后重启mysql
sudo systemctl start mysqld
./tpcc_start -h 127.0.0.1 -P 3306 -d tpcc1000 -u root -p "123456" -w 10 -c 4 -r 10 -l 100
mysql -u root -p
mysql > drop database tpcc1000;