ÔõÑùÔÚLinuxÉÏÉèÖÃÊý¾Ý¿â¼¯Èº
ÔõÑùÔÚlinuxÉÏÉèÖÃÊý¾Ý¿â¼¯Èº
Ëæ×Å»¥ÁªÍøµÄÅÉú³¤£¬º£Á¿Êý¾ÝµÄ´¦Àí³ÉΪÁ˸÷¸öÆóÒµµÄÅäºÏÐèÇó¡£ÎªÁËÌá¸ßÊý¾Ý¿âµÄÐÔÄܺÍÎȹÌÐÔ£¬Êý¾Ý¿â¼¯Èº³ÉΪÁ˲»¿É»òȱµÄ¼Ü¹¹Ö®Ò»¡£ÔÚLinux²Ù×÷ϵͳÉÏ£¬ÉèÖÃÊý¾Ý¿â¼¯Èº¿ÉÒÔ½ÓÄɶàÖÖ½â¾ö¼Æ»®£¬ÈçMySQL Cluster¡¢PostgreSQLºÍMongoDBµÈ¡£
±¾ÎĽ«ÒÔMySQL ClusterΪÀý£¬ÏÈÈÝÔÚLinuxÉÏÔõÑùÉèÖÃÊý¾Ý¿â¼¯Èº£¬ÒÔʵÏÖÊý¾ÝµÄÂþÑÜʽ´æ´¢ºÍ¸ºÔØƽºâ¡£
µÚÒ»²½£º×¼±¸ÇéÐÎ
Ê×ÏÈ£¬È·±£Linux²Ù×÷ϵͳÒѾװÖò¢×¼È·ÉèÖ᣾ßÓÐsudoȨÏÞµÄÓû§µÇ¼ϵͳ£¬²¢È·±£ÒѾװÖÃÁËMySQL ClusterµÄ°ü¡£
µÚ¶þ²½£ºÏÂÔغÍ×°ÖÃMySQL Cluster
¿ÉÒÔ´ÓMySQL¹Ù·½ÍøÕ¾ÏÂÔØMySQL ClusterµÄ×îа汾¡£ÏÂÔØÍê³Éºó£¬Ê¹ÓÃÒÔÏÂÏÂÁî¾ÙÐÐ×°Öãº
sudo tar -xzvf mysql-cluster-gpl-version.tar.gz
cd mysql-cluster-gpl-version
sudo ./configure
sudo make && sudo make install
µÚÈý²½£º½¨É輯ȺÉèÖÃÎļþ
ÔÚ×°ÖÃĿ¼Ï½¨ÉèÒ»¸öеÄÉèÖÃÎļþ£º
sudo vi /etc/my.cnf
ÔÚÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º
[mysqld]
ndbcluster
ndb-connectstring=
ndb-connectstring=
ÆäÖÐ ºÍ ÊÇÄúÍýÏëÔÚ¼¯ÈºÖÐʹÓõÄÁ½¸ö½ÚµãµÄIPµØµã¡£
ÉúÑIJ¢Í˳öÉèÖÃÎļþ¡£
µÚËIJ½£º½¨É輯ȺÖÎÀí½Úµã
ÔÚÉèÖúõĽڵãÉÏ£¬½¨ÉèÒ»¸öMySQL¼¯ÈºÖÎÀí½Úµã¡£·¿ªÖն˲¢ÔËÐÐÒÔÏÂÏÂÁ
sudo ndb_mgmd –config-file=/etc/my.cnf –initial
´ËÏÂÁÆô¶¯¼¯ÈºÖÎÀí½Úµã²¢¼ÓÔØÉèÖÃÎļþ¡£
µÚÎå²½£º½¨ÉèÊý¾Ý½Úµã
ÔÚÿ¸ö½ÚµãÉÏ£¬½¨ÉèMySQL¼¯ÈºµÄÊý¾Ý½Úµã¡£ÔÚÖÕ¶ËÉÏÔËÐÐÒÔÏÂÏÂÁ
sudo ndbd –initial
´ËÏÂÁÆô¶¯Êý¾Ý½Úµã²¢½«Æä¼ÓÈëµ½¼¯ÈºÖС£
µÚÁù²½£º½¨ÉèMySQLЧÀÍÆ÷½Úµã
ÔÚÖÕ¶ËÉÏÔËÐÐÒÔÏÂÏÂÁ½¨ÉèMySQLЧÀÍÆ÷½Úµã£º
sudo mysqld_safe –user=mysql –ndbcluster
´ËÏÂÁÆô¶¯MySQLЧÀÍÆ÷½Úµã²¢ÅþÁ¬µ½Êý¾Ý½Úµã¡£
µÚÆß²½£º²âÊÔÊý¾Ý¿âÅþÁ¬
ÏÖÔÚ£¬¿ÉÒÔ²âÊÔÊý¾Ý¿â¼¯ÈºÊÇ·ñÕý³£ÊÂÇ顣ʹÓÃÒÔÏÂÏÂÁîÅþÁ¬µ½MySQLЧÀÍÆ÷½Úµã£º
mysql -u root -p
ÊäÈëMySQLÖÎÀíÔ±Óû§µÄÃÜÂ룬ÈôÊÇÒ»ÇÐÕý³££¬Ó¦¸Ã¿ÉÒÔÀֳɵǼµ½MySQLЧÀÍÆ÷¡£
µÚ°Ë²½£º½¨ÉèÊý¾Ý¿âºÍ±í¸ñ
ÔÚÏÂÁîÐÐÖÐÔËÐÐÒÔÏÂÏÂÁîÀ´½¨ÉèÊý¾Ý¿âºÍ±í¸ñ£º
CREATE DATABASE example;
USE example;
CREATE TABLE employees (id INT PRIMARY KEY, name VARCHAR(50));
´ËÏÂÁ½¨ÉèÒ»¸öÃûΪexampleµÄÊý¾Ý¿â£¬²¢ÔÚÆäÖн¨ÉèÒ»¸öÃûΪemployeesµÄ±í¸ñ¡£
µÚ¾Å²½£º²åÈëºÍÅÌÎÊÊý¾Ý
ÔËÐÐÒÔÏÂÏÂÁîÀ´²åÈëÊý¾Ý£º
INSERT INTO employees (id, name) VALUES (1, ‘John’);
INSERT INTO employees (id, name) VALUES (2, ‘Jane’);
ÔËÐÐÒÔÏÂÏÂÁîÀ´ÅÌÎÊÊý¾Ý£º
SELECT * FROM employees;
ÈôÊÇÊý¾ÝÄܹ»Õý³£²åÈëºÍÅÌÎÊ£¬ËµÃ÷Êý¾Ý¿â¼¯ÈºÒѾÀÖ³ÉÉèÖò¢ÇÒÕý³£ÊÂÇé¡£
¿¢ÊÂÓï
ͨ¹ýÒÔÉÏ°ì·¨£¬ÄúÒѾÀÖ³ÉÉèÖÃÁËÊý¾Ý¿â¼¯Èº²¢ÊµÏÖÁËÊý¾ÝµÄÂþÑÜʽ´æ´¢ºÍ¸ºÔØƽºâ¡£Çë×¢ÖØ£¬Õâ½öÊÇÒ»¸ö»ù±¾µÄÉèÖÃʾÀý£¬ÏÖʵӦÓÃÖл¹ÐèҪƾ֤ÏêϸÐèÇó¾ÙÐÐÉèÖÃÓÅ»¯ºÍµ÷½â¡£
Ï£Íû±¾ÎĶÔÄúÔÚLinuxÉÏÉèÖÃÊý¾Ý¿â¼¯ÈºÓÐËù×ÊÖú¡£ÈôÊÇÄúÓÐÈκÎÎÊÌâ»òÒÉÐÄ£¬ÇëËæʱÁôÑÔ¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖÃÊý¾Ý¿â¼¯ÈºµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