FEMU测试指南

  1. 需要注意,这个文档是针对旧版femu的测试文档,因此很多功能可能不适用;

  2. femu官方GitHub clone了master分支之后,执行如下指令进行版本回退:

git checkout ba56426057f57f7eab839e860c7672d5289e25c5

femu运行步骤

  1. 首先进入服务器,在build-femu目录下运行

     sudo ./femu-compile.sh

    完成程序的编译。本步骤在每次修改代码后都要执行。

  2. 运行femu虚拟机

     ./run-blackbox.sh
  3. 显示f2fs文件系统的状态

     sudo cat /sys/kernel/debug/f2fs/status

如何在一个SSD设备上挂载两个分区

Step 1.使用fdisk指令查看硬盘名

以8GB的vssd为例,首先执行sudo fdisk -l查看硬件设备,输出如下:

Disk /dev/nvme0n1: 8 GiB, 8589934592 bytes, 2097152 sectors

可以看到有一个8GB的盘,设备名为/dev/nvme0n1

Step 2.操作该盘,实现分区操作

# 根据刚刚获取的硬盘名操作,需要root权限
sudo fdisk /dev/nvme0n1

# 输入m查看各种指令操作
m

# 新建分区
n

# 设置为主分区
p

之后根据提示设置分区大小,即可。最后输入w保存并退出

ext4文件系统挂载

  1. 脚本如下:

     #!/bin/sh
     sudo mkfs.ext4 -t ext4 /dev/nvme0n1
     sudo mount -t ext4 -o discard /dev/nvme0n1 /media/ext4
     sudo chmod 777 -R /media/ext4
  2. 其中设备号/dev/nvme0n1以及目录/media/ext4都是根据实际情况可以调整的。

  3. 记得不要丢掉discard选项,否则ssd不能得知fs对文件的删除操作,而只能将所有的页都看作有效页,从而造成闪存页分配失败。

使用GDB调试femu

  1. 首先进入B408服务器,进入“~/Desktop/NEW/femu/build-femu”目录下,执行:

     sudo gdb ./x86_64-softmmu/qemu-system-x86_64
  2. 在进入gdb程序以后,输入以下命令设置参数:

     set args -name "FEMU-blackbox-SSD" -enable-kvm -cpu host -smp 4 -m 4G -device virtio-scsi-pci,id=scsi0 -device scsi-hd,drive=hd0 -drive file=~/images/u14s.qcow2,if=none,aio=native,cache=none,format=qcow2,id=hd0 -drive file=~/images/vssd1.raw,if=none,aio=threads,format=raw,id=id0 -device nvme,femu_mode=1,drive=id0,serial=serial0,id=nvme0 -net user,hostfwd=tcp::8080-:22 -net nic,model=virtio -nographic -qmp unix:./qmp-sock,server,nowait

    注意,有三个地方需要根据具体配置修改

    1. 系统镜像文件的路径 "file=~/images/u14s.qcow2"

    2. 固态盘镜像的路径 "file=~/images/vssd1.raw"

    3. tcp端口号 "tcp::8080-:22"

  3. 输入 “run” 开始运行

  4. 运行中断后输入 “continue”(这一步可能要重复十几次)

  5. 虚拟机在gdb中运行起来了。新开一个终端,测试步骤和正常情况下一样。

  6. 发生段错误之后,gdb会报出错误位置。 输入"where"可以查看错误发生的函数调用栈。

修改femu中测试盘的大小

下面以8GB为例进行说明: 1. 首先使用如下指令制作简单镜像:

    qemu-img create -f raw XXX.raw 16G
其中`XXX.raw`是生成的镜像名称,可以根据需求灵活更改。
  1. ../build-femu/路径下,修改run-blackbox.sh脚本文件中的NVMEIMGF以及NVMEIMGSZ两个参数。

     NVMEIMGF=$IMGDIR/xxx.raw
     NVMEIMGSZ=8G
  2. 修改../build-femu/路径下的vssd1.conf文件,可以通过修改BLOCK_NB这个参数实现。这个参数为16时代表1GB。线性关系。

