• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • 建议的NDB群集启动配置

    从NDB群集中获得最佳性能取决于许多因素,其中包括:

    • NDB Cluster软件版本
    • 数据节点和SQL节点数
    • 硬件
    • 操作系统
    • 要存储的数据量
    • 集群运行的负载大小和类型

    因此,获得最佳配置可能是一个迭代过程,其结果可能会因每个NDB群集部署的具体情况而有很大差异。在运行群集的平台或使用NDB群集数据的应用程序中进行更改时,也可能会指示配置更改。由于这些原因,不可能提供适合所有使用场景的单个配置。但是,在本节中,我们提供了建议的基本配置。

    启动config.ini文件。config.ini建议使用以下文件来配置运行NDB Cluster 8.0的集群:

    # TCP PARAMETERS
    
    [tcp default]SendBufferMemory=2M
    ReceiveBufferMemory=2M
    
    # Increasing the sizes of these 2 buffers beyond the default values
    # helps prevent bottlenecks due to slow disk I/O.
    
    # MANAGEMENT NODE PARAMETERS
    
    [ndb_mgmd default]
    DataDir=path/to/management/server/data/directory
    
    # It is possible to use a different data directory for each management
    # server, but for ease of administration it is preferable to be
    # consistent.
    
    [ndb_mgmd]
    HostName=management-server-A-hostname
    # NodeId=management-server-A-nodeid
    
    [ndb_mgmd]
    HostName=management-server-B-hostname
    # NodeId=management-server-B-nodeid
    
    # Using 2 management servers helps guarantee that there is always an
    # arbitrator in the event of network partitioning, and so is
    # recommended for high availability. Each management server must be
    # identified by a HostName. You may for the sake of convenience specify
    # a NodeId for any management server, although one will be allocated
    # for it automatically; if you do so, it must be in the range 1-255
    # inclusive and must be unique among all IDs specified for cluster
    # nodes.
    
    # DATA NODE PARAMETERS
    
    [ndbd default]
    NoOfReplicas=2
    
    # Using 2 replicas is recommended to guarantee availability of data;
    # using only 1 replica does not provide any redundancy, which means
    # that the failure of a single data node causes the entire cluster to
    # shut down. As of NDB 8.0.19, it is also possible (but not required) to
    # use more than 2 replicas, although 2 replicas are sufficient to provide
    # high availability.
    
    LockPagesInMainMemory=1
    
    # On Linux and Solaris systems, setting this parameter locks data node
    # processes into memory. Doing so prevents them from swapping to disk,
    # which can severely degrade cluster performance.
    
    DataMemory=3456M
    
    # The value provided for DataMemory assumes 4 GB RAM
    # per data node. However, for best results, you should first calculate
    # the memory that would be used based on the data you actually plan to
    # store (you may find the ndb_size.pl utility helpful in estimating
    # this), then allow an extra 20% over the calculated values. Naturally,
    # you should ensure that each data node host has at least as much
    # physical memory as the sum of these two values.
    
    # ODirect=1
    
    # Enabling this parameter causes NDBCLUSTER to try using O_DIRECT
    # writes for local checkpoints and redo logs; this can reduce load on
    # CPUs. We recommend doing so when using NDB Cluster on systems running
    # Linux kernel 2.6 or later.
    
    NoOfFragmentLogFiles=300
    DataDir=path/to/data/node/data/directory
    MaxNoOfConcurrentOperations=100000
    
    SchedulerSpinTimer=400
    SchedulerExecutionTimer=100
    RealTimeScheduler=1
    # Setting these parameters allows you to take advantage of real-time scheduling
    # of NDB threads to achieve increased throughput when using ndbd. They
    # are not needed when using ndbmtd; in particular, you should not set
    # RealTimeScheduler for ndbmtd data nodes.
    
    TimeBetweenGlobalCheckpoints=1000
    TimeBetweenEpochs=200
    RedoBuffer=32M
    
    # CompressedLCP=1
    # CompressedBackup=1
    # Enabling CompressedLCP and CompressedBackup causes, respectively, local
    checkpoint files and backup files to be compressed, which can result in a space
    savings of up to 50% over noncompressed LCPs and backups.
    
    # MaxNoOfLocalScans=64
    MaxNoOfTables=1024
    MaxNoOfOrderedIndexes=256
    
    [ndbd]
    HostName=data-node-A-hostname
    # NodeId=data-node-A-nodeid
    
    LockExecuteThreadToCPU=1
    LockMaintThreadsToCPU=0
    # On systems with multiple CPUs, these parameters can be used to lock NDBCLUSTER
    # threads to specific CPUs
    
    [ndbd]
    HostName=data-node-B-hostname
    # NodeId=data-node-B-nodeid
    
    LockExecuteThreadToCPU=1
    LockMaintThreadsToCPU=0
    
    # You must have an [ndbd] section for every data node in the cluster;
    # each of these sections must include a HostName. Each section may
    # optionally include a NodeId for convenience, but in most cases, it is
    # sufficient to allow the cluster to allocate node IDs dynamically. If
    # you do specify the node ID for a data node, it must be in the range 1
    # to 144 inclusive and must be unique among all IDs specified for
    # cluster nodes. (Previous to NDB 8.0.18, this range was 1 to 48 inclusive.)
    
    # SQL NODE / API NODE PARAMETERS
    
    [mysqld]
    # HostName=sql-node-A-hostname
    # NodeId=sql-node-A-nodeid
    
    [mysqld]
    
    [mysqld]
    
    # Each API or SQL node that connects to the cluster requires a [mysqld]
    # or [api] section of its own. Each such section defines a connection
    # “slot”; you should have at least as many of these sections in the
    # config.ini file as the total number of API nodes and SQL nodes that
    # you wish to have connected to the cluster at any given time. There is
    # no performance or other penalty for having extra slots available in
    # case you find later that you want or need more API or SQL nodes to
    # connect to the cluster at the same time.
    # If no HostName is specified for a given [mysqld] or [api] section,
    # then any API or SQL node may use that slot to connect to the
    # cluster. You may wish to use an explicit HostName for one connection slot
    # to guarantee that an API or SQL node from that host can always
    # connect to the cluster. If you wish to prevent API or SQL nodes from
    # connecting from other than a desired host or hosts, then use a
    # HostName for every [mysqld] or [api] section in the config.ini file.
    # You can if you wish define a node ID (NodeId parameter) for any API or
    # SQL node, but this is not necessary; if you do so, it must be in the
    # range 1 to 255 inclusive and must be unique among all IDs specified
    # for cluster nodes.
    

    SQL节点的推荐my.cnf选项。充当NDB群集SQL节点的MySQL服务器必须始终使用--ndbcluster--ndb-connectstring选项在命令行或in中启动my.cnf。另外,为集群中的所有mysqld进程设置以下选项,除非您的设置另有要求:

    • --ndb-use-exact-count=0
    • --ndb-index-stat-enable=0
    • --ndb-force-send=1
    • --optimizer-switch=engine_condition_pushdown=on