คอมไพล์ sysbench บน Fedora 10

SysBench เป็นโปรแกรมที่ใช้วัดประสิทธิภาพ (benchmark) ของเครื่องได้หลายอย่าง ทั้ง CPU, Memory, Disk และ Database ทั้งนี้ยังสามารถระบุออปชั่นสำหรับการทดสอบได้เช่น จำนวน thread ที่รัน ขนาดที่จะทดสอบ ระยะเวลาที่ใช้ในการรัน

เราสามารถนำผลลัพธ์ที่ได้มาเปรียบเทียบเพื่อการตัดสินใจเลือกซื้อ ปรับแต่งเครื่อง หรือแก้ไขคอนฟิกให้ระบบทำงานได้ดีขึ้น

เนื่องจากในแผ่นติดั้ง หรือ จาก Fedora 10 Everything ไม่มีโปรแกรม sysbench ในรูปแบบ rpm ทำให้การที่จะใช้โปรแกรมนี้ได้ ในบทความนี้ขอนำเสนอขั้นตอนและวิธีการคอมไพล์โปรแกรม sysbench และติดตั้งเอง

หมายเหตุ เครื่องที่จะคอมไพล์ source file ได้นั้น จำเป็นต้องติดตั้ง package ประเภท development ด้วย

ดาวน์โหลดไฟล์

เวอร์ชั่นล่าสุดตอนที่เขียนบทความนี้ (16 May 2009) คือ sysbench-0.4.12 สามารถดาวน์โหลดได้ที่ Download sysbench – SourceForge.net: System performance benchmark: Files

แตกไฟล์ (extract) ใน /usr/local/src/

โปรแกรมที่นำมาคอมไพล์และติดตั้งเอง แนะนำให้ไว้ใน /usr/local/ เพราะเวลาปรับปรุง หรือติดตั้งใหม่ จะได้สะดวกต่อการอ้างอิงและค้นหา ในที่นี้จะไว้ใน /usr/local/src/ เพื่อเก็บ source file และไฟล์ที่ใช้ระหว่างการคอมไพล์โปรแกรม

[root@fc10-dev ~]# cp sysbench-0.4.12.tar.gz /usr/local/src/
[root@fc10-dev ~]# cd /usr/local/src/
[root@fc10-dev src]# ls -l
total 420
-rw-r--r-- 1 root root 421932 2009-05-16 17:02 sysbench-0.4.12.tar.gz

ใช้คำสั่ง tar เพื่อแตกไฟล์

[root@fc10-dev src]# tar zxvf sysbench-0.4.12.tar.gz
sysbench-0.4.12/
sysbench-0.4.12/configure
sysbench-0.4.12/TODO
sysbench-0.4.12/missing
sysbench-0.4.12/INSTALL
sysbench-0.4.12/autogen.sh
sysbench-0.4.12/Makefile.in
sysbench-0.4.12/README
sysbench-0.4.12/Makefile.am
sysbench-0.4.12/README-WIN.txt
...
...
...
sysbench-0.4.12/sysbench/sysbench.h
sysbench-0.4.12/sysbench/sb_options.h
sysbench-0.4.12/sysbench/sb_list.h
sysbench-0.4.12/sysbench/sb_logger.h
sysbench-0.4.12/sysbench/sb_logger.c
sysbench-0.4.12/sysbench/sb_options.c
sysbench-0.4.12/sysbench/sb_timer.c
sysbench-0.4.12/sysbench/sb_timer.h
sysbench-0.4.12/sysbench/CMakeLists.txt
sysbench-0.4.12/sysbench/sb_win.c

ใช้คำสั่ง cd เข้าไปในไดเร็คทอรี ใช้คำสั่ง ls เพื่อดูไฟล์

[root@fc10-dev src]# cd sysbench-0.4.12/
[root@fc10-dev sysbench-0.4.12]# ls
acinclude.m4  autogen.sh  config     configure.ac  doc      install-sh   Makefile.in  mkinstalldirs  README-WIN.txt  TODO
aclocal.m4    ChangeLog   configure  COPYING       INSTALL  Makefile.am  missing      README         sysbench

