So Tired !_! 逆水行舟, 不进则退!

28Jun/12

ubuntu 12.04 on citrix xenserver 5.6

Posted by Nick Xu

After upgrading my virtualized Ubuntu 11.10 installation to Ubuntu 12.04 Precise Pangolin, I've had strange problems on booting up the virtual machine: Sometimes it booted up smoothly, sometimes it hung, sometimes it reported a read-only filesystem due to errors (which actually could not be found using fsck). After some investigation, I decided to re-install the system.

I wanted to install Ubuntu 12.04 LTS para-virtualized (PV), but this is not supported out of the box by Citrix XenServer 5.6 SP2. However, I've found some really useful instructions in the Citrix Forums written for for Ubuntu 11.04, also working for Ubuntu 12.04:

  1. Enter the XenServer Console and get the UUID of the Ubuntu 10.10 template:
    xe template-list name-label="Ubuntu Lucid Lynx 10.04 (64-bit) (experimental)" --minimal
  2. Clone the Ubuntu 10.10 template:
    xe vm-clone uuid=[UUID from step 1 here] new-name-label="Ubuntu Precise Pangolin 12.04 (64-bit)"
  3. Configute the new Ubuntu 12.04 template:
    xe template-param-set other-config:default_template=true other-config:debian-release=precise uuid=[UUID from step 2 here]
  4. Create a new VM and choose your newly created Ubuntu 12.04 template.
  5. Enter the following url under "Install from URL:"
    http://archive.ubuntu.net/ubuntu/
  6. Create a separate /boot partition at the beginning of the virtual disk (I chose 256 MB).
  7. After the installation is completed, log into your new VM and become root.
    sudo -s
  8. Install the virtual kernel image:
    apt-get install linux-virtual linux-image-virtual linux-headers-virtual
  9. Remove the generic kernel image:
    apt-get remove linux-generic linux-headers-generic linux-image-generic
  10. Update the grub boot loader:
    update-grub
  11. Insert the XenServer Tools xs-tools.iso and mount it:
    mount /dev/xvdd /mnt
  12. Install the XenServer Tools:
    cd /mnt/Linux
    dpkg -i *amd64.deb
  13. Unmount the ISO and reboot:
    cd
    umount /mnt
    reboot
  14. That's it!

I haven't tried, but this might work for Citrix XenServer 6, too.

Filed under: Linux 1 Comment
17Jun/12

Install OpenCV 2.4 on Ubuntu 12.04

Posted by Nick Xu

If you’re going to process live streams from cameras or videos, the most important library needed for OpenCV is ffmpeg. You can find a good tutorial on how to compile and install ffmpeg on Ubuntu here.
You need to follow those steps, the only difference necessary is to add

--enable-shared --enable-pic

to all configurations. For example this is the configuration needed for ffmpeg:

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb 
    --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libvpx 
    --enable-nonfree --enable-version3 --enable-x11grab --enable-shared --enable-pic

If you forget to do so it’s likely you get this error when compiling ffmpeg:

