成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

MySQL集群在Ubuntu 9.0上的配置方法

數據庫 MySQL 數據庫運維
在這里我們將跳出原有的RedHat系統,講解Ubuntu系統上如何配置MySQL集群的問題。希望對大家有所幫助。

大家在網上都能找到都是RedHat系統等等,對Ubuntu系統MySQL集群就沒有介紹文章

我現在寫寫Ubuntu這個MySQL集群方法。新手不要罵我,呵呵。

介紹網絡環境:

測試環境:

  1. Server1: ndbd 192.168.245.11  
  2. Server2: ndbd 192.168.245.12  
  3. Server3: mysqld –ndb-cluster 192.168.245.13 

ndbd: 數據庫節點。

mysqld –ndb-cluster: MySQL服務器節點,程序直接訪問的是這臺機器的IP。默認端口仍是3306。

ndbd_mgm ndbd_mgmd:管理節點。管理/查看各庫節點和服務器節點的狀態。

二、集群方案

1.管理節點:server3(192.168.245.13)

2.存儲節點:server1(192.168.245.11),server2(192.168.245.12)

3.SQL節點:server1(192.168.245.11),server2(192.168.245.12),server3(192.168.245.13)

三、mysql安裝和配置

1.安裝,sudo apt-get install mysql-server

2.配置這三臺服務器上配置my.cnf,這三臺服務器都要配置

  1. vim /etc/mysql/my.cnf  
  2. —————————————–my.cnf開始——————————————–  
  3. Ubuntu@ubuntu:~$ cat /etc/mysql/my.cnf  
  4. #  
  5. # The MySQL database server configuration file.  
  6. #  
  7. # You can copy this to one of:  
  8. # - “/etc/mysql/my.cnf” to set global options,  
  9. # - “~/.my.cnf” to set user-specific options.  
  10. #  
  11. # One can use all long options that the program supports.  
  12. # Run program with –help to get a list of available options and with  
  13. # –print-defaults to see which it would actually understand and use.  
  14. #  
  15. # For explanations see  
  16. # http://dev.mysql.com/doc/mysql/en/serve ... ables.html  
  17.  
  18. # This will be passed to all mysql clients  
  19. # It has been reported that passwords should be enclosed with ticks/quotes  
  20. # escpecially if they contain “#” chars…  
  21. # Remember to edit /etc/mysql/debian.cnf when changing the socket location.  
  22. [client]  
  23. port = 3306 
  24. socket = /var/run/mysqld/mysqld.sock  
  25.  
  26. # Here is entries for some specific programs  
  27. # The following values assume you have at least 32M ram  
  28.  
  29. # This was formally known as [safe_mysqld]. Both versions are currently parsed.  
  30. [mysqld_safe]  
  31. socket = /var/run/mysqld/mysqld.sock  
  32. nice = 0 
  33.  
  34. [mysqld]  
  35. #  
  36. # * Basic Settings  
  37. #  
  38.  
  39. #  
  40. # * IMPORTANT  
  41. # If you make changes to these settings and your system uses apparmor, you may  
  42. # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.  
  43. #  
  44.  
  45. user = mysql 
  46. pid-file = /var/run/mysqld/mysqld.pid  
  47. socket = /var/run/mysqld/mysqld.sock  
  48. port = 3306 
  49. basedir = /usr  
  50. datadir = /var/lib/mysql  
  51. tmpdir = /tmp  
  52. language = /usr/share/mysql/english  
  53. skip-external-locking  
  54. #  
  55. # Instead of skip-networking the default is now to listen only on  
  56. # localhost which is more compatible and is not less secure.  
  57. bind-address = 127.0.0.1  
  58. #  
  59. # * Fine Tuning  
  60. #  
  61. key_buffer = 16M 
  62. max_allowed_packet = 16M 
  63. thread_stack = 128K 
  64. thread_cache_size = 8 
  65. #max_connections = 100 
  66. #table_cache = 64 
  67. #thread_concurrency = 10 
  68. #  
  69. # * Query Cache Configuration  
  70. #  
  71. query_cache_limit = 1M 
  72. query_cache_size = 16M 
  73. #  
  74. # * Logging and Replication  
  75. #  
  76. # Both location gets rotated by the cronjob.  
  77. # Be aware that this log type is a performance killer.  
  78. #log = /var/log/mysql/mysql.log  
  79. #  
  80. # Error logging goes to syslog. This is a Debian improvement   
  81. #  
  82. # Here you can see queries with especially long duration  
  83. #log_slow_queries = /var/log/mysql/mysql-slow.log  
  84. #long_query_time = 2 
  85. #log-queries-not-using-indexes  
  86. #  
  87. # The following can be used as easy to replay backup logs or for replication.  
  88. # note: if you are setting up a replication slave, see README.Debian about  
  89. # other settings you may need to change.  
  90. #server-id = 1 
  91. #log_bin = /var/log/mysql/mysql-bin.log  
  92. expire_logs_days = 10 
  93. max_binlog_size = 100M 
  94. #binlog_do_db = include_database_name 
  95. #binlog_ignore_db = include_database_name 
  96. #  
  97. # * BerkeleyDB  
  98. #  
  99. # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.  
  100. skip-bdb  
  101. #  
  102. # * MyISAM  
  103. #  
  104. # MyISAM is enabled by default with a 10MB datafile in /var/lib/mysql/.  
  105. # Read the manual for more MyISAM related options. There are many!  
  106. # You might want to disable MyISAM to shrink the mysqld process by circa 100MB.  
  107. #skip-innodb  
  108. #  
  109. # * Security Features  
  110. #  
  111. # Read the manual, too, if you want chroot!  
  112. chroot = /var/lib/mysql/  
  113. #  
  114. # For generating SSL certificates I recommend the OpenSSL GUI “tinyca”.  
  115. #  
  116. ssl-ca=/etc/mysql/cacert.pem  
  117. ssl-cert=/etc/mysql/server-cert.pem  
  118. ssl-key=/etc/mysql/server-key.pem  
  119.  
  120. ndbcluster  
  121. ndb-connectstring=192.168.245.13  
  122.  
  123. [mysqldump]  
  124. quick  
  125. quote-names  
  126. max_allowed_packet = 16M 
  127.  
  128. [mysql]  
  129. #no-auto-rehash # faster start of mysql but no tab completition  
  130.  
  131. [isamchk]  
  132. key_buffer = 16M 
  133.  
  134. #  
  135. # * NDB Cluster  
  136. #  
  137. # See /usr/share/doc/mysql-server-*/README.Debian for more information.  
  138. #  
  139. # The following configuration is read by the NDB Data Nodes (ndbd processes)  
  140.  
  141. # not from the NDB Management Nodes (ndb_mgmd processes).  
  142. #  
  143. [MYSQL_CLUSTER]  
  144.  
  145. ndb-connectstring=192.168.245.13  
  146.  
  147. #  
  148. # * IMPORTANT: Additional settings that can override those from this file!  
  149. # The files must end with ‘.cnf’, otherwise they’ll be ignored.  
  150. #  
  151. !includedir /etc/mysql/conf.d/  
  152.  
  153. Ubuntu@ubuntu:~$  
  154. ———————————my.cnf結束——————————————————— 