รัน ./configure

รัน ./configure เพื่อตรวจสอบไฟล์ต่างๆ ที่จำเป็นในการคอนไพล์โปรแกรม และสร้าง Makefile สำหรับคอมไพล์โปรแกรม

[root@fc10-dev sysbench-0.4.12]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to compile with MySQL support... (cached) yes
checking whether to compile with Oracle support... (cached) no
checking whether to compile with PostgreSQL support... (cached) no
checking for style of include used by make... GNU
checking for gcc... gcc
...
...
...
checking for cc_r... gcc
checking for sqrt in -lm... yes
checking for mysql_config... no
configure: error: mysql_config executable not found
********************************************************************************
ERROR: cannot find MySQL libraries. If you want to compile with MySQL support,
       you must either specify file locations explicitly using
       --with-mysql-includes and --with-mysql-libs options, or make sure path to
       mysql_config is listed in your PATH environment variable. If you want to
       disable MySQL support, use --without-mysql option.
********************************************************************************
[root@fc10-dev sysbench-0.4.12]#

ถ้าเจอข้อความฟ้องเตือน error แปลว่าขาดไฟล์ที่ต้องใช้  จำเป็นต้องติดตั้งไฟล์เพิ่มเติมก่อน แล้วรัน ./configure อีกครั้ง

แต่ถ้าในกรณีเราไม่ต้องการใช้โปรแกรม sysbench เพื่อทดสอบประสิทธิภาพของ mysql สามารถรัน ./configure ตามด้วยออปชั่น –without-mysql ก็รัน ./configure ผ่านได้

[root@fc10-dev sysbench-0.4.12]# ./configure --without-mysql
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to compile with MySQL support... (cached) no
checking whether to compile with Oracle support... (cached) no
checking whether to compile with PostgreSQL support... (cached) no
checking for style of include used by make... GNU
checking for gcc... gcc
...
...
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/xsl/Makefile
config.status: creating doc/xsl/catalog.xml
config.status: creating doc/Makefile
config.status: creating sysbench/Makefile
config.status: creating sysbench/drivers/Makefile
config.status: creating sysbench/drivers/mysql/Makefile
config.status: creating sysbench/drivers/oracle/Makefile
config.status: creating sysbench/drivers/pgsql/Makefile
config.status: creating sysbench/tests/Makefile
config.status: creating sysbench/tests/cpu/Makefile
config.status: creating sysbench/tests/fileio/Makefile
config.status: creating sysbench/tests/memory/Makefile
config.status: creating sysbench/tests/threads/Makefile
config.status: creating sysbench/tests/mutex/Makefile
config.status: creating sysbench/tests/oltp/Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@fc10-dev sysbench-0.4.12]#

ข้อความ error ด้านบน “configure: error: mysql_config executable not found” หมายถึงเครื่องนี้ไม่มีไฟล์ mysql_config ซึ่งได้จากการติดตั้ง mysql

สามารถติดตั้ง mysql เพิ่มเติม จากแผ่น DVD ติดตั้ง ใส่แผ่น DVD ใช้คำสั่ง mount เพื่อติดตั้งไฟล์ package ของ mysql

[root@fc10-dev sysbench-0.4.12]# mount /dev/scd0 /media/
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@fc10-dev sysbench-0.4.12]# cd /media/Packages/
[root@fc10-dev Packages]# rpm -i mysql-libs-5.0.67-2.fc10.x86_64.rpm
[root@fc10-dev Packages]# rpm -i perl-DBI-1.607-1.fc10.x86_64.rpm
[root@fc10-dev Packages]# rpm -i mysql-5.0.67-2.fc10.x86_64.rpm
[root@fc10-dev Packages]# cd -
/usr/local/src/sysbench-0.4.12
[root@fc10-dev sysbench-0.4.12]#