Ubuntu 18.04下安装MySQL数据库

  1. 直接采用命令行安装,以5.7版本为例

     sudo apt-get install mysql-server-5.7 mysql-client-5.7
  2. 在安装过程中可能跳出图形界面,需要输入root用户的密码,直接输入然后确认即可。

Ubuntu 18.04下修改MySQL数据库的存储路径

此处以修改到/media/ext4路径下为例

  1. 创建目标文件夹

     sudo mkdir /media/ext4/mysql
  2. 把默认安装的MySQL数据库从/var/lib/mysql复制到所创建的文件夹,并设置权限。

     sudo su
     cp -R /var/lib/mysql/* /media/ext4/mysql
     exit
     sudo chown -R mysql:mysql /media/ext4/mysql
  3. 停止mysql服务

     sudo service mysql stop
  4. 修改/etc/mysql/mysql.conf.d/mysqld.cnf文件

     datadir = /media/ext4/mysql
  5. 修改启动文件'/etc/apparmor.d/usr.sbin.mysqld'

     /var/lib/mysql/ r
     /var/lib/mysql/** rwk

    修改为

     /media/ext4/mysql/ r
     /media/ext4/mysql/** rwk
  6. 重启MySQL

     sudo /etc/init.d/apparmor restart
     sudo /etc/init.d/mysql restart
  7. 登录进入mysql中以后,执行如下指令看是否修改成功

     show variables like '%dir%';

另附一个很全面的教程

使用TPCC-Mysql进行MySQL压力测试

  1. 考虑到我们的测试盘每次都是格式化了的,因此在正式开始测试前,我们可能还需要执行创建文件夹、复制数据、重启MySQL服务等步骤。

     sudo su
     cp -R /var/lib/mysql/* /media/ext4/mysql
     exit
     sudo chown -R mysql:mysql /media/ext4/mysql
     sudo service mysql stop
     sudo /etc/init.d/apparmor restart
     sudo /etc/init.d/mysql restart
  2. 从GitHub上下载别人开源的tpcc-mysql代码,并完成编译(整个femu一共只需要执行一次,重启不需要执行)

     git clone https://github.com/Percona-Lab/tpcc-mysql.git
     cd tpcc-mysql/src
     make
  3. 进入到clone下来的tpcc-mysql目录(~/wangshuai/tpcc/mysql)下,依次执行如下指令,完成建库、建表、加载索引

     mysql -uroot -p -e  "CREATE DATABASE TPCC DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
     mysql -uroot -p TPCC <./create_table.sql
     mysql -uroot -p TPCC <./add_fkey_idx.sql
  4. 然后依次构建数据、开始测试

     ./tpcc_load -h 127.0.0.1 -P 3306 -d TPCC -u root -p 123456 -w 100
     ./tpcc_start -h 127.0.0.1 -P 3306 -d TPCC  -u root -p 123456 -w 100 -c 10 -r 600 -l 36000

    其中各参数的含义如下:

    选项

    意义

    -w

    指定仓库数量

    -c

    指定并发连接数

    -r

    指定开始测试前进行warmup的时间,进行预热后,测试效果更好(单位:秒)

    -l

    指定测试持续时间(单位:秒)

    -i

    指定生成报告间隔时长

    -f

    指定生成的报告文件名

图形化TPCC的屏幕输出

  1. 首先以管道的形式将TPCC屏幕输出输出到文件A中。

  2. 使用如下脚本提取数据

     ./tpcc_analyse.sh A > B;

    其中tpcc_analyse.sh如下:

     #!/bin/bash
     ### goto user homedir and remove previous file
     rm -f '$2'
     gnuplot << EOP
    
     ### set data source file
     datafile = '$1'
    
     ### set graph type and size
     set terminal jpeg size 640,480
    
     ### set titles
     set grid x y
     set xlabel "Time (sec)"
     set ylabel "Transactions"
    
     ### set output filename
     set output '$2'
    
     ### build graph
     # plot datafile with lines
     plot datafile using 1:2 title "1 head" with lines,\
     datafile using 3:4 title "4 heads" with lines axes x1y1
    
     EOP
  3. 如果有B和B1两个数据文件(即测试了两次,可以使用paste命令将两次的数据合并)

     paste B B1 > C
  4. 使用如下脚本根据数据文件绘图。

     ./tpcc_graph.sh C 1.jpg

    其中,tpcc_graph.sh内容如下:

     #!/bin/bash
     ### goto user homedir and remove previous file
     rm -f '$2'
     gnuplot << EOP
    
     ### set data source file
     datafile = '$1'
    
     ### set graph type and size
     set terminal jpeg size 1920,1080
    
     ### set titles
     set grid x y
     set xlabel "Time (sec)"
     set ylabel "Transactions"
    
     ### set output filename
     set output '$2'
    
     ### build graph
     # plot datafile with lines
     plot datafile using 1:2 title "1 head" with lines,\
     datafile using 3:4 title "4 heads" with lines axes x1y1
    
     EOP

使用blktrace、blkparse收集分析IO特征

  1. 使用blktrace收集块设备的trace文件,以设备/dev/nvme0n1,输出文件名设置为trace_xxx,收集时间3600秒为例。

     sudo blktrace -d /dev/nvme0n1 -o trace_xxx -w 3600
  2. 运行结束后会生成相应的trace文件,格式为trace_xxx.blktrace.n,接下来执行blkparse来生成二进制文件。

     blkparse -i trace_xxx -d trace_xxx.bin
  3. (version 1)使用周游学长的脚本生成(time, lpn) pair。其中,输入输出的文件名需要根据情况进行修改。

     # iotrace file: time(ms) start_address(4KB) length(4KB) R(0)/W(1)
    
     blktrace_file = "C:\\zy-documents\\trace\\vps26107\\0.trace"
     iotrace_file = "C:\\zy-documents\\trace\\vps26107\\vps107_0.iotrace"
    
     blktrace = open(blktrace_file,'r')
     iotrace  = open(iotrace_file,'w')
    
     sec_per_page = 8 # 4KB = 512B * 8
    
     print("begin")
    
     max_lpn = 0
    
     for line in blktrace:
         xy = line.split()
    
         if xy[0] == 'CPU0':
             break
    
         if xy[5] != 'Q':  # or 'D'
             continue
    
         time = float(xy[3]) # s
         #time = time * 1000  # ms
    
         if xy[6] == 'R':
             rw_flag = 0
         elif xy[6] == 'W':
             rw_flag = 1
         else:
             continue
    
         start_sec  = int(xy[7])
         length_sec = int(xy[9])
    
         start_lpn   = int(start_sec / sec_per_page)
         end_lpn     = int((start_sec + length_sec - 1) / sec_per_page)
         length_page = end_lpn - start_lpn + 1
    
         if max_lpn < end_lpn:
             max_lpn = end_lpn
    
         '''
         iotrace.write(str(time) + ' ' + str(start_lpn) + ' ' + \
                             str(length_page) + ' ' + str(rw_flag) + '\n')
         '''
         for i in range(length_page):
             iotrace.write(str(time) + ' ' + str(start_lpn + i) + '\n')
    
     blktrace.close()
     iotrace.close()
    
     print("max lpn: %d, max capacity: %d GB" % (max_lpn, (max_lpn*4/(1024*1024))))
     print("end")
  4. (verison 2)生成二进制文件以后,使用btt分析。

     btt -i bin_mysql_fileserver -B time r_w
  5. (verison 2)在步骤3.(version 2)中生成文件每行有三个参数,分别是时间、起始块号和终止块号。可以选择把后两个参数形成的区间给拆分成很多点。

      #include <stdio.h>
      #include <stdlib.h>
      #include <assert.h>
    
      int main(int argc, char const *argv[])
      {
          if(argc!=3)
          {
              printf("argc!=3\n");
          }
          FILE *fin = fopen(argv[1], "rb");
          FILE *fout = fopen(argv[2], "wb");
          assert(fin!=NULL);
          assert(fout!=NULL);
    
          float time;
          long long a, b;
    
          while(fscanf(fin, "%f %lld %lld", &time, &a, &b)!=EOF)
          {
              while(a<=b)
              {
                  fprintf(fout, "%f %lld\n", time, a);
                  a += 1;
              }
          }
    
          fclose(fin);
          fclose(fout);
    
          return 0;
      }
  6. (version3)吴大佬

     sudo blkparse -i fileserver -f "%5T.%9t %S %n %d\n" -a complete -o fileserver.ascii
  7. 最后使用python脚本,根据(time, LPN) pair作图。

     import matplotlib.pyplot as plt
    
     with open('output', 'rb') as f:
         lines = f.readlines()
    
     X = []
     Y = []
    
     for line in lines:
         line = line.strip()
         temp = line.split()
         if len(temp)==2:
             X.append(float(temp[0]))
             Y.append(int(temp[1]))
    
     fig = plt.figure()
     ax = fig.add_subplot(1,1,1)
     ax.scatter(X, Y, s=1)
    
     ax.set_title('filebench_mysql_r_w')
     ax.set_xlabel('Time')
     ax.set_ylabel('Block')
     plt.show()

统计blkparse输出中各个操作的出现次数

inputfile = "temp"
fin = open(inputfile, "r")

statistic = {};

print("begin")

for line in fin:
    xy = line.split()
    if xy[0] == 'CPU0':
        break
    if xy[5] != 'Q':
        continue
    if xy[6] in statistic:
        statistic[xy[6]] += 1
    else
        statistic[xy[6]] = 1

print(statistic)

fin.close()
print("end")

使用iozone进行磁盘性能测试

  1. 在Ubuntu 18.04下iozone可以直接使用apt安装

     sudo apt-get install iozone3
  2. iozone的各种参数含义(转自简书)

    ``` -a 用来使用全自动模式。生成包括所有测试操作的报告,使用的块 大小从4k到16M,文件大小从64k到512M。

    -A 这种版本的自动模式提供更加全面的测试但是消耗更多时间。参数–a在文件不小于 32MB时将自动停止使用低于64K的块 大小测试。这节省了许多时间。而参数–A 则告诉Iozone你不介意等待,即使在文件非常大时也希望进行小块 的测试。 注意: 不推荐在Iozone3.61版中使用这个参数。使用–az –i 0 –i 1替代。

    -b filename Iozone输出结果时将创建一个兼容Excel的二进制格式的文件。

    -B 使用mmap()文件。这将使用mmap()接口来创建并访问所有测试用的临时文件。一 些应用程序倾向于将文件当作内存的一块来看待。这些应用程序对文件执行mmap() 调用,然后就可以以读写内存的方式访问那个块来完成文件I/O。

    -c 计算时间时将close()包括进来。This is useful only if you suspect that close() is broken in the operating system currently under test. 对于NFS版本3测试而言这将会 很有用,同时它也能帮助我们识别nfs3_commit 是否正常工作。

    -C 显示吞吐量测试中每个客户传输的字节数。如果你的操作系统在文件I/O或进程管 理方面存在饥饿问题时这将派上用场。

-d #
穿过“壁垒”时微秒级的延迟。在吞吐量测试中所有线程或进程在执行测试前都必
须挂起在一道“壁垒”之前。通常来说,所有线程或进程在同一时间被释放。这个
参数允许在释放每个进程或线程之间有一定的延迟(微秒级)。Microsecond delay out of barrier.  During the throughput tests all threads or processes are
forced to a barrier before beginning the test.

-D
对mmap文件使用msync(MS_ASYNC) 。这告诉操作系统在mmap空间的所有数据
需要被异步地写到磁盘上。

-e
计算时间时将flush (fsync,fflush) 包括进来。

-E
用来进行一些扩展的测试。只在一些平台上可用。使用pread 接口。

-f filename
用来指定测试时使用的临时文件的文件名。当使用unmount参数时这将很有用。测试时在每个测试之间进行unmount的话,测试使用的临时文件在一个可以被卸载的文件夹中是很有必要的。卸载当前工作目录是不可能的,因为Iozone进程运行于此。

-F filename filename filename …
指定吞吐量测试中每个临时文件的文件名。文件名的数量应该和指定的进程或线程
数相同。

-g #
设置自动模式可使用的最大文件大小(Kbytes)。

-G
对mmap文件使用msync(MS_SYNC)。这告诉操作系统在mmap空间的所有数据
需要被同步地写到磁盘上。

-h
显示帮助。

-H #
使用POSIX异步I/O接口中的#号异步操作。Iozone使用POSIX 异步I/O接口,并使
用bcopy 从异步缓存拷贝回应用程序缓存。一些版本的MSC NASTRAN就是这么进
行I/O操作的。应用程序使用这一技术以便异步I/O可以在一个库中实现,而不需要
更改程序内模。
This technique is used by applications so that the async
I/O may be performed in a library and requires no changes to the applications internal model.

-i #
用来指定运行哪个测试。 (0=write/rewrite, 1=read/re-read, 2=random-read/write
3=Read-backwards, 4=Re-write-record, 5=stride-read, 6=fwrite/re-fwrite, 7=fread/Re-fread,
8=random mix, 9=pwrite/Re-pwrite, 10=pread/Re-pread, 11=pwritev/Re-pwritev, 12=preadv/Re-preadv). 
总是需要先进行0号测试以便后面的测试有文件可以测试。
也支持使用-i # -i # -i # 以便可以进行多个测试。

-I
对所有文件操作使用VxFS VX_DIRECT 。告诉VXFS 文件系统所有对文件的操作将跨
过缓存直接在磁盘上进行。

-j #
设置访问文件的跨度为 (# * 块 大小). Stride read测试将使用这个跨度来读块 。

-J # (毫秒级)
在每个I/O操作之前产生指定毫秒的计算延迟。看 -X 和-Y来获取控制计算延
迟的其他参数。
    -k #
Use POSIX async I/O (no bcopy) with # async operations. Iozone will use POSIX async
I/O and will not perform any extra bcopys. The buffers used by Iozone will be handed to
the async I/O system call directly.

-K
在普通测试时生成一些随机访问。

-l #
Set the lower limit on number of processes to run. When running throughput tests this
option allows the user to specify the least number of processes or threads to start. This
option should be used in conjunction with the -u option.

-L #
Set processor cache line size to value (in bytes). Tells Iozone the processor cache line size.
This is used internally to help speed up the test.

-m
Tells Iozone to use multiple buffers internally. Some applications read into a single
buffer over and over. Others have an array of buffers. This option allows both types of
applications to be simulated.  Iozone’s default behavior is to re-use internal buffers.
This option allows one to override the default and to use multiple internal buffers.

-M
Iozone will call uname() and will put the string in the output file.

-n #
为自动模式设置最小文件大小(Kbytes)。

-N
报告结果以毫秒每操作的方式显示。

-o
写操作是同步写到磁盘的。 (O_SYNC). Iozone 会以O_SYNC 标志打开文件。这强制所有写操作完全写入磁盘后才返回测试。

-O
报告结果以操作每秒的方式显示。

-p
This purges the processor cache before each file operation. Iozone will allocate another
internal buffer that is aligned to the same processor cache boundary and is of a size that
matches the processor cache. It will zero fill this alternate buffer before beginning each test.
This will purge the processor cache and allow one to see the memory subsystem without
the acceleration due to the processor cache.

-P #
Bind processes/threads to processors, starting with this cpu #. Only available on some
platforms. The first sub process or thread will begin on the specified processor. Future processes or threads will be placed on the next processor. Once the total number of cpus is exceeded then future processes or threads will be placed in a round robin fashion.

-q #
设置自动模式下使用的最大块大小(Kbytes) 。也可以通过-q #k ( Kbytes) 或 -q #m ( Mbytes) 或 -q #g ( Gbytes)。设置最小块大小见 –y 。

-Q
Create offset/latency files. Iozone will create latency versus offset data files that can be
imported with a graphics package and plotted. This is useful for finding if certain offsets
have very high latencies. Such as the point where UFS will allocate its first indirect block.
One can see from the data the impacts of the extent allocations for extent based filesystems
with this option.

-r # 
指定测试块 大小,K字节。也可以通过-r #k (Kbytes) 或 -r #m (Mbytes) 或 -r #g (Gbytes).


-R
生成Excel报告. Iozone将生成一个兼容Excel的标准输出报告。这个文件可以使用
 Microsoft Excel打开,可以创建一个文件系统性能的图表。注意:3D图表是面向列
的。画图时你需要选择这项因为Excel默认处理面向行的数据。


-s # 
指定测试文件大小,K字节。也可以通过-s #k (Kbytes) 或 -s #m (Mbytes) 或 -s #g (Gbytes).

-S #
Set processor cache size to value (in Kbytes). This tells Iozone the size of the processor cache.
It is used internally for buffer alignment and for the purge functionality.

-t #
以吞吐量模式运行Iozone。这一选项允许用户指定测试时使用多少个线程或者进程。

-T
吞吐量测试时使用POSIX线程。仅在兼容POSIX线程的平台上可用。

-u #
Set the upper limit on number of processes to run. When running throughput tests this
option allows the user to specify the greatest number of processes or threads to start.
This option should be used in conjunction with the -l option.

-U mountpoint
在测试之间卸载并重新挂载挂载点。这保证了缓存cache不包含任何测试过的文件。


-v
显示Iozone的版本号。

-V #
Specify a pattern that is to be written to the temporary file and validated for accuracy in
each of the read tests.

-w
当临时文件使用完毕时不删除它们。把它们留在文件系统中。

-W
读或写时锁文件。

-x
关闭“stone-walling”. Stonewalling 是 Iozone内部使用的一种技术。它是在进行吞吐量测试时使用的。程序启动所有线程或进程然后将它们暂停在“壁垒”前。
一旦它们都做好准备工作,它们将被同时释放。当其中任何一个线程或进程完成工作,整个测试就终止了并计算到达这个点时所有I/O的吞吐量。这保证了整个测试进行时所有的进程和线程都是并行的。这个标志位允许取消 stonewalling并看看会发生什么。

-X filename
Use this file for write telemetry information. The file contains  triplets of information:
Byte offset, size of transfer, compute delay in milliseconds.  This option is useful if one has
taken a system call trace of the application that is of interest.  This allows Iozone to replicate the I/O operations that this specific application generates and provide benchmark results for this file behavior.  (if column 1 contains # then the line is a comment)

-y #
设置自动模式下使用的最小块大小(Kbytes) 。也可以通过-y #k ( Kbytes) 或 -y #m ( Mbytes) 或 -y #g ( Gbytes)。设置最大块大小见 –y 。

-Y filename
Use this file for read telemetry information. The file contains triplets of information:
Byte offset, size of transfer, compute delay in milliseconds.  This option is useful if one has
taken a system call trace of the application that is of interest.  This allows Iozone to replicate the I/O operations that this specific application generates and provide benchmark results for this file behavior. (if column 1 contains # then the line is a comment)

-z
Used in conjunction with -a to test all possible record sizes. Normally Iozone omits testing
of small record sizes for very large files when used in full automatic mode.  This option forces
Iozone to include the small record sizes in the automatic tests also.

-Z
启动混合 mmap I/O 和文件 I/O.

-+m filename
Use this file to obtain the configuration information of the clients for cluster testing. The file contains one line for each client. Each line has three fields. The fields are space delimited. A # sign in column zero is a comment line. The first field is the name of the client. The second field is the path, on the client, for the working directory where Iozone will execute. The third field is the path, on the client, for the executable Iozone.
To use this option one must be able to execute commands on the clients without being challenged for a password. Iozone will start remote execution by using “rsh”.

-+u
Enable CPU utilization mode.

-+d
启动诊断模式。在这一模式下每个字节都将被验证。这在怀疑I/O子系统出错时有用。

-+p  percent_read
Set the percentage of the thread/processes that will perform random read testing. Only valid in throughput mode and with more than 1 process/thread.

-+r
Enable O_RSYNC and O_SYNC for all I/O testing.

-+t
启动网络性能测试。需要 -+m

-+A
Enable madvise. 0 = normal, 1=random, 2=sequential, 3=dontneed, 4=willneed.
For use with options that activate mmap() file I/O. See: -B
```
  1. 我的测试脚本(待定)

另附:

Ubuntu 18.04下安装Casandra数据库

  1. Cassandra安装步骤见官网

  2. 具体脚本如下。

     echo "deb http://www.apache.org/dist/cassandra/debian 311x main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list
     curl https://www.apache.org/dist/cassandra/KEYS | sudo apt-key add -
     sudo apt-get update
     sudo apt-get install cassandra

Ubuntu 18.04下修改Casandra数据库存储路径

Cassandra的配置文件为/etc/cassandra/cassandra.yaml,修改其中的三个路径即可。

  1. 首先执行如下指令停止cassandra服务。

     sudo service cassandra stop
  2. 修改cassandra的配置文件。

     data_file_directories:
         - /var/lib/cassandra/data
     修改为:
     data_file_directories:
         - /media/ext4/cassandra/data
    
     commitlog_directory: /var/lib/cassandra/commitlog
     修改为
     commitlog_directory: /media/ext4/cassandra/commitlog
    
     saved_caches_directory: /var/lib/cassandra/saved_caches
     修改为
     saved_caches_directory: /media/ext4/cassandra/saved_caches
  3. 在对应路径下创建文件夹

     sudo mkdir /media/ext4/cassandra
     sudo mkdir /media/ext4/cassandra/data
     sudo mkdir /media/ext4/cassandra/commitlog
     sudo mkdir /media/ext4/cassandra/saved_caches
  4. 执行如下指令为数据库赋予权限

     sudo chown -R cassandra:cassandra /media/ext4/cassandra
  5. 最后执行如下指令重新启动Cassandra

     sudo service cassandra start

使用Cassandra进行磁盘性能测试

这里的性能测试采用的是cassandra里自带的压力测试脚本cassandra-stress

  1. 脚本如下

     cassandra-stress write -pop dist=uniform\(0..1024\) duration=5m -rate threads=16 -errors ignore
     cassandra-stress mixed ratio\(write=8,read=2\) duration=10h -rate threads=16 -errors ignore

    附:

Cassandra-stress说明文档

Deep Diving into cassandra-stress (Part 1)

Deep Diving into cassandra-stress – Part 2 (Mixed Command)

Deep Diving cassandra-stress – Part 3 (Using YAML Profiles)

使用fio进行磁盘性能测试

修改内核调度器,统计信息

  1. 查看当前调度器

     sudo cat /sys/block/sda/queue/scheduler
  2. 更改调度器文件读写权限,更改调度器

     sudo chmod 777 /sys/block/sda/queue/scheduler
     sudo echo noop > /sys/block/sda/queue/scheduler

Linux添加新磁盘分区

  1. 首先运行如下指令,以/dev/sda为例:

     sudo fdisk /dev/sda

YCSB测试RocksDB

  1. 下载和安装 RocksDB

     git clone https://github.com/facebook/rocksdb.git
     cd rocksdb
     make static_lib
     cd examples/
     make all
  2. 下载和安装 YCSB

     git clone https://github.com/brianfrankcooper/YCSB.git
     cd YCSB
     mvn clean package
  3. 测试

    在 YCSB 文件夹里,执行

     cp workloads/workloada workloads/myworkloada

    修改 recordcount 和 operationcount 为 16000000,即 1600 万,每个 record 1KB 大小,database 大小是 16G

     vim workloads/myworkloada
     ./bin/ycsb load rocksdb -s -P workloads/myworkloada -p rocksdb.dir=/media/f2fs/ycsb-rocksdb-data 
    
     ./bin/ycsb run rocksdb -s -P workloads/myworkloada -p rocksdb.dir=/media/f2fs/ycsb-rocksdb-data

    其中的 rocksdb.dir 为 Qemu-SSD 对应的目录

filebench的负载特性如何分析

使用nvme-cli来输出统计信息

Last updated

Was this helpful?