主要在:[mysqld]下添加:

  1. ndbcluster  
  2. ndb-connectstring=192.168.245.13 

和添加

  1. [MYSQL_CLUSTER]  
  2. ndb-connectstring=192.168.245.13 

上面三臺服務器都要一樣

2.配置ndb_mgmd.cnf(192.168.245.13服務器上配置)

復制/usr/share/doc/mysql-server-5.0/examples/ndb_mgmd.cnf到/etc/mysql/ndb_mgmd.cnf

編輯ndb_mgmd.cnf

  1. ——————-開始————  
  2. Ubuntu@ubuntu:~$ cat /etc/mysql/ndb_mgmd.cnf  
  3. [NDBD DEFAULT]  
  4. NoOfReplicas=2 
  5. DataMemory=10MB 
  6. IndexMemory=25MB 
  7. MaxNoOfTables=256 
  8. MaxNoOfOrderedIndexes=256 
  9. MaxNoOfUniqueHashIndexes=128 
  10.  
  11. [MYSQLD DEFAULT]  
  12. [NDB_MGMD DEFAULT]  
  13. [TCP DEFAULT]  
  14. [NDB_MGMD]  
  15. Id=1 # the NDB Management Node (this one)  
  16. HostName=192.168.245.13  
  17. DataDir= /var/lib/mysql-cluster  
  18.  
  19. [NDBD]  
  20. Id=2 # the first NDB Data Node  
  21. HostName=192.168.245.11  
  22. DataDir= /var/lib/mysql-cluster  
  23.  
  24. [NDBD]  
  25. Id=3 # the second NDB Data Node  
  26. HostName=192.168.245.12  
  27. DataDir=/var/lib/mysql-cluster  
  28.  
  29. [MYSQLD]  
  30. Id=4 # the first SQL node  
  31. HostName=192.168.245.13  
  32. [MYSQLD]  
  33. Id=5 # the first SQL node  
  34. HostName=192.168.245.11  
  35. [MYSQLD]  
  36. Id=6 # the first SQL node  
  37. HostName=192.168.245.12  
  38.  
  39. Ubuntu@ubuntu:~$  
  40.  
  41. ——————-結束———— 