undefined reference to `x264_encoder_open_124'

Once ffmpeg is installed you’re ready to compile OpenCV. There is a short introduction in the official documentation on how to compile and install OpenCV.

Installation in Linux

These steps have been tested for Ubuntu 10.04 but should work with other distros.

Required packages

  • GCC 4.4.x or later. This can be installed with
    sudo apt-get install build-essential
  • CMake 2.6 or higher
  • Subversion (SVN) client
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkgconfig
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
  • [optional] libdc1394 2.x
  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev.

All the libraries above can be installed via Terminal or by using Synaptic Manager

Getting OpenCV source code

You can use the latest stable OpenCV version available in sourceforge or you can grab the latest snapshot from the SVN repository.

Getting the latest stable OpenCV version

Getting the cutting-edge OpenCV from SourceForge SVN repository

Launch SVN client and checkout either

  1. the current OpenCV snapshot from here: http://code.opencv.org/svn/opencv/trunk
  2. or the latest tested OpenCV snapshot from here: http://code.opencv.org/svn/opencv/tags/latest_tested_snapshot

In Ubuntu it can be done using the following command, e.g.:

cd ~/<my_working _directory>
svn co http://code.opencv.org/svn/opencv/trunk

Building OpenCV from source using CMake, using the command line

  1. Create a temporary directory, which we denote as <cmake_binary_dir>, where you want to put the generated Makefiles, project files as well the object filees and output binaries
  2. Enter the <cmake_binary_dir> and type
    cmake [<some optional parameters>] <path to the OpenCV source directory>

    For example

    cd ~/opencv
    mkdir release
    cd release
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
  3. Enter the created temporary directory (<cmake_binary_dir>) and proceed with:
    make
    sudo make install

Following those steps should be very easy. After running cmake a summary is printed which is important and you should pay attention to. This is the configuration summary on my system:

-- General configuration for OpenCV 2.4.0 =====================================
-- Version control:                 svn:8310M
-- 
--   Platform:
--     Host:                        Linux 3.2.0-24-generic x86_64
--     CMake:                       2.8.7
--     CMake generator:             Unix Makefiles
--     CMake build tool:            /usr/bin/make
--     Configuration:               RELEASE
-- 
--   C/C++:
--     Built as dynamic libs?:      YES
--     C++ Compiler:                /usr/bin/c++ (ver 4.6.3)
--     C++ flags (Release):         -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -O3 -DNDEBUG   -DNDEBUG
--     C++ flags (Debug):           -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     C Compiler:                  /usr/bin/gcc
--     C flags (Release):           -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
--     C flags (Debug):             -Wall -Wno-long-long -pthread -fomit-frame-pointer -msse -msse2 -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG -ggdb3
--     Linker flags (Release):      
--     Linker flags (Debug):        
-- 
--   OpenCV modules:
--     To be built:                 calib3d contrib core features2d flann gpu highgui imgproc legacy ml nonfree objdetect photo python stitching ts video videostab
--     Disabled by user:            -
--     Disabled by dependency:      -
--     Unavailable:                 androidcamera java
-- 
--   GUI: 
--     QT 4.x:                      YES (ver 4.8.1 EDITION = OpenSource)
--     QT OpenGL support:           YES (/usr/lib/x86_64-linux-gnu/libQtOpenGL.so)
--     OpenGL support:              YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so /usr/lib/libSM.so /usr/lib/x86_64-linux-gnu/libICE.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libXext.so)
-- 
--   Media I/O: 
--     ZLib:                        /usr/lib/x86_64-linux-gnu/libz.so (ver 1.2.3.4)
--     JPEG:                        /usr/lib/x86_64-linux-gnu/libjpeg.so (ver )
--     PNG:                         /usr/lib/x86_64-linux-gnu/libpng.so (ver 1.2.46)
--     TIFF:                        /usr/lib/x86_64-linux-gnu/libtiff.so (ver 42)
--     JPEG 2000:                   /usr/lib/x86_64-linux-gnu/libjasper.so (ver 1.900.1)
--     OpenEXR:                     /usr/lib/libImath.so /usr/lib/libIlmImf.so /usr/lib/libIex.so /usr/lib/libHalf.so /usr/lib/libIlmThread.so (ver 1.6.1)
--     OpenNI:                      NO
--     OpenNI PrimeSensor Modules:  NO
-- 
--   Video I/O:
--     DC1394 1.x:                  NO
--     DC1394 2.x:                  YES (ver 2.2.0)
--     GStreamer:                   
--       base:                      YES (ver 0.10.36)
--       app:                       YES (ver 0.10.36)
--       video:                     YES (ver 0.10.36)
--     UniCap:                      NO
--     UniCap ucil:                 NO
--     PvAPI:                       NO
--     V4L/V4L2:                    Using libv4l (ver 0.8.5)
--     Xine:                        NO
--     FFMPEG:                      YES
--       codec:                     YES (ver 53.7.0)
--       format:                    YES (ver 53.4.0)
--       util:                      YES (ver 51.9.1)
--       swscale:                   YES (ver 2.0.0)
--       gentoo-style:              YES
-- 
--   Other third-party libraries:
--     Use IPP:                     NO
--     Use TBB:                     YES (ver 4.0 interface 6000)
--     Use Cuda:                    NO
--     Use Eigen:                   YES (ver 2.0.17)
--     Use Clp:                     NO
-- 
--   Python:
--     Interpreter:                 /usr/bin/python (ver 2.7.3)
--     Libraries:                   /usr/lib/libpython2.7.so
--     numpy:                       /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.6.1)
--     packages path:               lib/python2.7/dist-packages
-- 
--   Documentation:
--     Build Documentation:         YES
--     Sphinx:                      /usr/local/bin/sphinx-build (ver 1.1.3)
--     PdfLaTeX compiler:           /usr/bin/pdflatex
-- 
--   Tests and samples:
--     Tests:                       YES
--     Performance tests:           YES
--     Examples:                    NO
-- 
--   Install path:                  /usr/local
-- 
--   cvconfig.h is in:              /home/shambool/code/libs/opencv_svn/build
-- -----------------------------------------------------------------

It’s a good idea to install Intel TBB if you don’t have it already, to improve the speed of some methods. As you can see in the summary my system doesn’t support CUDA and hence OpenCV couldn’t find the libraries. There are two ways to change these parameters. One is to pass the value of the parameters to cmake, and the second is to edit

opencv/CMakeLists.txt

and change the value of the parameters. I prefer the former, and have enabled the support for OpenGL and QT.

Update: there is an installation guide here that you may find useful, particularly if you don’t know what libraries are needed for OpenCV. And you can find the official documentation [url=”http://docs.opencv.org/”here[/url].

 

 

Installing OpenCV 2.2 in Ubuntu 11.04

Many people have used my previous tutorial about installing OpenCV 2.1 in Ubuntu 9.10. In the comments of that post, I noticed great interest for using OpenCV with Python and the Intel Threading Building Blocks (TBB). Since new versions of OpenCV and Ubuntu are available, I decided to create a new post with detailed instructions for installing the latest version of OpenCV, 2.2, in the latest version of Ubuntu, 11.04, with Python and TBB support.

First, you need to install many dependencies, such as support for reading and writing image files, drawing on the screen, some needed tools, etc… This step is very easy, you only need to write the following command in the Terminal

1 sudo apt-get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev

Now we need to get and compile the ffmpeg source code so that video files work properly with OpenCV. This section is partially based on the method discussed here.

1 cd ~
3 tar -xvzf ffmpeg-0.7-rc1.tar.gz
4 cd ffmpeg-0.7-rc1
5 ./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libfaac --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libxvid --enable-x11grab --enable-swscale --enable-shared
6 make
7 sudo make install

The next step is to get the OpenCV 2.2 code:

1 cd ~
3 tar -xvf OpenCV-2.2.0.tar.bz2
4 cd OpenCV-2.2.0/

Now we have to generate the Makefile by using cmake. In here we can define which parts of OpenCV we want to compile. Since we want to use Python and TBB with OpenCV, here is where we set that. Just execute the following line at the console to create the appropriate Makefile. Note that there is a dot at the end of the line, it is an argument for the cmake program and it means current directory.

1 cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON .

Check that the above command produces no error and that in particular it reports FFMPEG as 1. If this is not the case you will not be able to read or write videos. Also, check that Python reports ON and Python numpy reports YES. Also, check that under Use TBB it says YES. If anything is wrong, go back, correct the errors by maybe installing extra packages and then run cmake again. You should see something similar to this:

Now, you are ready to compile and install OpenCV 2.2:

1 make
2 sudo make install

Now you have to configure OpenCV. First, open the opencv.conf file with the following code:

1 sudo gedit /etc/ld.so.conf.d/opencv.conf

Add the following line at the end of the file(it may be an empty file, that is ok) and then save it:

1 /usr/local/lib

Run the following code to configure the library:

1 sudo ldconfig

Now you have to open another file:

1 sudo gedit /etc/bash.bashrc

Add these two lines at the end of the file and save it:

1 PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
2 export PKG_CONFIG_PATH

Finally, close the console and open a new one, restart the computer or logout and then login again. OpenCV will not work correctly until you do this.

There is a final step to configure Python with OpenCV. You need to copy the file cv.so into the correct place. You can do that by just executing the following command:

1 sudo cp /usr/local/lib/python2.7/site-packages/cv.so /usr/local/lib/python2.7/dist-packages/cv.so

Now you have OpenCV 2.2 installed in your computer with Python and TBB support.

Let’s check some demos included in OpenCV.
First, let’s see some C demos:

1 cd ~/OpenCV-2.2.0/samples/c
2 chmod +x build_all.sh
3 ./build_all.sh

Some of the training data for object detection is stored in /usr/local/share/opencv/haarcascades. You need to tell OpenCV which training data to use. I will use one of the frontal face detectors available. Let’s find a face:

1 ./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml"--scale=1.5 lena.jpg

Note the scale parameter. It allows you to increase or decrease the size of the smallest object found in the image (faces in this case). Smaller numbers allows OpenCV to find smaller faces, which may lead to increasing the number of false detections. Also, the computation time needed gets larger when searching for smaller objects.

You can also detect smaller objects that are inside larger ones. For example you can search for eyes inside any detected face. You can do that with the nested-cascade parameter:

1 ./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="/usr/local/share/opencv/haarcascades/haarcascade_eye.xml" --scale=1.5 lena.jpg


Feel free to experiment with other features like mouth or nose for example using the corresponding cascades provided in the haarcascades directory.

Now let’s check some C++ demos:

1 cd ~/OpenCV-2.2.0/samples/cpp
2 make

Now all the C++ demos are built in ~/OpenCV-2.2.0/bin. Let’s see a couple of them. For example, a simulated chessboard calibration:

1 ~/OpenCV-2.2.0/bin/calibration_artificial


In OpenCV 2.2, the grabcut algorithm is provided as a C++ sample. This is a very nice segmentation algorithm that needs very little user input to segment the objects in the image. For using the demo, you need to select a rectangle of the area you want to segment. Then, hold the Control key and left click to select the background (in Blue). After that, hold the Shift key and left click to select the foreground (in Red). Then press the n key to generate the segmentation. You can press n again to continue to the next iteration of the algorithm.

1 ~/OpenCV-2.2.0/bin/grabcut ~/OpenCV-2.2.0/samples/cpp/lena.jpg

This image shows the initial rectangle for defining the object that I want to segment.

Now I roughly set the foreground (red) and background (blue).

When you are ready, press the n key to run the grabcut algorithm. This image shows the result of the first iteration of the algorithm.

Now let’s see some background subtraction from a video. The original video shows a hand moving in front of some trees. OpenCV allows you to separate the foreground (hand) from the background (trees).

1 ~/OpenCV-2.2.0/bin/bgfg_segm ~/OpenCV-2.2.0/samples/c/tree.avi

And finally, let’s see Python working with OpenCV:

1 cd ~/OpenCV-2.2.0/samples/python/

Let’s run the kmeans.py example. This script starts with randomly generated 2D points and then uses a clustering method called k-means. Each cluster is presented in a different color.

1 python kmeans.py

Now let’s see the convexhull.py demo. This algorithm basically calculates the smallest convex polygon that encompasses the data points.

1 python convexhull.py

Python scripts can also be executed directly like the following example. This script reads a video file (../c/tree.avi) within pyhton and shows the first frame on screen:

1 ./minidemo.py


Have fun with OpenCV in C, C++ or Python…

Filed under: Linux No Comments
15Jun/12

Ubuntu VPS的中文和中文乱码问题解决

Posted by Nick Xu

我们的Ubuntu vps缺省是英文环境,如果要想在Ubuntu VPS下面能显示,输入中文,必须要做一番设置。

方法一:

首先,如果用putty进行SSH登录到Ubuntu VPS上,要先保证putty支持中文,请参考:putty的常见配置

重要的还是Ubuntu VPS的中文配置:

创建文件/var/lib/locales/supported.d/zh,内容为:

zh_CN.UTF-8 UTF-8
zh_CN.GBK GBK

运行locale-gen产生中文的locale,然后修改文件/etc/environment其中的LANG部分为:

LANG="zh_CN.UTF-8"

然后重启VPS,重启后就可以正常显示和输入中文了

方法二:

1.查看当前系统语言环境

locale

2.查看系统内安装的locale

root@ubuntu-vps:~# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX

3.安装zh_CN.utf8

root@ubuntu-vps:~# cd /usr/share/locales
root@ubuntu-vps:/usr/share/locales# ls
install-language-pack  remove-language-pack
root@ubuntu-vps:/usr/share/locales# ./install-language-pack zh_CN
Generating locales...
zh_CN.UTF-8... done
Generation complete.
dpkg-trigger: dpkg-trigger 必须从维护者脚本中调用(或者通过 --by-package 选项)

4.验证locale安装是否成功

root@ubuntu-vps:/usr/share/locales# locale
LANG=zh_CN.utf8
LC_CTYPE="zh_CN.utf8"
LC_NUMERIC="zh_CN.utf8"
LC_TIME="zh_CN.utf8"
LC_COLLATE="zh_CN.utf8"
LC_MONETARY="zh_CN.utf8"
LC_MESSAGES="zh_CN.utf8"
LC_PAPER="zh_CN.utf8"
LC_NAME="zh_CN.utf8"
LC_ADDRESS="zh_CN.utf8"
LC_TELEPHONE="zh_CN.utf8"
LC_MEASUREMENT="zh_CN.utf8"
LC_IDENTIFICATION="zh_CN.utf8"
LC_ALL=

 

解决中文乱码:

1、转换文件内容编码

Windows下生成的纯文本文件,其中文编码为GBK,在Ubuntu下显示为乱码,可以使用iconv命令进行转换:

iconv -f gbk -t utf8 source_file > target_file

2、转换文件名编码

Windows下压缩的zip文件,在 Ubuntu下解开时,中文文件名会显示乱码,可以用convmv解决。

安装convmv:

sudo apt-get install convmv

转换文件或目录:

convmv -f gbk -t utf8 -r –notest *

3、解压zip文件乱码

在Ubuntu下使用unzip解压Widnows环境下生成的zip文件,会发生文件名或者目录名乱码现象,解决办法是使用 7-zip和convmv。

安装7-zip和convmv:

sudo apt-get install convmv p7zip-full

解压zip文件:

LANG=C 7z e zip_file

convmv -f gbk -t utf8 -r –notest *

4、解压rar文件乱码

在ubuntu下解压Windows环境下生成的rar文件,同样会碰到中文乱码问题,例如使用7z来解压。

解决办法是使用unrar来解压。

安装unrar:

sudo apt-get install unrar

5、pdf中文乱码

PDF文件中的中文显示出乱码的情况下,可以安装poppler-data来解决:

sudo apt-get install poppler-data

参照:

http://rashost.com/blog/ubuntu-chinese-locale(Ubuntu VPS的中文设置)

http://blog.rebill.info/archives/ubuntu-set-zh_CN-utf8-locale.html(Ubuntu下设置中文locale)

http://www.awz.cn/i/computer/linux/read-46.html(使用ubuntu 10.04中的中文乱码问题解决)

Filed under: Linux No Comments
13Jun/12

redhat下mysql集群的安装与配置

Posted by Nick Xu

我是在虚拟机上测试的,三台机子分别为:

192.168.2.100,管理节点。

192.168.2.101,数据节点和SQL节点。

192.168.2.102,数据节点和SQL节点。

装的系统是:Red Hat Enterprise Linux 4。

软件包是:mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz。

安装步骤

1.管理节点的安装
#groupadd mysql
#useradd mysql -g mysql
#mv mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz /usr/local/
#cd /usr/local/
#tar zxvf mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz
#rm -f mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz
#mv mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23 mysql
#chown -R mysql:mysql mysql
#cd mysql
#scripts/mysql_install_db --user=mysql

2.管理节点的配置
#mkdir /var/lib/mysql-cluster
#cd /var/lib/mysql-cluster
#vi config.ini                //这里需要手动添加如下内容
[ndbd default]
NoOfReplicas=2
DataMemory=80M
IndexMemory=18M
[ndb_mgmd]
Id=1
Hostname=192.168.2.100
datadir=/usr/local/mysql/logs
[ndbd]
Id=2
Hostname=192.168.2.101
datadir=/usr/local/mysql/data/

[ndbd]
Id=3
Hostname=192.168.2.102
datadir=/usr/local/mysql/data/
[MYSQLD]
[MYSQLD]

 

3.安装和配置数据节点

这里2台机器数据节点安装是相同的.

#groupadd mysql
#useradd mysql -g mysql
#mv mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz /usr/local/
#cd /usr/local/
#tar zxvf mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz
#rm -f mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23.tar.gz
#mv mysql-cluster-gpl-7.1.2a-beta-linux-i686-glibc23 mysql
#chown -R mysql:mysql mysql
#cd mysql
#scripts/mysql_install_db --user=mysql
#cp support-files/my-medium.cnf /etc/my.cnf
#cp support-files/mysql.server /etc/init.d/mysqld
#vi /etc/my.cnf         //这里需要手动添加如下的内容
 [mysqld]
datadir=/usr/local/mysql/data/       //这里要与管理节点的 config.ini相同
ndbcluster
ndb-connectstring=192.168.2.100
[ndbd]
connect-string=192.168.2.100
[mysql_cluster]
ndb-connectstring=192.168.2.100
[ndb_mgm]
connect-string=192.168.2.100
[ndb_mgmd]
config-file=/var/lib/mysql-cluster/config.ini  //这里要指定管理节点配置文件路径

 
4.启动相关服务

在管理节点启动相关服务:
#/usr/local/mysql/bin/ndb_mgmd -f /var/lib/mysql-cluster/config.ini
#netstat -lntpu
tcp        0      0 0.0.0.0:1186                0.0.0.0:*                   LISTEN      7797/ndb_mgmd

看到1186端口开放了说明启动是正常的.

在数据节点启动相关服务:
#/usr/local/mysql/bin/ndbd --initial
#netstat -lntpu
tcp        0      0 192.168.2.101:32772         0.0.0.0:*                   LISTEN      3392/ndbd
tcp        0      0 192.168.2.101:32773         0.0.0.0:*                   LISTEN      3392/ndbd
tcp        0      0 192.168.2.101:32774         0.0.0.0:*                   LISTEN      3392/ndbd

#service mysqld start
#netstat -lntpu
tcp        0      0 :::3306                     :::*                        LISTEN      3557/mysqld

可以看到相关的ndbd服务以及mysql已经启动ok了.

Filed under: Linux No Comments
13Jun/12

RedHat RHEL 6.1安装gcc的方法

Posted by Nick Xu

RHEL 6.1默认是没有gcc和gcc-c++环境的,而且我也没有$购买正版服务。

只能想办法本地安装了,总结方法如下:

上传安装镜像rhel-server-6.1-x86_64-dvd.iso,

然后将镜像文件挂,如/mnt

# mount -o loop rhel-server-6.1-x86_64-dvd.iso /mnt

# cd /mnt/Packages

# rpm -ivh glibc-common-2.12-1.25.el6.x86_64.rpm

# rpm -ivh kernel-headers-2.6.32-131.0.15.el6.x86_64.rpm

# rpm -ivh libgcc-4.4.5-6.el6.x86_64.rpm

# rpm -ivh glibc-2.12-1.25.el6.x86_64.rpm

# rpm -ivh libgomp-4.4.5-6.el6.x86_64.rpm

# rpm -ivh nscd-2.12-1.25.el6.x86_64.rpm

# rpm -ivh glibc-headers-2.12-1.25.el6.x86_64.rpm

# rpm -ivh glibc-devel-2.12-1.25.el6.x86_64.rpm

# rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm

# rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm

# rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm

# rpm -ivh cpp-4.4.5-6.el6.x86_64.rpm

# rpm -ivh gcc-4.4.5-6.el6.x86_64.rpm

注:以上是安装gcc,软件安装顺序不能错。
******************************************
# rpm -ivh libstdc++-4.4.5-6.el6.x86_64.rpm

# rpm -ivh libstdc++-devel-4.4.5-6.el6.x86_64.rpm

# rpm -ivh gcc-c++-4.4.5-6.el6.x86_64.rpm

注:以上是安装gcc-c++

Filed under: Linux No Comments
13Jun/12

redhat 网络设置

Posted by Nick Xu

用[]表示用户自己填写

Ip配置:

临时-shell:ifconfig  eth0  [ipaddr]  netmask [netmaskn]

---------------------------------------------------------------------------

永久-配置文件:  /etc/sysconfig/network-scripts/ifcfg-eth0

动态ip:

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=dhcp

HWADDR=[mac]

静态ip:

DEVICE=eth0

ONBOOT=yes

BOOTPROTO=static

IPADDR=[一个合适你的ip]

NETMASK=[根据你的ip填写]

 

注意:如果你的配置文件改了,需要重启响应的硬件,这里的话,是网卡,service network restart

 

--------------------------------------------------------------------------------------------------------------------------------------

网关:/etc/sysconfig/network

NETWORKING=yes                 /*IPv4*/

NETWORKING_IPV6=no

HOSTNAME=[你的主机名]

 

GATEWAY=[你的网关]                      /*静态ip的时候一定要设置这里才可以访问外网的哦~*/

 

--------------------------------------------------------------------------------------------------------------------------------------

Dns: /etc/resolv.conf

 

Nameserver [你的域名服务器,比如218.30.19.40]

--------------------------------------------------------------------------------------------------------------------------------------

检测你的本机网络

Ping

1、    与网关:ping [your gateway]

2、    与外网交互,比如下载一个东西:

 

wget http://www.qq.com/

 

--------------------------------------------------------------------------------------------------------------------------------------

一个机子绑定多个ip

Shell下:

ifconfig eth0:0  [ipaddr] netmask [子网掩码] up

ifconfig eth0:1  [ipaddr] netmask [子网掩码] up

去掉一个:

ifconfig eth0:1 down

 

--------------------------------------------------------------------------------------------------------------------------------------

route:

查看路由信息: route –n

 

redhat 网络设置 - yinzhezq - yinzhezq的博客

 

 

设置默认网关: route add default gw [ipaddr]

添加一个静态路由:route add –net [netaddr] netmask [掩码] gw [ipaddr]  [eth0]

/*netaddr 为上图destination*/

删除一个静态路由:route del –net [netaddr] netmask [掩码] gw [ipaddr] [eth0]

Filed under: Linux No Comments
7Jun/12

在Eclipse Indigo安装UML2 Tools

Posted by Nick Xu

UML2 Tools 是Eclipse的一个用于支持画UML2图的重要插件,可是如果你用的是Hellios或者Indigo版本的Eclipse,会发现无法安装下载的 UML2 Tools SDK,提示错误一般是找不到包括org.eclipse.emf.ocl feature在内的dependency。

原因是:从Hellios开始,这个feature就不再被Eclipse支持,虽然仍然有不少plugin依赖这个feature,比如这个UML2 Tools SDK。

在UML2 Tools取消这个依赖之前,如果想使用它,唯一的办法就是临时装上org.eclipse.emf.ocl这个feature,步骤如下。

1、从https://bugs.eclipse.org/bugs/attachment.cgi?id=173482 下载rog.eclipse.emf.ocl-update.zip。

2、在Eclipse的Help -> Install New Software安装这个功能。

3、从http://www.eclipse.org/modeling/mdt/downloads/?project=uml2tools 下载最新的UML2 tools SDK zip文件。

4、同样在Eclipse的Help -> Install New Software安装这个功能。

这次就不会遇到cannot resolve dependency的问题了。

 

安装结束,重启Eclipse,在创建新的项目中就出现了UML 2.1 Diagrams

 

这里有一个简单的UML Tools Tutorial

Tagged as: , No Comments
5Jun/12

mysql cluster 7 动态增加数据节点配置步骤

Posted by Nick Xu

vi /usr/local/mysql/mysql-cluster/config.ini

[ndbd default]

DataMemory =100M

IndexMemory =100M

NoOfReplicas = 2

DataDir = /usr/local/mysql/var/mysql-cluster

[ndbd]

Id = 1

HostName = 172.20.86.188

 

[ndbd]

Id = 2

HostName = 172.20.86.189

 

[mgm]

HostName = 172.20.86.185

Id = 10

 

[mysqld]

Id=20

HostName = 172.20.86.185

 

2在185上运行ndb_mgm

Ndb_mgm>show

-- NDB Cluster -- Management Client --
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(s)
id=1   @172.20.86.188 (5.1.32-ndb-7.0.5, Nodegroup: 0, Master)
id=2   @172.20.86.189 (5.1.32-ndb-7.0.5, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)

[mysqld(API)]  2 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)

 

 

Step 1: Update configuration file

 

[ndbd default]
DataMemory =100M
IndexMemory =100M
NoOfReplicas = 2
DataDir = /usr/local/mysql/var/mysql-cluster

[ndbd]
Id = 1
HostName = 172.20.86.188

[ndbd]
Id = 2
HostName = 172.20.86.189

[ndbd]
Id = 3
HostName=172.20.86.187
 
[ndbd]
Id = 4
HostName=172.20.86.186

[mgm]
HostName = 172.20.86.185
Id = 10

[mysqld]
Id=20
HostName = 172.20.86.185

 

 

Step 2: Restart the management server

Step 2.1停止管理节点

ndb_mgm>10 STOP
Node 10 has shut down.
Disconnecting to allow Management Server to shutdown
shell>

Step 2.2重新加载配置文件

shell>ndb_mgmd -f config.ini --reload
2008-12-08 17:29:23 [MgmSrvr] INFO    -- NDB Cluster Management Server.5.1.34-ndb-7.0.7
2008-12-08 17:29:23 [MgmSrvr] INFO    --Readingcluster configuration from 'config.ini'

Step 2.3查看新集群状态

-- NDB Cluster -- Management Client --
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(s)
id=1   @172.20.86.188 (5.1.32-ndb-7.0.5, Nodegroup: 0, Master)
id=2   @172.20.86.189 (5.1.32-ndb-7.0.5, Nodegroup: 0)
id=3 (not connected, accepting connect from 172.20.86.186)
id=4 (not connected, accepting connect from 172.20.86.187)

[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)

[mysqld(API)]  1 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)

 

Step 3: Perform. a rolling restart of the existing data nodes –轮流重新启动连接的数据节点

ndb_mgm>1 RESTART
Node 1: Node shutdown initiated
Node 1: Node shutdown completed, restarting, no start.
Node 1 is being restarted

ndb_mgm> Node 1: Start initiated (version7.0.5)
Node 1: Started (version7.0.5)

ndb_mgm>2 RESTART
Node 2: Node shutdown initiated
Node 2: Node shutdown completed, restarting, no start.
Node 2 is being restarted

 

Step 4: Perform. a rolling restart of all cluster API nodes –轮流重启sql节点

本案仅有一个sql节点

shell>mysqladmin -uroot -ppasswordshutdown
shell>mysqld_safe &

 

Step 5: Perform. an initial start of the new data nodes –初始化新的数据节点

 

在新增的数据节点上186和187上执行

Shell>ndbmtd –initial

或者

Shell>ndbd –initial

登陆管理节点查看集群状态

Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(s)
id=1   @172.20.86.188 (5.1.32-ndb-7.0.5, Nodegroup: 0, Master)
id=2   @172.20.86.189 (5.1.32-ndb-7.0.5, Nodegroup: 0)
id=3   @172.20.86.186 (5.1.32-ndb-7.0.5,no nodegroup)
id=4   @172.20.86.187 (5.1.32-ndb-7.0.5,no nodegroup)

[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)

[mysqld(API)]  2 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)

Step 6: Create a new node group.

ndb_mgm>CREATE NODEGROUP 3,4
Nodegroup 1 created
 
ndb_mgm>SHOW
Connected to Management Server at: 172.20.86.185:1186
Cluster Configuration
---------------------
[ndbd(NDB)]    2 node(s)
id=1   @172.20.86.188 (5.1.32-ndb-7.0.5, Nodegroup: 0, Master)
id=2   @172.20.86.189 (5.1.32-ndb-7.0.5, Nodegroup: 0)
id=3   @172.20.86.186 (5.1.32-ndb-7.0.5,Nodegroup: 1)
id=4   @172.20.86.187 (5.1.32-ndb-7.0.5,Nodegroup: 1)

[ndb_mgmd(MGM)] 1 node(s)
id=10  @172.20.86.185 (5.1.32-ndb-7.0.5)

[mysqld(API)]  1 node(s)
id=20  @172.20.86.185 (5.1.32-ndb-7.0.5)

Step 7: Redistribute cluster data. –数据的重新分配

 

对于新增的数据节点一些访问量较高的数据和比较重要的数据需要从新分配。

 

分发数据命令:

Alter online table ips reorganize partition;

查看数据的分配情况:

ndb_mgm>ALL REPORT MEMORY

Node 1: Data usage is 5%(177 32K pages of total 3200)
Node 1: Index usage is 0%(108 8K pages of total 12832)
Node 2: Data usage is 5%(177 32K pages of total 3200)
Node 2: Index usage is 0%(108 8K pages of total 12832)
Node 3: Data usage is 0%(0 32K pages of total 3200)
Node 3: Index usage is 0%(0 8K pages of total 12832)
Node 4: Data usage is 0%(0 32K pages of total 3200)
Node 4: Index usage is 0%(0 8K pages of total 12832)

或者

shell>ndb_desc -c 192.168.0.10 -d n ips -p
-- ips --
Version: 1
Fragment type: 9
K Value: 6
Min load factor: 78
Max load factor: 80
Temporary table: no
Number of attributes: 6
Number of primary keys: 1
Length of frm data: 340
Row Checksum: 1
Row GCI: 1
SingleUserMode: 0
ForceVarPart: 1
FragmentCount: 2
TableStatus: Retrieved
-- Attributes --
id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
country_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
type Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
ip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
addresses Bigunsigned NULL AT=FIXED ST=MEMORY
date Bigunsigned NULL AT=FIXED ST=MEMORY

-- Indexes --
PRIMARY KEY(id) - UniqueHashIndex
PRIMARY(id) - OrderedIndex

-- Per partition info --
Partition  Row count  Commit count Frag fixed memory  Frag varsized memory
0          26086      26086        1572864            557056
1          26329      26329        1605632            557056

NDBT_ProgramExit: 0 - OK

You can cause the data to be redistributed among all of the data nodes by performing, for eachNDBCLUSTERtable, anALTER ONLINE TABLE ... REORGANIZE PARTITIONstatement in themysqlclient. After issuing the statementALTER ONLINE TABLE ips REORGANIZE PARTITION, you can see usingndb_descthat the data for this table is now stored using 4 partitions, as shown here (with the relevant portions of the output in bold type):

shell>ndb_desc -c 172.20.86.185 -d n ips -p
-- ips --
Version: 16777217
Fragment type: 9
K Value: 6
Min load factor: 78
Max load factor: 80
Temporary table: no
Number of attributes: 6
Number of primary keys: 1
Length of frm data: 341
Row Checksum: 1
Row GCI: 1
SingleUserMode: 0
ForceVarPart: 1
FragmentCount: 4
TableStatus: Retrieved
-- Attributes --
id Bigint PRIMARY KEY DISTRIBUTION KEY AT=FIXED ST=MEMORY AUTO_INCR
country_code Char(2;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
type Char(4;latin1_swedish_ci) NOT NULL AT=FIXED ST=MEMORY
ip_address Varchar(15;latin1_swedish_ci) NOT NULL AT=SHORT_VAR ST=MEMORY
addresses Bigunsigned NULL AT=FIXED ST=MEMORY
date Bigunsigned NULL AT=FIXED ST=MEMORY

-- Indexes --
PRIMARY KEY(id) - UniqueHashIndex
PRIMARY(id) - OrderedIndex

-- Per partition info --
Partition  Row count  Commit count Frag fixed memory  Frag varsized memory
0          12981      52296        1572864            557056
1          13236      52515        1605632            557056
2          13105      13105        819200             294912
3          13093      13093        819200             294912
Tagged as: , No Comments
4Jun/12

在同一台主机配置MySQL Cluster

Posted by Nick Xu

MySQL cluster是share nothing的集群,采用ndb存储引擎,和Oracle的RAC采用集中存储不同,是一种分布式的架构,所以可以很轻松的实现在同一台主机上配置MySQL Cluster,相对RAC来说要简单得多。

在MySQL Cluster中,有三种不同的节点:

  • 管理节点:守护进程为ndb_mgmd,用于管理cluster。
  • 数据节点: 守护进程为ndbd,用于存放数据
  • SQL节点:守护进程为mysqld,就是一个MySQL实例,对外供客户端连接访问数据。

本文将在一台64位linux主机上同时配置上述三种节点。在实际生产环境中,根据需要,可以在相同或者不同的机器部署节点。本次实例中共包含以下节点:

  • 一个管理节点
  • 两个数据节点
  • 三个SQL节点

下载Mysql cluster,当前版本7.0.6,http://dev.mysql.com/downloads/cluster/7.0.html

解压,并复制到安装目录

tar zxvf mysql-cluster-gpl-7.0.6-linux-x86_64-glibc23.tar.gz
cp mysql-cluster-gpl-7.0.6-linux-x86_64-glibc23 /u01/mysql-cluster

cd /u01/mysql-cluster

创建三个MySQL实例的数据目录

mkdir data/data1
mkdir data/data2
mkdir data/data3

mkdir data/data1/mysql
mkdir data/data1/test

mkdir data/data2/mysql
mkdir data/data2/test

mkdir data/data3/mysql
mkdir data/data3/test

Cluster配置文件如下

$ more conf/config.ini
[ndbd default]
noofreplicas=2
[ndbd]
hostname=localhost
id=2
[ndbd]
hostname=localhost
id=3
[ndb_mgmd]
id = 1
hostname=localhost
[mysqld]
id=4
hostname=localhost
[mysqld]
id=5
hostname=localhost
[mysqld]
id=6
hostname=localhost

三个MySQL实例配置文件如下

$ more conf/my1.cnf
[mysqld]
ndb-nodeid=4
ndbcluster=true
datadir=/u01/mysql-cluster/data/data1
basedir=/u01/mysql-cluster
port=9306
server-id=1
log-bin

$ more conf/my2.cnf
[mysqld]
ndb-nodeid=5
ndbcluster=true
datadir=/u01/mysql-cluster/data/data2
basedir=/u01/mysql-cluster
port=9307
server-id=2
log-bin

$ more conf/my3.cnf
[mysqld]
ndb-nodeid=6
ndbcluster=true
datadir=/u01/mysql-cluster/data/data3
basedir=/u01/mysql-cluster
port=9308
server-id=3
log-bin

初始化三个MySQL实例

script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data1
script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data2
script/mysql_install_db --basedir=/u01/mysql-cluster --datadir=/u01/mysql-cluster/data/data3

初始化管理节点

bin/ndb_mgmd --initial -f conf/config.ini --configdir=/u01/mysql-cluster

进入管理节点查看配置

$ bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> help
---------------------------------------------------------------------------
 NDB Cluster -- Management Client -- Help
---------------------------------------------------------------------------
HELP                                   Print help text
HELP COMMAND                           Print detailed help for COMMAND(e.g. SHOW)
SHOW                                   Print information about cluster
CREATE NODEGROUP ,...          Add a Nodegroup containing nodes
DROP NODEGROUP                     Drop nodegroup with id NG
START BACKUP [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
START BACKUP [] [SNAPSHOTSTART | SNAPSHOTEND] [NOWAIT | WAIT STARTED | WAIT COMPLETED]
                                       Start backup (default WAIT COMPLETED,SNAPSHOTEND)
ABORT BACKUP                Abort backup
SHUTDOWN                               Shutdown all processes in cluster
CLUSTERLOG ON [] ...         Enable Clus
 = ALERT | CRITICAL | ERROR | WARNING | INFO | DEBUG
 = STARTUP | SHUTDOWN | STATISTICS | CHECKPOINT | NODERESTART | CONNECTION
| INFO | ERROR | CONGESTION | DEBUG | BACKUP
    = 0 - 15
       = ALL | Any database node id

For detailed help on COMMAND, use HELP COMMAND.

ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2 (not connected, accepting connect from localhost)
id=3 (not connected, accepting connect from localhost)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @localhost  (mysql-5.1.34 ndb-7.0.6)

[mysqld(API)]   3 node(s)
id=4 (not connected, accepting connect from localhost)
id=5 (not connected, accepting connect from localhost)
id=6 (not connected, accepting connect from localhost)

初始化数据节点

bin/ndbd --initial -c localhost:1186
2009-06-21 23:13:19 [ndbd] INFO     -- Configuration fetched from 'localhost:1186', generation: 1
bin/ndbd --initial -c localhost:1186
2009-06-21 23:13:50 [ndbd] INFO     -- Configuration fetched from 'localhost:1186', generation: 1

启动SQL节点

bin/mysqld --defaults-file=conf/my1.cnf&
[1] 17843
 090621 23:14:36 [Warning] No argument was provided to --log-bin,
and --log-bin-index was not used; so replication may break when this MySQL server acts as a master
and has his hostname changed!! Please use '--log-bin=test-bin' to avoid this problem.
InnoDB: The first specified data file ./ibdata1 did not exist:
InnoDB: a new database to be created!
090621 23:14:36  InnoDB: Setting file ./ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
090621 23:14:36  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
090621 23:14:36  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
InnoDB: Setting log file ./ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
090621 23:14:36  InnoDB: Started; log sequence number 0 0
090621 23:14:36 [Note] NDB: NodeID is 4, management server 'localhost:1186'
090621 23:14:37 [Note] NDB[0]: NodeID: 4, all storage nodes connected
090621 23:14:37 [Note] Starting Cluster Binlog Thread
090621 23:14:37 [Note] Event Scheduler: Loaded 0 events
090621 23:14:37 [Note] bin/mysqld: ready for connections.
Version: '5.1.34-ndb-7.0.6-cluster-gpl-log'  socket: '/tmp/mysql.sock'
port: 9306  MySQL Cluster Server (GPL)
090621 23:14:38 [Note] NDB Binlog: Ndb tables initially read only.
090621 23:14:38 [Note] NDB: Creating mysql.ndb_schema
090621 23:14:38 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_schema
090621 23:14:38 [Note] NDB Binlog: logging ./mysql/ndb_schema (UPDATED,USE_WRITE)
090621 23:14:38 [Note] NDB: Creating mysql.ndb_apply_status
090621 23:14:39 [Note] NDB Binlog: CREATE TABLE Event: REPL$mysql/ndb_apply_status
090621 23:14:39 [Note] NDB Binlog: logging ./mysql/ndb_apply_status (UPDATED,USE_WRITE)
2009-06-21 23:14:39 [NdbApi] INFO     -- Flushing incomplete GCI:s < 20/3
2009-06-21 23:14:39 [NdbApi] INFO     -- Flushing incomplete GCI:s < 20/3
090621 23:14:39 [Note] NDB Binlog: starting log at epoch 20/3
090621 23:14:39 [Note] NDB Binlog: ndb tables writable
bin/mysqld --defaults-file=conf/my2.cnf&
bin/mysqld --defaults-file=conf/my3.cnf&

查看cluster

bin/ndb_mgm
-- NDB Cluster -- Management Client --
ndb_mgm> show
Connected to Management Server at: localhost:1186
Cluster Configuration
---------------------
[ndbd(NDB)]     2 node(s)
id=2    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0, Master)
id=3    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6, Nodegroup: 0)

[ndb_mgmd(MGM)] 1 node(s)
id=1    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6)

[mysqld(API)]   3 node(s)
id=4    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6)
id=5    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6)
id=6    @127.0.0.1  (mysql-5.1.34 ndb-7.0.6)

创建测试表

bin/mysql -uroot -h localhost -P 9306  --socket=/tmp/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2
Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

root@(none) 11:21:24>use test
Database changed
root@test 11:21:26>create table test_ndb(i int,a varchar(20),primary key(i)) engine=ndb;
090621 23:22:32 [Note] NDB Binlog: CREATE TABLE Event: REPL$test/test_ndb
090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)
090621 23:22:32 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/test_ndb
090621 23:22:32 [Note] NDB Binlog: DISCOVER TABLE Event: REPL$test/test_ndb
090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)
090621 23:22:32 [Note] NDB Binlog: logging ./test/test_ndb (UPDATED,USE_WRITE)
Query OK, 0 rows affected (1.10 sec)

root@test 11:22:32>insert into test_ndb values(1,'NinGoo');
Query OK, 1 row affected (0.02 sec)

[mysql@dbconsole mysql-cluster]$ ls -l data/data1/test
total 12
-rw-rw----  1 mysql dba 8578 Jun 21 23:22 test_ndb.frm
-rw-rw----  1 mysql dba    0 Jun 21 23:22 test_ndb.ndb
[mysql@dbconsole mysql-cluster]$ ls -l data/data2/test
total 12
-rw-rw----  1 mysql dba 8578 Jun 21 23:22 test_ndb.frm
-rw-rw----  1 mysql dba    0 Jun 21 23:22 test_ndb.ndb
[mysql@dbconsole mysql-cluster]$ ls -l data/data3/test
total 12
-rw-rw----  1 mysql dba 8578 Jun 21 23:22 test_ndb.frm
-rw-rw----  1 mysql dba    0 Jun 21 23:22 test_ndb.ndb

$ bin/mysql -uroot -P 9307 --socket=/tmp/mysql.sock
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.1.34-ndb-7.0.6-cluster-gpl-log MySQL Cluster Server (GPL)

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

root@(none) 11:24:38>use test
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
root@test 11:24:41>select * from test_ndb;
+---+--------+
| i | a      |
+---+--------+
| 1 | NinGoo |
+---+--------+
1 row in set (0.02 sec)

无觅相关文章插件,快速提升流量

Tagged as: , , No Comments
   
site
site