รัน ./configure อีกครั้ง

[root@fc10-dev sysbench-0.4.12]# ./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to compile with MySQL support... (cached) yes
checking whether to compile with Oracle support... (cached) no
checking whether to compile with PostgreSQL support... (cached) no
checking for style of include used by make... GNU
checking for gcc... gcc
...
...
...
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/xsl/Makefile
config.status: creating doc/xsl/catalog.xml
config.status: creating doc/Makefile
config.status: creating sysbench/Makefile
config.status: creating sysbench/drivers/Makefile
config.status: creating sysbench/drivers/mysql/Makefile
config.status: creating sysbench/drivers/oracle/Makefile
config.status: creating sysbench/drivers/pgsql/Makefile
config.status: creating sysbench/tests/Makefile
config.status: creating sysbench/tests/cpu/Makefile
config.status: creating sysbench/tests/fileio/Makefile
config.status: creating sysbench/tests/memory/Makefile
config.status: creating sysbench/tests/threads/Makefile
config.status: creating sysbench/tests/mutex/Makefile
config.status: creating sysbench/tests/oltp/Makefile
config.status: creating config/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@fc10-dev sysbench-0.4.12]#

ก่อนจะข้ามไปขั้นตอนต่อไปต้องดูผลลัพธ์ของ ./configure ด้วยว่ายังมี error ใดๆ อีกหรือไม่

รัน make

รัน make เพื่อเริ่มคอมไฟล์โปรแกรม

[root@fc10-dev sysbench-0.4.12]# make
Making all in doc
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12/doc'
Making all in xsl
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/doc'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc'
Making all in sysbench
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench'
Making all in drivers
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
Making all in mysql
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers/mysql'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbmysql_a-drv_mysql.o -MD -MP -MF .deps/libsbmysql_a-drv_mysql.Tpo -c -o libsbmysql_a-drv_mysql.o `test -f 'drv_mysql.c' || echo './'`drv_mysql.c
drv_mysql.c:35:19: error: mysql.h: No such file or directory
drv_mysql.c:36:26: error: mysqld_error.h: No such file or directory
drv_mysql.c: In function ‘mysql_drv_describe’:
drv_mysql.c:284: error: ‘MYSQL_RES’ undeclared (first use in this function)
drv_mysql.c:284: error: (Each undeclared identifier is reported only once
drv_mysql.c:284: error: for each function it appears in.)
drv_mysql.c:284: error: ‘res’ undeclared (first use in this function)
drv_mysql.c:285: error: ‘MYSQL_ROW’ undeclared (first use in this function)
drv_mysql.c:285: error: expected ‘;’ before ‘row’
drv_mysql.c:286: error: ‘MYSQL_FIELD’ undeclared (first use in this function)
drv_mysql.c:286: error: ‘fields’ undeclared (first use in this function)
drv_mysql.c:328: error: ‘row’ undeclared (first use in this function)
drv_mysql.c: In function ‘mysql_drv_connect’:
drv_mysql.c:360: error: ‘MYSQL’ undeclared (first use in this function)
drv_mysql.c:360: error: ‘con’ undeclared (first use in this function)
drv_mysql.c:366: error: expected expression before ‘)’ token
drv_mysql.c:401: error: ‘MYSQL_VERSION_ID’ undeclared (first use in this function)
drv_mysql.c: In function ‘mysql_drv_disconnect’:
drv_mysql.c:441: error: ‘MYSQL’ undeclared (first use in this function)
drv_mysql.c:441: error: ‘con’ undeclared (first use in this function)
drv_mysql.c: In function ‘mysql_drv_bind_param’:
drv_mysql.c:520: error: ‘MYSQL’ undeclared (first use in this function)
drv_mysql.c:520: error: ‘con’ undeclared (first use in this function)
drv_mysql.c:520: error: expected expression before ‘)’ token
drv_mysql.c: In function ‘mysql_drv_query’:
drv_mysql.c:729: error: ‘MYSQL’ undeclared (first use in this function)
drv_mysql.c:729: error: ‘con’ undeclared (first use in this function)
drv_mysql.c:739: error: ‘ER_LOCK_DEADLOCK’ undeclared (first use in this function)
drv_mysql.c:739: error: ‘ER_LOCK_WAIT_TIMEOUT’ undeclared (first use in this function)
drv_mysql.c:739: error: ‘ER_CHECKREAD’ undeclared (first use in this function)
drv_mysql.c: In function ‘mysql_drv_store_results’:
drv_mysql.c:789: error: ‘MYSQL’ undeclared (first use in this function)
drv_mysql.c:789: error: ‘con’ undeclared (first use in this function)
drv_mysql.c:790: error: ‘MYSQL_RES’ undeclared (first use in this function)
drv_mysql.c:790: error: ‘res’ undeclared (first use in this function)
drv_mysql.c:791: error: ‘MYSQL_ROW’ undeclared (first use in this function)
drv_mysql.c:791: error: expected ‘;’ before ‘row’
drv_mysql.c:839: error: ‘ER_LOCK_DEADLOCK’ undeclared (first use in this function)
drv_mysql.c:839: error: ‘ER_LOCK_WAIT_TIMEOUT’ undeclared (first use in this function)
drv_mysql.c:855: error: ‘row’ undeclared (first use in this function)
drv_mysql.c: In function ‘mysql_drv_free_results’:
drv_mysql.c:879: error: ‘MYSQL_RES’ undeclared (first use in this function)
drv_mysql.c:879: error: expected expression before ‘)’ token
make[3]: *** [libsbmysql_a-drv_mysql.o] Error 1
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers/mysql'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make: *** [all-recursive] Error 1
[root@fc10-dev sysbench-0.4.12]#

