Percona XtraDB Cluster with python3 mysql

Percona XtraDB Cluster

# aptitude install curl rsync
# curl http://www.percona.com/downloads/RPM-GPG-KEY-percona | apt-key add -

insert /etc/apt/sources.list

deb http://repo.percona.com/apt squeeze main

# aptitude update
# aptitude install percona-xtradb-cluster-client-5.5 percona-xtradb-cluster-server-5.5 percona-xtrabackup

insert /etc/mysql/my.cnf

[mysqld]
binlog_format=ROW
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://
wsrep_slave_threads=2
wsrep_cluster_name=xtradbClusterTest
wsrep_sst_method=rsync
wsrep_node_name=node1
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2

/etc/init.d/mysql restart

ADD a new mysql cluster node

1. Change “wsrep_node_name” to be unique for every new node
2. Change “wsrep_cluster_address=gcomm://” to “wsrep_cluster_address=gcomm://[ip of a running node]”

copy /etc/mysql/debian.cnf from master node to new node

python3 and MySQL-python

insert /etc/apt/sources.list

# Backports repository
deb http://backports.debian.org/debian-backports squeeze-backports main contrib non-free

# aptitude update
# aptitude install python3 python3-pip libmysqlclient-dev python-dev libevent-dev
# easy_install -U distribute
# pip install MySQL-python

EnvironmentError: mysql_config not found

problem

# pip install MySQL-python==1.2.3
Downloading/unpacking MySQL-python==1.2.3
  Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/root/build/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: not found

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/root/build/MySQL-python/setup.py", line 15, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /root/build/MySQL-python
Storing complete log in /root/.pip/pip.log

solved

# aptitude install libmysqlclient-dev

mtop on CentOS

mtop เอาไว้ monitor การทำงานของ MySQL ครับ

ปล. สำหรับ 64bit server นะครับ

# get http://pkgs.repoforge.org/perl-Curses/perl-Curses-1.28-1.el5.rf.x86_64.rpm
# rpm -ivh perl-Curses-1.28-1.el5.rf.x86_64.rpm
# wget http://pkgs.repoforge.org/mtop/mtop-0.6.6-1.2.el5.rf.noarch.rpm
# rpm -ivh mtop-0.6.6-1.2.el5.rf.noarch.rpm
# mtop –dbuser=root -p

MySQL 5.5 on Debian

# aptitude install libaio-dev libaio1

# cd /usr/src
# wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.21-debian5.0-x86_64.deb/from/http://mysql.oss.eznetsols.org/
# dpkg -i ysql-5.5.21-debian5.0-x86_64.deb
# ln -s /opt/mysql/server-5.5 /usr/local/mysql
# ln -s /opt/mysql/server-5.5/bin/* /usr/local/bin/
# cp /opt/mysql/server-5.5/support-files/my-medium.cnf /etc/mysql/my.cnf
# ln -s /etc/mysql/my.cnf /etc/my.cnf
# nano /etc/mysql/my.cnf

[client]
#password = your_password
port = 3306
socket = /var/run/mysqld/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
socket = /var/run/mysqld/mysql.sock
user = root
basedir = /usr/local/mysql
datadir = /var/lib/mysql
tmpdir = /tmp
log_error = /var/log/mysql.err
skip-external-locking
….

# cp /opt/mysql/server-5.5/support-files/mysql.server /etc/init.d/mysql
# chmod +x /etc/init.d/mysql
# update-rc.d mysql defaults
# mkdir /var/lib/mysql
# cd /opt/mysql/server-5.5/scripts/
# ./mysql_install_db –user=root –ldata=/var/lib/mysql/
# /etc/init.d/mysql start
# /usr/local/mysql/bin/mysqladmin -u root password ‘newpassword’

## test
# mysql -u root -p

## finalize
# mysql_upgrade -u root -p

source:
http://www.badllama.com/comment/1
https://wiki.archlinux.org/index.php/MySQL