[MySQL] Install MySQL Cluster 7.2.10 on CentOS 6

0.Pre-config OS
================================================================
先將/etc/udev/rules.d/70-persistent-net.rules裡的eth0刪除並把eth1改為eth0
#sudo vi /etc/udev/rules.d/70-persistent-net.rules

更改/etc/sysconfig/network-scripts/ifcfg-eth0
#sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETWORK=192.168.1.0
NETMASK=255.255.255.0
BROADCAST=192.168.1.255
IPADDR=192.168.1.xxx

更改hostname
#sudo vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=xxx_xxx

disable SELINUX
#sudo vi /etc/sysconfig/selinux
SELINUX=disabled

1.Management Node
================================================================
#tar -zxvf mysql-cluster-gpl-7.2.5-linux2.6-x86_64.tar.gz
#cd mysql-cluster-gpl-7.2.5-linux2.6-x86_64
#mv bin/ndb_mgm .
#mv bin/ndb_mgmd .
#chmod +x ndb_mg*
#mv ndb_mg* /usr/bin/

set up the config file ON ManagementNode
#mkdir /var/lib/mysql-cluster
#cd /var/lib/mysql-cluster
#vi config.ini

-------config.ini--------
[NDBD DEFAULT]
DataMemory=80M
IndexMemory=18M
NoOfReplicas=2

[MYSQLD DEFAULT]

[NDB_MGMD DEFAULT]

[TCP DEFAULT]

# Managment Server
[NDB_MGMD]
HostName=192.168.1.180       # the IP of Mgm SERVER
# Storage Engines
[NDBD]
HostName=192.168.1.182        # the IP of the 2nd SERVER
DataDir= /var/lib/mysql-cluster
[NDBD]
HostName=192.168.1.183    # the IP of the 3rd SERVER
DataDir=/var/lib/mysql-cluster
# 1 MySQL Clients
[MYSQLD]
HostName=192.168.1.180       # the IP of 4th SERVER
---------------------------

#mkdir -p /usr/local/mysql/mysql-cluster

Start the Management Node:
#ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial
#ndb_mgmd -f /var/lib/mysql-cluster/config.ini --reload

2.Data Node
================================================================
#tar -zxvf mysql-cluster-gpl-7.2.10-linux2.6-x86_64.tar.gz
#mv mysql-cluster-gpl-7.2.10-linux2.6-x86_64 /usr/local/
#cd /usr/local/
#mv mysql-cluster-gpl-7.2.10-linux2.6-x86_64 mysql-cluster
#mkdir /var/lib/mysql-cluster
#mkdir /etc/mysql
#cd /etc/mysql
#vi my.cnf

--------my.cnf--------
[mysqld]
datadir=/usr/local/mysql-cluster/data
basedir=/usr/local/mysql-cluster
socket=/usr/local/mysql-cluster/mysql.sock
default-storage-engine=NDBCLUSTER
ndbcluster
ndb-connectstring=192.168.1.180

[mysql_cluster]
ndb-connectstring=192.168.1.180
-----------------------

Startup DataNode
#/usr/local/mysql-cluster/bin/ndbd --initial
#/usr/local/mysql-cluster/bin/ndbd -d

3.SQL Node
================================================================
#tar -zxvf mysql-cluster-gpl-7.2.10-linux2.6-x86_64.tar.gz
#mv mysql-cluster-gpl-7.2.10-linux2.6-x86_64 /usr/local/
#cd /usr/local/
#mv mysql-cluster-gpl-7.2.10-linux2.6-x86_64 mysql-cluster
#cp mysql-cluster/support-files/mysql.server /etc/init.d/mysqld
#mkdir /etc/mysql
#vi /etc/mysql/my.cnf

——————-my.cnf——————————–
[client]
port = 3306
socket = /tmp/mysql.sock

# The MySQL server
[mysqld]
basedir = /usr/local/mysql-cluster
datadir = /usr/local/mysql-cluster/data
port = 3306
socket = /tmp/mysql.sock
ndbcluster
ndb-connectstring=192.168.1.180
user = mysql
# Try number of CPU’s*2 for thread_concurrency
thread_concurrency = 2
log-bin=mysql-bin
log-error

[mysql_cluster]
ndb-connectstring=192.168.1.180

[mysqld_safe]
log-error = /var/log/mysqld.log
pid-file = /var/run/mysqld/mysqld.pid

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[mysqlhotcopy]
interactive-timeout
————————————-————————-