ถ้ามีข้อความ error ฟ้องเตือนขึ้นมา แสดงว่าคอมไพล์โปรแกรมไม่สำเร็จ ต้องทำการแก้ไข ส่วนมากคือขาดไฟล์ที่ต้องใช้ ในที่นี้

drv_mysql.c:35:19: error: mysql.h: No such file or directory
drv_mysql.c:36:26: error: mysqld_error.h: No such file or directory

แปลว่าขาดไฟล์ header ของ mysql ต้องติดตั้งเพิ่มเติม ไฟล์ header (mysql.h, mysqld_error.h) อยู่ใน package ชื่อ mysql-devel ซึ่งไม่มีอยู่ในแผ่นติดตั้ง DVD ต้องดาวน์โหลดเพิ่มเติมจาก  FC10 Everything (x86_64)

[root@fc10-dev sysbench-0.4.12]# cd ~
[root@fc10-dev ~]# rpm -i mysql-devel-5.0.67-2.fc10.x86_64.rpm
[root@fc10-dev ~]# cd -
/usr/local/src/sysbench-0.4.12
[root@fc10-dev sysbench-0.4.12]#

รันคำสั่ง make อีกครั้ง

[root@fc10-dev sysbench-0.4.12]# make
Making all in doc
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12/doc'
Making all in xsl
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/doc'
make[2]: Nothing to be done for `all-am'.
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc'
Making all in sysbench
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench'
Making all in drivers
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
Making all in mysql
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers/mysql'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbmysql_a-drv_mysql.o -MD -MP -MF .deps/libsbmysql_a-drv_mysql.Tpo -c -o libsbmysql_a-drv_mysql.o `test -f 'drv_mysql.c' || echo './'`drv_mysql.c
mv -f .deps/libsbmysql_a-drv_mysql.Tpo .deps/libsbmysql_a-drv_mysql.Po
rm -f libsbmysql.a
ar cru libsbmysql.a libsbmysql_a-drv_mysql.o
ranlib libsbmysql.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers/mysql'
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/drivers'
Making all in tests
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests'
Making all in cpu
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/cpu'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbcpu_a-sb_cpu.o -MD -MP -MF .deps/libsbcpu_a-sb_cpu.Tpo -c -o libsbcpu_a-sb_cpu.o `test -f 'sb_cpu.c' || echo './'`sb_cpu.c
mv -f .deps/libsbcpu_a-sb_cpu.Tpo .deps/libsbcpu_a-sb_cpu.Po
rm -f libsbcpu.a
ar cru libsbcpu.a libsbcpu_a-sb_cpu.o
ranlib libsbcpu.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/cpu'
Making all in fileio
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/fileio'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbfileio_a-sb_fileio.o -MD -MP -MF .deps/libsbfileio_a-sb_fileio.Tpo -c -o libsbfileio_a-sb_fileio.o `test -f 'sb_fileio.c' || echo './'`sb_fileio.c
mv -f .deps/libsbfileio_a-sb_fileio.Tpo .deps/libsbfileio_a-sb_fileio.Po
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbfileio_a-crc32.o -MD -MP -MF .deps/libsbfileio_a-crc32.Tpo -c -o libsbfileio_a-crc32.o `test -f 'crc32.c' || echo './'`crc32.c
mv -f .deps/libsbfileio_a-crc32.Tpo .deps/libsbfileio_a-crc32.Po
rm -f libsbfileio.a
ar cru libsbfileio.a libsbfileio_a-sb_fileio.o libsbfileio_a-crc32.o
ranlib libsbfileio.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/fileio'
Making all in memory
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/memory'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbmemory_a-sb_memory.o -MD -MP -MF .deps/libsbmemory_a-sb_memory.Tpo -c -o libsbmemory_a-sb_memory.o `test -f 'sb_memory.c' || echo './'`sb_memory.c
mv -f .deps/libsbmemory_a-sb_memory.Tpo .deps/libsbmemory_a-sb_memory.Po
rm -f libsbmemory.a
ar cru libsbmemory.a libsbmemory_a-sb_memory.o
ranlib libsbmemory.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/memory'
Making all in threads
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/threads'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbthreads_a-sb_threads.o -MD -MP -MF .deps/libsbthreads_a-sb_threads.Tpo -c -o libsbthreads_a-sb_threads.o `test -f 'sb_threads.c' || echo './'`sb_threads.c
mv -f .deps/libsbthreads_a-sb_threads.Tpo .deps/libsbthreads_a-sb_threads.Po
rm -f libsbthreads.a
ar cru libsbthreads.a libsbthreads_a-sb_threads.o
ranlib libsbthreads.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/threads'
Making all in mutex
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/mutex'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench  -pthread -g -O2 -MT libsbmutex_a-sb_mutex.o -MD -MP -MF .deps/libsbmutex_a-sb_mutex.Tpo -c -o libsbmutex_a-sb_mutex.o `test -f 'sb_mutex.c' || echo './'`sb_mutex.c
mv -f .deps/libsbmutex_a-sb_mutex.Tpo .deps/libsbmutex_a-sb_mutex.Po
rm -f libsbmutex.a
ar cru libsbmutex.a libsbmutex_a-sb_mutex.o
ranlib libsbmutex.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/mutex'
Making all in oltp
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/oltp'
gcc -DHAVE_CONFIG_H -I. -I../../../config  -I./.. -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../../../sysbench -I/usr/include/mysql  -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC  -pthread -g -O2 -MT libsboltp_a-sb_oltp.o -MD -MP -MF .deps/libsboltp_a-sb_oltp.Tpo -c -o libsboltp_a-sb_oltp.o `test -f 'sb_oltp.c' || echo './'`sb_oltp.c
mv -f .deps/libsboltp_a-sb_oltp.Tpo .deps/libsboltp_a-sb_oltp.Po
rm -f libsboltp.a
ar cru libsboltp.a libsboltp_a-sb_oltp.o
ranlib libsboltp.a
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests/oltp'
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench/tests'
make[3]: Nothing to be done for `all-am'.
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests'
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench/tests'
Making all in .
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/sysbench'
gcc -DHAVE_CONFIG_H -I. -I../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../sysbench  -pthread -g -O2 -MT sysbench.o -MD -MP -MF .deps/sysbench.Tpo -c -o sysbench.o sysbench.c
mv -f .deps/sysbench.Tpo .deps/sysbench.Po
gcc -DHAVE_CONFIG_H -I. -I../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../sysbench  -pthread -g -O2 -MT sb_timer.o -MD -MP -MF .deps/sb_timer.Tpo -c -o sb_timer.o sb_timer.c
mv -f .deps/sb_timer.Tpo .deps/sb_timer.Po
gcc -DHAVE_CONFIG_H -I. -I../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../sysbench  -pthread -g -O2 -MT sb_options.o -MD -MP -MF .deps/sb_options.Tpo -c -o sb_options.o sb_options.c
mv -f .deps/sb_options.Tpo .deps/sb_options.Po
gcc -DHAVE_CONFIG_H -I. -I../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../sysbench  -pthread -g -O2 -MT sb_logger.o -MD -MP -MF .deps/sb_logger.Tpo -c -o sb_logger.o sb_logger.c
mv -f .deps/sb_logger.Tpo .deps/sb_logger.Po
gcc -DHAVE_CONFIG_H -I. -I../config  -D_REENTRANT -D_XOPEN_SOURCE=500 -D_GNU_SOURCE -I../sysbench  -pthread -g -O2 -MT db_driver.o -MD -MP -MF .deps/db_driver.Tpo -c -o db_driver.o db_driver.c
mv -f .deps/db_driver.Tpo .deps/db_driver.Po
/bin/sh ../libtool --tag=CC   --mode=link gcc -pthread -g -O2      -o sysbench sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto   -lrt -lm
../libtool: line 838: X--tag=CC: command not found
../libtool: line 871: libtool: ignoring unknown tag : command not found
../libtool: line 838: X--mode=link: command not found
../libtool: line 1004: *** Warning: inferring the mode of operation is deprecated.: command not found
../libtool: line 1005: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
../libtool: line 2231: X-g: command not found
../libtool: line 2231: X-O2: command not found
../libtool: line 2231: X-rdynamic: command not found
../libtool: line 1951: X-L/usr/lib64/mysql: No such file or directory
../libtool: line 1951: X-L/usr/lib64: No such file or directory
../libtool: line 2400: Xsysbench: command not found
../libtool: line 2405: X: command not found
../libtool: line 2412: Xsysbench: command not found
../libtool: line 2547: X-lmysqlclient_r: command not found
../libtool: line 2547: X-lz: command not found
../libtool: line 2547: X-lcrypt: command not found
../libtool: line 2547: X-lnsl: command not found
../libtool: line 2547: X-lm: command not found
../libtool: line 2547: X-lssl: command not found
../libtool: line 2547: X-lcrypto: command not found
../libtool: line 2547: X-lrt: command not found
../libtool: line 2547: X-lm: command not found
../libtool: line 2629: X-L/usr/local/src/sysbench-0.4.12/sysbench: No such file or directory
../libtool: line 2547: X-lmysqlclient_r: command not found
../libtool: line 2547: X-lz: command not found
../libtool: line 2547: X-lcrypt: command not found
../libtool: line 2547: X-lnsl: command not found
../libtool: line 2547: X-lssl: command not found
../libtool: line 2547: X-lcrypto: command not found
../libtool: line 2547: X-lrt: command not found
../libtool: line 2547: X-lm: command not found
../libtool: line 2629: X-L/usr/local/src/sysbench-0.4.12/sysbench: No such file or directory
../libtool: line 2547: X-lmysqlclient_r: command not found
../libtool: line 2547: X-lz: command not found
../libtool: line 2547: X-lcrypt: command not found
../libtool: line 2547: X-lnsl: command not found
../libtool: line 2547: X-lssl: command not found
../libtool: line 2547: X-lcrypto: command not found
../libtool: line 2547: X-lrt: command not found
../libtool: line 2547: X-lm: command not found
../libtool: line 5162: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o ""  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/usr/local/src/sysbench-0.4.12/sysbench -lmysqlclient_r -lz -lcrypt -lnsl -lssl -lcrypto -lrt -lm: No such file or directory
../libtool: line 5163: Xgcc -pthread "" "" -o @OUTPUT@ sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o ""  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/usr/local/src/sysbench-0.4.12/sysbench -lmysqlclient_r -lz -lcrypt -lnsl -lssl -lcrypto -lrt -lm: No such file or directory
../libtool: line 5168: X: command not found
../libtool: line 5172: : command not found
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12'
[root@fc10-dev sysbench-0.4.12]#

