Archive

Archive for the ‘Database’ Category

CodeIgniter & TokuMX

February 4, 2015 Leave a comment

CodeIgniter is a lightweight PHP framework that can help you to develop Web Application. TokuMX is a drop-in replacement for MongoDB, that support transaction.

You can download codeigniter from here, and TokuMX from here . For more information about how to install TokuMX, you can read TokuMX documentation from GitHub here.

To Make Web Application can connect to Mongo Instance, you need to install PHP extension for mongo. To Install in Centos or Redhat environment, run command :

pecl install mongo

and add to /etc/php.ini

extension=mongo.so

Restart Web Service

service httpd restart

Download codeigniter-mongo-library from here .

Here’s simple code example how to use codeigniter-mongo-library to perform CRUD operation.

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller
{
  // Insert Operation
  public function mongo_insert_test()      
  {
     $this->load->library("cimongo/cimongo");
     for($i=0;$i<25;$i++) {
        $this->cimongo
            ->insert("testData", array("x" => $i, "y" => 25-$i ));
     }
  }

  // Select Operation 
  public function mongo_select_test()
  {
     $this->load->library("cimongo/cimongo");
     $mongo_data = $this->cimongo->get("testData");
     foreach($mongo_data->result_array() as $row) {
        echo sprintf('x:%d,y:%d <br>',$row['x'],$row['y']);
     }
  }
  
  // Update Operation
  public function mongo_update_test()
  {
     $this->load->library("cimongo/cimongo");
     $result = $this->cimongo->where(array("x" => 24 ))
                    ->set(array("x" => 25 ))->update("testData");
     echo $result
  }

  // Delete Operation
  public function mongo_delete_test()
  {
     $this->load->library("cimongo/cimongo");
     $result = $this->cimongo->where(array("x" => 25 ))
                    ->delete("testData");
     echo $result;
  } 

}

?>

 

Categories: Database, Mongo, PHP, Programming

Plastic SCM Mysql Database Config

October 30, 2014 Leave a comment

This is step-by-step to Change Mysql Server Configuration before migrating plastic scm database from MS SQL Server (CE)

  1. Edit the my.cnf file, normally located in /etc or /etc/mysql in Linux, or the c:\Program Files\MySQL\my.ini file in Windows. Add or edit the lines below.
  2. The innodb_buffer_pool_size should be around half of the memory of your server machine. This is the most important value. Note that due to a limitation in MySQL, this value should be maximum 4GB (more details here):
    innodb_buffer_pool_size = 2G
  3. innodb_additional_mem_pool_size should be a 5% of the innodb_buffer_pool_size:
    innodb_additional_mem_pool_size = 100M
  4. Set innodb_log_file_size to 25% of buffer pool size.
    innodb_log_file_size = 500M
  5. innodb_log_buffer_size can be around 2% of the buffer pool size or, at a minimum, 8MB.
    innodb_log_buffer_size = 40M
  6. Also, don’t forget to set the max_allowed_packet to 10MB. This is mandatory for correct Plastic SCM operation:
    max_allowed_packet = 10M
  7. Once these settings are in place, restart the MySQL service.

original source : http://www.plasticscm.com/infocenter/technical-articles/kb-how-to-fine-tune-mysql-performance-for-plastic-scm.aspx

Categories: Database, Version Control