先啟動:

13服務器:

  1. sudo /etc/init.d/mysql-ndb-mgm start 

然后啟動

11.12服務器

  1. sudo /etc/init.d/mysql-ndb start 

最后啟動,13.11.12服務器mysql服務

  1. sudo /etc/init.d/mysql start 

測試:

13服務器上:

  1. neo@mgm:~$ ndb_mgm  
  2. – NDB Cluster — Management Client –  
  3. ndb_mgm> show  
  4. Connected to Management Server at: localhost:1186  
  5. Cluster Configuration  
  6. ———————  
  7. [ndbd(NDB)] 2 node(s)  
  8. id=2 @192.168.245.11 (Version: 5.0.51, Nodegroup: 0)  
  9. id=3 @192.168.245.12 (Version: 5.0.51, Nodegroup: 0, Master)  
  10.  
  11. [ndb_mgmd(MGM)] 1 node(s)  
  12. id=1 @192.168.245.13 (Version: 5.0.51)  
  13.  
  14. [mysqld(API)] 2 node(s)  
  15. id=4 @192.168.245.13 (Version: 5.0.51)  
  16. id=5 @192.168.245.11 (Version: 5.0.51)  
  17. id=5 @192.168.245.12 (Version: 5.0.51)  
  18.  
  19. ndb_mgm> 

與沒有使用簇的MySQL相比,在MySQL簇內操作數據的方式沒有太大的區別。

執行這類操作時應記住三點

1.表必須用ENGINE=NDB或ENGINE=NDBCLUSTER選項創建,或用ALTER TABLE選項更改,以使用NDB Cluster存儲引擎在 Cluster內復制它們。如果使用mysqldump的輸出從已有數據庫導入表,可在文本編輯器中打開SQL腳本,并將該選項添加到任何表創建語句,或用這類選項之一替換任何已有的ENGINE(或TYPE)選項。

2.另外還請記住,每個NDB表必須有一個主鍵。如果在創建表時用戶未定義主鍵,NDB Cluster存儲引擎將自動生成隱含的主鍵。(注釋:該隱含 鍵也將占用空間,就像任何其他的表索引一樣。由于沒有足夠的內存來容納這些自動創建的鍵,出現問題并不罕見)。