#groupadd mysql
#useradd -r -g mysql -s /sbin/nologin mysql
#cd /usr/local/mysql-cluster
#scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-cluster
#vi /etc/init.d/mysqld
***把basedir 跟 datadir的路徑加入
basedir=
    datadir=
    改為
basedir=/usr/local/mysql-cluster
    datadir=/usr/local/mysql-cluster/data

#/etc/init.d/mysqld start
#/etc/init.d/mysqld stop

$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Add Data and SQL Node
Step 1: Update configuration file.  (add [NDBD] or [MYSQLD]), 加sqlnode只要做到Step 4
Step 2: Restart the management server.
2.1 in ndb_mgm console, type 'x' stop. x is mgmnode id, x=1 usually.
2.2 in shell, restart ndb_mgmd (#ndb_mgmd -f /var/lib/mysql-cluster/config.ini --reload)
Step 3: Perform a rolling restart of the existing data nodes.
3.1 in ndb_mgm console, type 'x' restart. x is data node id.(每一個Data Node都要restart)
Step 4: Perform a rolling restart of all cluster API nodes.
4.1 in shell, restart mysqld (#/etc/init.d/mysqld restart)
Step 5: Perform an initial start of the new data nodes.
5.1 in shell, execute ndbd --initial
Step 6: Create a new node group.
6.1 in ndb_mgm console, type CREATE NODEGROUP 3,4
Step 7: Redistribute cluster data
7.1 in ndb_mgm console, type ALL REPORT MEMORY
7.2 在sqlnode的結點下,連入mysql> ALTER ONLINE TABLE xxxxx REORGANIZE PARTITION
7.3 在sqlnode的結點下,連入mysql> OPTIMIZE TABLE xxxxx,xxxxx

[OpenERP] Install OpenERP 6.1 on Amazon EC2 (Ubuntu 12.04 LTS x64)

1.先安裝系統所需的程式或lib
#sudo apt-get install openssh-server denyhosts
#sudo apt-get update
#sudo apt-get dist-upgrade

2.Create the OpenERP user
#sudo adduser --system --home=/opt/openerp --group openerp
#sudo su - openerp -s /bin/bash
#exit

3.Install and configure the database server(PostgreSQL)
#sudo apt-get install postgresql
#sudo su - postgres
#createuser --createdb --username postgres --no-createrole --no-superuser --pwprompt openerp
Enter password for new role: cen0q@dmin (mz@dmin)
Enter it again: cen0q@dmin (mz@dmin)
#exit

4.Install the necessary Python libraries for the OpenERP server
#sudo apt-get install unzip python-mock python-unittest2 python-docutils python-jinja2 python-dateutil python-feedparser python-gdata python-ldap python-libxslt1 python-lxml python-mako python-openid python-psycopg2 python-pybabel python-pychart python-pydot python-pyparsing python-reportlab python-simplejson python-tz python-vatnumber python-vobject python-webdav python-werkzeug python-xlwt python-yaml python-zsi python-pip
#sudo apt-get remove python-werkzeug
#sudo pip install werkzeug

5.Install the OpenERP server
a.Download:
#wget http://nightly.openerp.com/6.1/releases/openerp-6.1-1.tar.gz
#     http://nightly.openerp.com/6.1/releases/openerp-6.1-latest.tar.gz
b.unzip:
#sudo mkdir /opt/openerp
#cd /opt/openerp
#sudo tar xvf ~/openerp-6.1-1.tar.gz
#sudo chown -R openerp: *
#sudo cp -a openerp-6.1-1 server

6.Configuring the OpenERP server
#sudo cp /opt/openerp/server/install/openerp-server.conf /etc/
#sudo chown openerp: /etc/openerp-server.conf
#sudo chmod 640 /etc/openerp-server.conf
#sudo vi /etc/openerp-server.conf
db_password = False
logfile = /var/log/openerp/openerp-server.log
#########################
for openerp v7
要額外加上gdata-python-client (http://code.google.com/p/gdata-python-client/)
先下載最新版本,解壓後再執行
#sudo python ./setup.py install
#########################
#sudo su - openerp -s /bin/bash
#/opt/openerp/server/openerp-server   <---for ctrl="" div="" run="" server="" shutdown="" test="" to="">
#exit

7.Installing the boot script
#sudo chmod 755 /etc/init.d/openerp-server
#sudo chown root: /etc/init.d/openerp-server
#sudo update-rc.d -f openerp-server defaults
#sudo mkdir /var/log/openerp
#sudo chown openerp:root /var/log/openerp