新闻组上看到的mysql cluster安装过程

如下:

 I have recently had success setting up a MySQL Cluster, so I
thought I’d share what I did with everyone since it was such a challenge
for me to do and the documentation for how to set it up is so poor.
 

[@more@] 

######################### My Setup ####################################

Here is my setup:

I have two machines, Machine A and Machine B, that have requests and
updates to the db balanced by a router.  There is one IP address that
clients use to access the db.  The router distributes 50% of the
requests to Machine A and the remaining 50% to Machine B.  Therefore,
the db on both Machine A and Machine B must be exactly the same at all
times.  To achieve this I used MySQL Cluster.

 

I am running Redhat Linux 9 on both machines, and the machines are
physically identical.

 

Machine A ip = 10.0.2.39

Machine B ip = 10.0.2.38

########################### Installing ################################ 

I did the following on both machines:

 

- I installed MySql-Max (Linux (x86, glibc-2.2, static, gcc) 4.1.7 

http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-4.1.7-pc-linux-i6
86.tar.gz/from/pick

 

- I extracted the tar file into the root folder, and installed the mysql
db by running the mysql_install_db script in the scripts directory.  (In
the mysql directory type-  ./scripts/mysql_install_db)

 

- I then created a config.ini file which I placed in the mysql
directory.  I also created a my.cnf file which I placed in the
mysql/data directory.

################### Config.ini #######################################

 [NDBD DEFAULT]

NoOfReplicas= 2

 

[MYSQLD DEFAULT]

[NDB_MGMD DEFAULT]

[TCP DEFAULT]

 

[NDB_MGMD]

HostName= 10.0.2.39      (10.0.2.38 on machine B)

 

[NDBD]

HostName= 10.0.2.38

DataDir= /root/mysql/data

 

[NDBD]

HostName= 10.0.2.39

DataDir= /root/mysql/data

 

[MYSQLD]

[MYSQLD]

[MYSQLD]

###################### My.cnf ########################## 

The my.cnf file on both machines is:

[mysqld]

ndbcluster

###################### Starting the cluster ############# 

To start the cluster I did the following:

(please note that MySQL is installed in the /root/mysql directory)

 

Machine A:

- opened a terminal.

- typed-   cd mysql

- typed-   ./bin/ndb_mgmd

       - starts the cluster manager

- typed-   ./bin/ndbd --initial

       - please note, only use the '--initial' parameter if it is the

        first time you are starting the node.  

- typed- ./bin/mysqld_safe --user=root &

       - starts mysql.  The terminal may stick here so use ctrl-c to get

         a new prompt.

- typed- ./bin/mysql

       - starts the mysql monitor.

- typed-  use test;

       - to use the test database.

 

Machine B:

- follow the same steps as Machine A:

###################### Testing the cluster ############# 

On Machine A:

- at the mysql monitor prompt

- type-  use test;

      - to use the test database.

- type-  create table cluster_test (i int) engine=ndbcluster;

      - this should create a clustered table called cluster_test.

 

On Machine B:

- at the mysql monitor prompt

- type-  use test;

- type-  show tables;

      -  this should show the cluster_test table created on Machine A.

 

Inserting

Subsequent inserts etc. can be done at the mysql monitor prompt.

Example:

On Machine A:

-        type- insert into cluster_test values(314159);

 

On Machine B:

-        type- select * from cluster_test;

    - should display the value 314159.

##########################################################

ERROR 1114: The table ‘big_table_a’ is full

在新闻组上看到的关于mysql cluster的问题:

[@more@]

At us is 1 MGM node and 4 DB nodes! 
Each of 5 computers have 1Gb operative memory! 
We have created 3 SQL a file (everyone on 900Mb) 
each of which has consisted of 10 000 000 lines 

insert into big_table_a set a1='213123', a2='123123', a3='213124', 
a4='234234';
insert into big_table_a set a1='213123', a2='978433', a3='234234', 
a4='2535623';
............................

Through API node we have started this SQL a script with the help of a 
command 

source data1.sql;
source data2.sql;
source data3.sql;

When in a database already has entered the name more than 
14 000 000 lines MySQL Cluster has given out the following mistake: 

ERROR 1114: The table 'big_table_a' is full

回复:

If your big_table has a primary key it will be using up your index_memory in
a short time.
Also, you may want to disconnect/reconnect while inserting all the data.
To understand what your memory is used for you should read:
http://dev.mysql.com/doc/mysql/en/MySQL_Cluster_DB_Definition.html
(datamemory and index memory part). 

Generally 1gig of memory is not a lot. I have the same setup but with 2gigs
of ram in each machine and I have experienced the same problems.

What datatypes are the columns in your table?
You can calculate the amount of memory that your table takes up and find out
if you have enough space.

升级到php5的日记 一

终于要从php4升级到php5了,是的,俺费尽了口舌,说服了boss使用php5和mysqli开发新项目.

首先俺细细的阅读了官方站点上介绍php5的有关章节,以及网络上的一些关于php5的文章.基本开发环境定为linux+apache2+php5+mysql4.1,很经典的搭配.为了提高开发效率,俺决定继续使用pear的类库和prado,因此现状是php4,php5的代码将并存.第一周俺们就遇到了麻烦:

1.mysqli和zend1的兼容性
php.ini里面有一个选项,可以开启对zend1的兼容性,如果你在打开这个开关的同时还想使用mysqli的话,很快就会失望.它会无情的告诉你:
unable clone a uncloneable object…………………

2.使用prado和php5的一些问题
prado程序包prado.php的有段代码如下:
set_error_handler( …….. );
php5的配置默认是不提示E_STRICT级别的错误,要命的是,这行代码对任何错误都会die(………………..),pear的代码完全没办法工作,只好咔嚓之

使用Pear::Pager类的一个问题

今天把公司的服务器从php4升级到php5,问题来了.最严重的是使用Pear::Pager类,报错如下:
Fatal error: Cannot re-assign $this in D:xampphtdocstmptest.php on line 5

看了下Pager类的构造,有如下代码:
$this = ……………..;

看来从php5开始不再支持这种对自身重新实例化的写法了,只好重写了Pager类草草收场

[@more@]

mysql cluster安装笔记

经过两天的配置安装翻阅文档,终于成功的配置了两台装有mysql的机器为cluster,总结要点如下:

1.db节点不需要启动mgm服务
2.db节点的my.cnf需要额外加上ndb-connectstring参数,指向mgm服务器
3.可以用mgm服务器的ndb_mgm程序观察各节点的状态,方法: echo show | /usr/local/mysql/bin/ndb_mgm
4.config.ini的NoOfReplicas参数指明了每个db组的节点数,如果设置为2,则每组的db节点数为2,mgm服务器自动顺序分配组
5.每个db组至少要有一个db节点连通,否则整个cluster会停机
6.db节点启动ndbd时候,要指定connect-string到mgm服务器
7.db节点的启动步骤: a.启动ndbd b.启动mysql服务
8.mgm节点的启动步骤: a.启动ndb_mgmd b:启动ndbd c:启动mysql服务
9.建表时需要指明engine=ndbcluster,才会利用cluster功能储存;普通的建表方式仍然支持.

这里是之前看的安装步骤,但是有些错误的说

[@more@]

使用action script viewer 4反编译swf文件

步骤如下:

1.用asv打开.swf文件

2.选择export rebuild data (jsfl)

3.到导出目录用flash mx 2004新建一个fla文件,将所有的.swf,.mp3…导入到库,完成后另存为rebuild.fla

4.双击rebuild.jsfl进行反编译

5.保存,收工

[@more@]

大文件上传且带进度条的php解决方案

以下是用Pear::HTML_Progress实现大文件上传的例子

  • HTTP 1 – Upload files with your web browser to a web server. Single page (using frames).
  • HTTP 2 – Upload files with your web browser to a web server. Progress meter in a popup.
  • HTTP 3 – Mixed field Upload. Single page (using frames).
  • HTTP 4 – Upload files with your web browser to a web server and logs operations into a file.
  • FTP – Upload file on a remote ftp server that may be different than webserver.

    更多的HTML_Progress教程看这里:
    http://pear.laurent-laville.org/HTML_Progress/examples/

  • [@more@]

    php代码美化程序PHP_Beautifier试用手记

    在pear的rss列表上看到了PHP_Beautifier 0.1.1 beta发布,便下载回来试用:
    >>pear install PHP_Beautifier
    ………………………………………..

    顺利完成,看了下帮助,还带有命令行工具,方便:

    D:xamppphp>php_beautifier –help

    Usage: php_beautifier [options]
    and/or can be ‘-‘, which means stdin/stdout.
    you can use ? and * for batch processing
    can be a dir (ending with ‘/’ or a real dir)
    or a file (without ‘/’)
    multiple ins and one out = merge all files in one output
    Options:
    –input or -f input file – default: stdin
    –output or -o output dir or file – default: stdout
    –indent_tabs or -t indent with tabs
    –indent_spaces or -s indent with spaces – default
    –filters or -l Add filter(s)
    –directory_filters or -d Include dirs for filters
    –compress or -c Compress output
    –recursive or -r Search in subdir recursively
    –help or -? display help/usage (this message)

    Filter definition:
    –filters "Filter1(setting1=value1,setting2=’value2′) Filter2()"

    不过试用下来,处理的不是太完美,比如复杂点php代码美化后不整齐之类的,期待更好的版本出现 [@more@]