อาทิตย์, 19 เม.ย. 2015
 
 

SMSKP-PayPal

Donate using PayPal
Amount:
Note:
Note:

PTT Oil Price

Gold Status

SM SKP ADS-1

สมุยสเก็ตอัพ คอมมิวนิตี้
Newsfeeds
Planet MySQL
Planet MySQL - http://www.planetmysql.org/

  • FromDual.en: FromDual Performance Monitor for MySQL and MariaDB 0.10.1 has been released
    Taxonomy upgrade extras: mysqlperformancemonitormonitoringfpmmmmaasperformance monitormpmFromDual has the pleasure to announce the release of the new version 0.10.1 of its popular Database Performance Monitor for MySQL, MariaDB, Galera Cluster and Percona Server fpmmm. You can download fpmmm from here. In the inconceivable case that you find a bug in fpmmm please report it to our Bug-tracker. Any feedback, statements and testimonials are welcome as well! Please send them to feedback@fromdual.com. This release contains various minor bug fixes and improvements. Mainly it was a rewrite from Perl into PHP. New installation of fpmmm v0.10.1 Please follow our mpm installation guide. A specific fpmmm installation guide will follow with the next version. Prerequisites CentOS 6 # yum install php-cli php-process php-mysqli # cat << _EOF >/etc/php.d/fpmmm.ini variables_order = "EGPCS" date.timezone = 'Europe/Zurich' _EOF rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/6/x86_64/zabbix-release-2.2-1.el6.noarch.rpm yum update yum install zabbix-senderCentOS 7 # yum install php-cli php-process php-mysqli # cat << _EOF >/etc/php.d/fpmmm.ini variables_order = "EGPCS" date.timezone = 'Europe/Zurich' _EOF rpm -Uvh http://repo.zabbix.com/zabbix/2.2/rhel/7/x86_64/zabbix-release-2.2-1.el7.noarch.rpm yum update yum install zabbix-senderUbuntu 14.04 # apt-get install php5-cli php5-mysqlnd # cat << _EOF >/etc/php5/cli/conf.d/fpmmm.ini variables_order = "EGPCS" date.timezone = 'Europe/Zurich' _EOF apt-get install zabbix-agentOpenSuSE 13.1 # zypper install php5 php5-posix php5-mysql php5-pcntl php5-curl #cat << _EOF >/etc/php5/conf.d/fpmmm.ini variables_order = "EGPCS" date.timezone = 'Europe/Zurich' _EOF zypper addrepo http://download.opensuse.org/repositories/server:/monitoring/openSUSE_13.1 server_monitoring zypper update zypper install zabbix-agentUpgrade from mpm 0.x to fpmmm 0.10.1 # cd /opt # tar xf /download/fpmmm-0.10.1.tar.gz # rm -f fpmmm # ln -s fpmmm-0.10.1 fpmmmYou further have to replace all mysql_performance_monitor_agent.pl hooks (in Zabbix agent) by bin/fpmmm. Changes in fpmmm v0.10.1 fpmmm agent Defaults in fpmmm.conf.template adapted. Item sending prepared for empty strings. Log of cachedData more verbose. zabbix_sender stuff fixed and made more robust. New naming convention fpmmm implemented. Connection problems and error catching fixed. NDB cluster and PBXT stuff removed and locking made more robust. zabbix-sender on SuSE should work now as well. Bug #149. exec/system replaced by my_exec. Debug parameter replaced by LogLevel parameter, including all templates and warning for deprecation. export LC_ALL=C added to all O/S calls to make it language independent. Usage added (--help). All Perl code replaced by PHP code. Bug fix on cache clean-up on corruption. Mac OSX (darwin) support added, partially. Changed defaults away from /tmp This is no good location for persistent things because of RedHat tmpcleaner job. Debugging info added for missing lock file. fpmmm agent and MaaS none. Various modules Regexp pattern fixed for mr_versions. MySQL module Trailing / from datadir is removed. InnoDB module Innodb buffer pool hit ratio rounded to 2 digits. Innodb_os_log_written item added. InnoDB hash searches item fixed. Galera module Galera status now gathered with causal reads off. Memcached module Memcached stuff activated. DRBD module Bug report on new DRBD fixed. fpmmm templates for Zabbix Security template data typo fixed. Templates moved from xml folder to tpl folder and other file structure and renaming. InnoDB Flush Log at Transaction Commit Serverity lowered from Warning to Information. For subscriptions of commercial use of fpmmm please get in contact with us.

  • Ruby Thin Web Server
    Somebody suggested that I try out thin, “A fast and very simple Ruby web server.” So, I thought it might be interesting to test, and a simplification over Rails to demonstrate an small Ruby MVC pattern. Installing thin seemed straight forward as a gem installation, like gem install thin The initial install didn’t work out of the box because I’d neglected to install the gcc-c++ library. It raised the following errors: Fetching: eventmachine-1.0.7.gem (100%) Building native extensions. This could take a while... ERROR: Error installing thin: ERROR: Failed to build gem native extension.   /usr/bin/ruby extconf.rb checking for main() in -lssl... no checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for rb_thread_blocking_region()... yes checking for ruby/thread.h... yes checking for rb_thread_call_without_gvl() in ruby/thread.h... yes checking for inotify_init() in sys/inotify.h... yes checking for writev() in sys/uio.h... yes checking for rb_thread_fd_select()... yes checking for rb_fdset_t in ruby/intern.h... yes checking for rb_wait_for_single_fd()... yes checking for rb_enable_interrupt()... no checking for rb_time_new()... yes checking for sys/event.h... no checking for epoll_create() in sys/epoll.h... yes checking for clock_gettime()... yes checking for CLOCK_MONOTONIC_RAW in time.h... yes checking for CLOCK_MONOTONIC in time.h... yes creating Makefile   make "DESTDIR=" g++ -I. -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I. -DWITHOUT_SSL -DBUILD_FOR_RUBY -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_TBR -DHAVE_RUBY_THREAD_H -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_RB_THREAD_CALL_WITHOUT_GVL -DHAVE_INOTIFY_INIT -DHAVE_INOTIFY -DHAVE_WRITEV -DHAVE_WRITEV -DHAVE_RB_THREAD_FD_SELECT -DHAVE_RB_THREAD_FD_SELECT -DHAVE_TYPE_RB_FDSET_T -DHAVE_RB_FDSET_T -DHAVE_RB_WAIT_FOR_SINGLE_FD -DHAVE_RB_TIME_NEW -DOS_UNIX -DHAVE_EPOLL_CREATE -DHAVE_EPOLL -DHAVE_CLOCK_GETTIME -DHAVE_CONST_CLOCK_MONOTONIC_RAW -DHAVE_CONST_CLOCK_MONOTONIC -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -mtune=generic -m64 -o ed.o -c ed.cpp make: g++: Command not found make: *** [ed.o] Error 127     Gem files will remain installed in /usr/local/share/gems/gems/eventmachine-1.0.7 for inspection. Results logged to /usr/local/share/gems/gems/eventmachine-1.0.7/ext/gem_make.out Naturally, I installed the gcc-c++ library with the yum utility, like this: yum list gcc-c++ It displayed the following log output: Loaded plugins: langpacks, refresh-packagekit mysql-connectors-community | 2.5 kB 00:00 mysql-tools-community | 2.5 kB 00:00 mysql56-community | 2.5 kB 00:00 pgdg93 | 3.6 kB 00:00 updates/20/x86_64/metalink | 14 kB 00:00 updates | 4.9 kB 00:00 updates/20/x86_64/primary_db | 13 MB 00:04 (1/2): updates/20/x86_64/updateinfo | 1.9 MB 00:02 (2/2): updates/20/x86_64/pkgtags | 1.4 MB 00:00 Resolving Dependencies --> Running transaction check ---> Package gcc-c++.x86_64 0:4.8.3-7.fc20 will be installed --> Processing Dependency: libstdc++-devel = 4.8.3-7.fc20 for package: gcc-c++-4.8.3-7.fc20.x86_64 --> Running transaction check ---> Package libstdc++-devel.x86_64 0:4.8.3-7.fc20 will be installed --> Finished Dependency Resolution   Dependencies Resolved   ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gcc-c++ x86_64 4.8.3-7.fc20 updates 7.2 M Installing for dependencies: libstdc++-devel x86_64 4.8.3-7.fc20 updates 1.5 M   Transaction Summary ================================================================================ Install 1 Package (+1 Dependent package)   Total download size: 8.7 M Installed size: 25 M Downloading packages: (1/2): gcc-c++-4.8.3-7.fc20.x86_64.rpm | 7.2 MB 00:05 (2/2): libstdc++-devel-4.8.3-7.fc20.x86_64.rpm | 1.5 MB 00:01 -------------------------------------------------------------------------------- Total 1.3 MB/s | 8.7 MB 00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction (shutdown inhibited) Installing : libstdc++-devel-4.8.3-7.fc20.x86_64 1/2 Installing : gcc-c++-4.8.3-7.fc20.x86_64 2/2 Verifying : gcc-c++-4.8.3-7.fc20.x86_64 1/2 Verifying : libstdc++-devel-4.8.3-7.fc20.x86_64 2/2   Installed: gcc-c++.x86_64 0:4.8.3-7.fc20   Dependency Installed: libstdc++-devel.x86_64 0:4.8.3-7.fc20   Complete! After installing the gcc-c++ libraries, I reran the gem utility to install the thin utility. It created three Ruby Gems: eventmachine-1.0.7, daemons-1.2.2.gem, and thin-1.6.3.gem, as shown: Building native extensions. This could take a while... Successfully installed eventmachine-1.0.7 Fetching: daemons-1.2.2.gem (100%) Successfully installed daemons-1.2.2 Fetching: thin-1.6.3.gem (100%) Building native extensions. This could take a while... Successfully installed thin-1.6.3 Parsing documentation for daemons-1.2.2 Installing ri documentation for daemons-1.2.2 Parsing documentation for eventmachine-1.0.7 Installing ri documentation for eventmachine-1.0.7 Parsing documentation for thin-1.6.3 Installing ri documentation for thin-1.6.3 Done installing documentation for daemons, eventmachine, thin after 11 seconds 3 gems installed Having created the Ruby Gems, I followed the thin instruction on the web site, and created the following Ruby web server: app = proc do |env| [ 200, # Status code { # Response headers 'Content-Type' => 'text/html', 'Content-Length' => '12', }, ['Hello World!'] # Response body ] end   # You can install Rack middlewares # to do some crazy stuff like logging, # filtering, auth or build your own. use Rack::CommonLogger   run app Then, I tested the Ruby web server with the following command: thin start -R thin.ru It displayed the following test server as the result of localhost:3000 URL: As always, I hope this helps those who land on this page.

  • FromDual.en: MySQL Environment MyEnv 1.2.0 has been released
    Taxonomy upgrade extras: myenvoperationMySQL Operationsmulti instanceconsolidationtestingupgradeFromDual has the pleasure to announce the release of the new version 1.2.0 of its popular MySQL, Galera Cluster, MariaDB and Percona Server multi-instance environment MyEnv. The new MyEnv can be downloaded here. In the inconceivable case that you find a bug in the MyEnv please report it to our bug tracker. Any feedback, statements and testimonials are welcome as well! Please send them to feedback@fromdual.com. Upgrade from 1.1.x to 1.2.0 # cd ${HOME}/product # tar xf /download/myenv-1.2.0.tar.gz # rm -f myenv # ln -s myenv-1.2.0 myenvIf you are using plug-ins for showMyEnvStatus create all the links in the new directory structure: cd ${HOME}/product/myenv ln -s ../../utl/oem_agent.php plg/showMyEnvStatus/Changes in MyEnv 1.2.0 MyEnv Some minor fixes on init script. Introduction of states production, quality, testing and development. Colored prompt added for stage production databases. All /tmp/*sock moved to /var/run/mysqld. up output prepared for bind-address awareness. lsb_release dummy implemented. MyEnv Installer Advice for 2 sudo commands in row was wrong. Port conflict resolution more verbose. Init script replacement check added. Replace init script is distribution aware and auto executable. Installer made mode modular and prepared for automatization. Installer allows now to run as other user than mysql. Bugs in preparing myenv.conf fixed and instance name removed. Install routine made more distribution aware. MyEnv Utilities Split partition (split_partition.php) improved. Fix of DROP PARTITION (drop_partition.php) was executed in wrong order (new before old). Alter Engine script rewritten into PHP (alter_engine.php). Alter Engine script handles ROW_FORMAT=FIXED problem correctly now. Alter Engine script handles too large Primary Key better. Alter Engine script recognizes tables with AUTO_INCREMENT column not at 1st position. Purge Binary Log rewritten into PHP (purge_binary_log.php). compare_status_files.pl added to compare output of 2 SHOW GLOBAL STATUS. For subscriptions of commercial use of MyEnv please get in contact with us.

  • Ruby-MySQL Columns
    Last week I posted how to configure and test Ruby and MySQL. Somebody asked me how to handle a dynamic list of columns. So, here’s a quick little program to show you how to read the dynamic list of column: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 require 'rubygems' require 'mysql'   # Begin block. begin # Create a new connection resource. db = Mysql.new('localhost','student','student','studentdb')   # Create a result set. rs = db.query('SELECT item_title, item_rating FROM item') # Read through the result set hash. rs.each do | row | out = "" i = 0 while i < db.field_count # Check if not last column. if i < db.field_count - 1 out += "#{row[i]}, " else out += "#{row[i]}" end i += 1 end puts "#{out}" end # Release the result set resources. rs.free rescue Mysql::Error => e # Print the error. puts "ERROR #{e.errno} (#{e.sqlstate}): #{e.error}" puts "Can't connect to MySQL database specified." # Signal an error. exit 1 ensure # Close the connection when it is open. db.close if db end The new logic on lines 13 through 22 reads the list of columns into a comma delimited list of values. The if-block checks to make sure it doesn’t append a comma to the last column in the list. It prints output like: The Hunt for Red October, PG Star Wars I, PG Star Wars II, PG Star Wars II, PG Star Wars III, PG13 The Chronicles of Narnia, PG RoboCop, Mature Pirates of the Caribbean, Teen The Chronicles of Narnia, Everyone MarioKart, Everyone Splinter Cell, Teen Need for Speed, Everyone The DaVinci Code, Teen Cars, Everyone Beau Geste, PG I Remember Mama, NR Tora! Tora! Tora!, G A Man for All Seasons, G Hook, PG Around the World in 80 Days, G Harry Potter and the Sorcerer's Stone, PG Camelot, G As always, I hope this helps those looking for a solution.

  • mysqldiskusage – source code examination
    As you know there is a great toolset named “MySQL Utilities”, which you can use for solving various administrative tasks. mysqldiskusage utility is for calculating MySQL Server’s disk usage and generating informative reports. Of course this project is open source and everybody could review the source code. A few words about how mysqldiskusage calculates database disk usage will be crucial for understanding algorithm. The source tree is: mysql-utilities-1.5.4/scripts/mysqldiskusage.py If you open this Python file you will see (line 169-175) : # We do database disk usage by default. try: diskusage.show_database_usage(servers[0], datadir, args, options) except UtilError: _, e, _ = sys.exc_info() print("ERROR: %s" % e.errmsg) sys.exit(1) By default it shows database disk usage and calling another function named show_database_usage from mysql-utilities-1.5.4/mysql/utilities/command/diskusage.py file. Now if we open up this diskusage.py file and search for show_database_usage function, you should see that in turn this function uses another function named _build_db_list. From _build_db_list it gets back all necessary information as in code stated clearly(line 550-562): # Get list of databases with sizes and formatted when necessary columns, rows, db_total = _build_db_list(server, res, dblist, datadir, fmt == "grid", have_read, verbosity, include_empty or do_all, is_remote) if not quiet: print "# Database totals:" print_list(sys.stdout, fmt, columns, rows, no_headers) if not quiet: _print_size("\nTotal database disk usage = ", db_total) print Now we know that all calculations are happened in _build_db_list function. If you search and find this function(begins from line 360) you can see that, in fact mysqldiskusage is calculating database disk usage as follows: 1. It finds (data_length + index_length) from information_schema.tables per database manner 2. Then it sum ups (data_length + index_length) with misc_files variable data which is in fact returned by _get_db_dir_size function. But what is this misc_files? Logically misc_files must be .opt and .frm files. So misc_files must not be an “.MYD” , “.MYI”, “.IBD”, “general_log”, “slow_log”. So in fact mysqldiskusage calculates database disk usage as -> (data_length + index_length)[size in bytes] + (.opt+.frm)[size in bytes]. First of all we must insist on not using information_schema for accurate disk usage calculation because of simple rule: “InnoDB preallocates pages(16Kib) for further table usage, but data_length column will not show these pages” As proof of concept let’s create sample empty table: mysql> create database test; Query OK, 1 row affected (0,01 sec) mysql> use test; Database changed mysql> select data_length, index_length from information_schema.tables where table_schema='test' and table_name='t1'; +-------------+--------------+ | data_length | index_length | +-------------+--------------+ | 16384 | 0 | +-------------+--------------+ 1 row in set (0,00 sec) If we consider that our exact table size is 16384 bytes, we are in wrong direction. In fact if we use OS commands we could see that the exact size of table is 98304 bytes: [root@node1 ~]# ls -lt /var/lib/mysql/test/ total 208 -rw-rw----. 1 mysql mysql 98304 Apr 18 11:44 t1.ibd So when we create an InnoDB table it is preallocates 6 pages(16Kib*6 = 98304) but only 1 page shown up from data_length column. Now let’s come back to our misc_files or exactly _get_db_dir_size() function. From source code we can see that there is no a check for “.IBD” files: ... for item in os.listdir(folder): name, ext = os.path.splitext(item) if ext.upper() not in (".MYD", ".MYI") and \ name.upper() not in ('SLOW_LOG', 'GENERAL_LOG'): itemfolder = os.path.join(folder, item) ... Because of this calculation is wrong for databases as we see from output: [root@node1 ~]# mysqldiskusage --server=root_pass -vvv # Source on localhost: ... connected. # Database totals: +---------------------+--------------+--------------+--------------+--------------+ | db_name | db_dir_size | data_size | misc_files | total | +---------------------+--------------+--------------+--------------+--------------+ | employees | 242.523.049 | 205.979.648 | 242.523.049 | 448.502.697 | As you see it sum ups data_size with misc_files and gets back total as 448.502.697 bytes. But in fact our employees database is exactly 242.523.049 bytes. And of course the: Total database disk usage = 450.940.391 bytes or 430,05 MB is wrong as well. For further exploration and how to patch source code see related BUG REPORT #76703. The post mysqldiskusage – source code examination appeared first on Azerbaijan MySQL UG.