3.當你在一個節點上運行create database mydb;你去其他sql node上執行show databases;將不能看到mydb,你需要創建它,然后use mydb; show tables;你將看到同步的表。

  1. SQL Node 1  
  2. neo@sql:~$ mysql -uroot -p  
  3. Enter password:  
  4. Welcome to the MySQL monitor. Commands end with ; or g.  
  5. Your MySQL connection id is 7  
  6. Server version: 5.0.51a-3Ubuntu5.1 (Ubuntu)  
  7.  
  8. Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.  
  9.  
  10. mysql> create database cluster;  
  11. Query OK, 1 row affected (0.00 sec)  
  12.  
  13. mysql> use cluster  
  14. Database changed  
  15. mysql> create table city( id mediumint unsigned not null auto_increment primary key, 
  16. name varchar(20) not null default ” ) engine = ndbcluster default  
  17.  
  18. charset utf8;  
  19. Query OK, 0 rows affected (1.07 sec)  
  20.  
  21. mysql> insert into city values(1, ‘Shenzhen’);  
  22. Query OK, 1 row affected (0.12 sec)  
  23.  
  24. mysql> insert into city values(2, ‘Guangdong’);  
  25. Query OK, 1 row affected (0.00 sec)  
  26.  
  27. SQL Node 2  
  28.  
  29. neo@sql:~$ mysql -uroot -p  
  30. Enter password:  
  31. Welcome to the MySQL monitor. Commands end with ; or g.  
  32. Your MySQL connection id is 7  
  33. Server version: 5.0.51a-3Ubuntu5.1 (Ubuntu)  
  34.  
  35. Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the buffer.  
  36.  
  37. mysql> show databases;  
  38. ——————–   
  39. | Database |  
  40. ——————–   
  41. | information_schema |  
  42. | example |  
  43. | mydb |  
  44. | mysql |  
  45. | neo |  
  46. ——————–   
  47. 6 rows in set (0.13 sec)  
  48.  
  49. mysql> create database cluster;  
  50. Query OK, 1 row affected (0.00 sec)   
  51. mysql> show databases;  
  52. ——————–   
  53. | Database |  
  54. ——————–   
  55. | information_schema |  
  56. | cluster |  
  57. | example |  
  58. | mydb |  
  59. | mysql |  
  60. | neo |  
  61. ——————–   
  62. 6 rows in set (0.13 sec)  
  63.  
  64. mysql> use cluster;  
  65. Reading table information for completion of table and column names  
  66. You can turn off this feature to get a quicker startup with -A  
  67.  
  68. Database changed  
  69. mysql> show tables;  
  70. ——————-   
  71. | Tables_in_cluster |  
  72. ——————-   
  73. | city |  
  74. ——————-   
  75. 1 row in set (0.01 sec)  
  76.  
  77. mysql> select * from city;  
  78. —- ———–   
  79. | id | name |  
  80. —- ———–   
  81. | 1 | Shenzhen |  
  82. | 2 | Guangdong |  
  83. —- ———–   
  84. 2 rows in set (0.03 sec)  
  85.  
  86. mysql> 

【編輯推薦】 

  1. MySQL數據庫集群進行正確配置步驟
  2. MySQL 集群在Server1與Server2上如何安裝MySQL
  3. MySQL集群配置
  4. MySQL集群自動安裝腳本
  5. MySQL觸發器如何正確使用

 

責任編輯:彭凡 來源: Ubuntu社區
相關推薦

2011-09-07 13:33:51

ubuntuUbuntu Twea

2014-06-30 09:27:17

UbuntuTomcat集群

2018-04-03 13:31:53

LinuxUbuntu 16.0msmtp

2022-09-14 11:31:37

MySQL數據庫管理系統

2015-09-06 09:55:51

UbuntuHHVM

2010-08-17 15:08:48

MySQL集群

2019-04-28 10:00:11

UbuntuLinuxMySQL

2011-05-24 09:33:40

UbuntuOpenStackNova

2011-01-12 09:59:28

Ubuntu Serviptables

2011-01-14 14:00:19

GanetiLinux集群虛擬化

2020-12-26 14:48:21

UbuntuLinuxDeb文件

2011-08-31 17:55:06

2011-03-10 11:06:02

Ubuntu搭建LAMP

2023-09-24 19:24:18

UbuntuVSCodium

2011-01-21 17:43:13

2013-04-18 15:53:46

SLURM開源分布式資源管理

2010-07-13 09:46:09

TomcatUbuntu 10.0

2021-04-09 10:58:51

UbuntuLinuxWindows 10

2019-07-05 09:45:19

UbuntuLinux釋放空間

2022-08-05 22:02:07

UbuntuLinuxVim
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 综合二区 | 羞羞视频网站免费看 | 中文字幕影院 | www久久国产 | 色综合久 | 国产日韩精品视频 | 国产精品一区二区三区久久 | h视频免费看| 国产精品大全 | 国产高清性xxxxxxxx | av电影一区 | 粉嫩在线 | 爱爱无遮挡 | 国产成人99久久亚洲综合精品 | 国产综合视频 | 青娱乐av| 亚洲一区二区精品视频 | 久久av一区二区三区 | 免费在线日韩 | 成人中文字幕av | 日韩福利视频 | 久久精品国产一区二区电影 | 区一区二在线观看 | 亚洲视频免费在线观看 | 日日摸夜夜添夜夜添特色大片 | 久久久久久国模大尺度人体 | wwww.xxxx免费 | 国产成人精品999在线观看 | 国产三区av | 日韩三级免费网站 | 91在线免费视频 | 成人三级视频 | 视频一区二区三区中文字幕 | 97久久精品 | 欧美精品一二三区 | 亚洲综合在线视频 | 99视频免费看 | 国产视频二区在线观看 | 成人在线亚洲 | 亚洲午夜精品一区二区三区他趣 | 国产精品美女久久久久久免费 |