您所在的位置: 主页 > 关于我们 > 技术专题 > MySQL专区 >

配置存储节点和SQL节点

来源:唯佳数据恢复中心技术专题点击数:更新时间:2015-10-11

数据节点所需的my.cnf文件相当简单。配置文件应位于/etc目录下,并能用任何文本编辑器进行编辑(如有必要,创建该文件),例如:

vi /etc/my.cnf

对于本示例中的每个数据节点和SQL节点,my.cnf文件类似于:

# Options for mysqld process:
[MYSQLD]                        
ndbcluster                      # run NDB engine
ndb-connectstring=192.168.0.10  # location of MGM node
 
# Options for ndbd process:
[MYSQL_CLUSTER]                 
ndb-connectstring=192.168.0.10  # location of MGM node

输入上述内容后,保存文件并退出文本编辑器。在容纳数据节点“A”、数据节点“B”和SQL节点的机器上分别执行上述操作。

配置管理节点

配置MGM节点的第一步是创建目录,该目录用于存放配置文件,然后创建配置文件本身。例如(以根用户身份运行):

mkdir /var/lib/mysql-cluster
cd /var/lib/mysql-cluster
vi config.ini

在此使用了vi来创建文件,不过,任何文本编辑器均应能胜任。

对于我们的典型设置,config.ini文件应类似于:

# Options affecting ndbd processes on all data nodes:
[NDBD DEFAULT]    
NoOfReplicas=2    # Number of replicas
DataMemory=80M    # How much memory to allocate for data storage
IndexMemory=18M   # How much memory to allocate for index storage
                  # For DataMemory and IndexMemory, we have used the
                  # default values. Since the "world" database takes up
                  # only about 500KB, this should be more than enough for
                  # this example Cluster setup.
 
# TCP/IP options:
[TCP DEFAULT]     
portnumber=2202   # This the default; however, you can use any
                  # port that is free for all the hosts in cluster
                  # Note: It is recommended beginning with MySQL 5.0 that
                  # you do not specify the portnumber at all and simply allow
                  # the default value to be used instead
 
# Management process options:
[NDB_MGMD]                      
hostname=192.168.0.10           # Hostname or IP address of MGM node
datadir=/var/lib/mysql-cluster  # Directory for MGM node logfiles
 
# Options for data node "A":
[NDBD]                          
                                # (one [NDBD] section per data node)
hostname=192.168.0.30           # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's datafiles
 
# Options for data node "B":
[NDBD]                          
hostname=192.168.0.40           # Hostname or IP address
datadir=/usr/local/mysql/data   # Directory for this data node's datafiles
 
# SQL node options:
[MYSQLD]                        
hostname=192.168.0.20           # Hostname or IP address
                                # (additional mysqld connections can be
                                # specified for this node for various
                                # purposes such as running ndb_restore)

一旦创建了所有的配置文件并指定了这些最低选项,可启动簇,并验证所有进程均能正常运行。关于这方面的讨论

关于可用MySQL簇配置参数以及其用法的更多信息,关于与进行备份有关的MySQL簇配置。

注释:簇管理节点的默认端口是1186,数据节点的默认端口2202。从MySQL 5.0.3开始,该限制已被放宽,簇能够根据空闲的端口自动地为数据节点分配端口。

 

分享到:QQ空间新浪微博腾讯微博人人网微信