การรัน make ครั้งนี้ก็ยังมี error อีก

../libtool: line 838: X--tag=CC: command not found
../libtool: line 871: libtool: ignoring unknown tag : command not found
../libtool: line 838: X--mode=link: command not found

เท่าที่ทดสอบและตรวจสอบข้อมูลจากเว็บไซต์ของ sysbench เอง มีการเปลี่ยนแปลงเวอร์ชั่นของ libtool ซึ่งเป็น library ที่ใช้ในการคอมไพล์โปรแกรม เวอร์ชั่นตั้งแต่ 0.4.11  ต้องรันคำสั่งด้านล่างนี้เพื่อแก้ไขปัญหา

[root@fc10-dev sysbench-0.4.12]# libtoolize --force --copy
You should update your `aclocal.m4' by running aclocal.
Putting files in AC_CONFIG_AUX_DIR, `config'.
[root@fc10-dev sysbench-0.4.12]# ./autogen.sh
[root@fc10-dev sysbench-0.4.12]#

รันคำสั่ง make อีกครั้ง หลังจากรันคำสั่งแก้ไข

[root@fc10-dev sysbench-0.4.12]# make
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure   --no-create --no-recursion
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to compile with MySQL support... (cached) yes
checking whether to compile with Oracle support... (cached) no
checking whether to compile with PostgreSQL support... (cached) no
checking for style of include used by make... GNU
checking for gcc... gcc
...
...
...
/bin/sh ../libtool --tag=CC   --mode=link gcc -pthread -g -O2      -o sysbench sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -rdynamic -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -lm -L/usr/lib64 -lssl -lcrypto   -lrt -lm
mkdir .libs
gcc -pthread -g -O2 -o sysbench sysbench.o sb_timer.o sb_options.o sb_logger.o db_driver.o -rdynamic  tests/fileio/libsbfileio.a tests/threads/libsbthreads.a tests/memory/libsbmemory.a tests/cpu/libsbcpu.a tests/oltp/libsboltp.a tests/mutex/libsbmutex.a drivers/mysql/libsbmysql.a -L/usr/lib64/mysql -lmysqlclient_r -lz -lcrypt -lnsl -L/usr/lib64 -lssl -lcrypto -lrt -lm
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12'
make[1]: Nothing to be done for `all-am'.
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12'
[root@fc10-dev sysbench-0.4.12]#

ตรวจสอบอีกครั้งว่าไม่มี error ขึ้นมาอีก จากการันคำสั่ง make แล้วค่อยไปขั้นตอนต่อไป

รัน make install

ถ้ารัน make แล้ว ไม่มีข้อความ error แสดงว่าโปรแกรมคอมไพล์สำเร็จ สามารถใช้คำสั่ง make install เพื่อติดตั้งไฟล์ได้ โดยดีฟอลต์ โปรแกรมที่คอมไฟล์เองจะติดตั้งไฟล์ไว้ใน /usr/local/

[root@fc10-dev sysbench-0.4.12]# make install
Making install in doc
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12/doc'
Making install in xsl
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[3]: Entering directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[3]: Nothing to be done for `install-exec-am'.
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/doc/xsl'
...
...
...
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12/sysbench'
make[1]: Entering directory `/usr/local/src/sysbench-0.4.12'
make[2]: Entering directory `/usr/local/src/sysbench-0.4.12'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/src/sysbench-0.4.12'
make[1]: Leaving directory `/usr/local/src/sysbench-0.4.12'
[root@fc10-dev sysbench-0.4.12]#

ตรวจสอบโปรแกรม sysbench ที่ถูกติดตั้ง ไว้ใน /usr/local/bin/

[root@fc10-dev sysbench-0.4.12]# ls -l /usr/local/bin/
total 308
-rwxr-xr-x 1 root root 307952 2009-05-16 17:20 sysbench
[root@fc10-dev sysbench-0.4.12]#

ทดลองรัน sysbench

ทดลองรัน sysbench โดยไม่ได้ระบุออปชั่น ถ้าคอมไพล์และติดตั้งถูกต้อง หน้าจอจะขึ้นวิธีการใช้ (usage) ขึ้นมา

หมายเหตุ โดยดีฟอลต์จากการติดตั้งลีนุกซ์ส่วนใหญ่แล้ว /usr/local/bin/ จะอยู่ใน PATH อยู่แล้ว ทำให้เราไม่ต้องระบุ PATH เต็มๆ เวลารันไฟล์ ที่อยู่ใน /usr/local/bin/

[root@fc10-dev sysbench-0.4.12]# sysbench
Missing required command argument.
Usage:
  sysbench [general-options]... --test=<test-name> [test-options]... command
General options:
  --num-threads=N            number of threads to use [1]
  --max-requests=N           limit for total number of requests [10000]
  --max-time=N               limit for total execution time in seconds [0]
  --forced-shutdown=STRING   amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE   size of stack per thread [32K]
  --init-rng=[on|off]        initialize random number generator [off]
  --test=STRING              test to run
  --debug=[on|off]           print more debugging info [off]
  --validate=[on|off]        perform validation checks where possible [off]
  --help=[on|off]            print help and exit
  --version=[on|off]         print version and exit
Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test
Commands: prepare run cleanup help version
See 'sysbench --test=<name> help' for a list of options for each test.
[root@fc10-dev sysbench-0.4.12]#

ลบไฟล์ที่คอมไพล์ (optional)

หลังจากคอมไพล์และติดตั้งลงโปรแกรมไว้ใน /usr/local/bin/ แล้ว เราสามารถลบไฟล์ที่คอมไพล์ออกไปได้ เพื่อประหยัดพื้นที่ดิสก์

[root@fc10-dev sysbench-0.4.12]# cd ..
[root@fc10-dev src]# rm -rvf sysbench-0.4.12/ sysbench-0.4.12.tar.gz
removed `sysbench-0.4.12/configure'
removed `sysbench-0.4.12/Makefile.in'
removed `sysbench-0.4.12/TODO'
removed `sysbench-0.4.12/install-sh'
removed `sysbench-0.4.12/aclocal.m4'
removed `sysbench-0.4.12/Makefile'
removed `sysbench-0.4.12/README'
removed `sysbench-0.4.12/autogen.sh'
removed `sysbench-0.4.12/sysbench/sysbench.o'
removed directory: `sysbench-0.4.12/sysbench/.libs'
removed `sysbench-0.4.12/sysbench/db_driver.c'
removed `sysbench-0.4.12/sysbench/sb_win.h'
...
...
...
removed directory: `sysbench-0.4.12/config'
removed `sysbench-0.4.12/libtool'
removed `sysbench-0.4.12/config.log'
removed `sysbench-0.4.12/Makefile.am'
removed `sysbench-0.4.12/README-WIN.txt'
removed directory: `sysbench-0.4.12'
removed `sysbench-0.4.12.tar.gz'
[root@fc10-dev src]#  ls -l
total 0
[root@fc10-dev src]#

ข้อมูลอ้างอิง

Leave a Reply

Your email address will not be published.