标签:架构 link pat 初始 one 服务启动 类信息 mkdir initial
用途 | 组件 | |
---|---|---|
SQL nodes | mysqld binary | |
Data nodes | ndbd or ndbmtd | |
Management nodes | ndb_mgmd and ndb_mgm |
Node | IP Address |
---|---|
Management node (mgmd) | 192.168.10.200 |
SQL node (mysqld) | 192.168.10.201 |
Data node "A" (ndbd) | 192.168.10.202 |
Data node "B" (ndbd) | 192.168.10.203 |
groupadd mysql
useradd -g mysql -s /bin/false mysql
cat > /etc/profile.d/mysqlEnv.sh <<-‘EOF‘
export NDB_VER="7.6.16"
export SOFT_INSTALL_DIR="/usr/local"
export SOFT_LINK_DIR="/usr/local/mysql"
export SOFT_LOG_DIR="${SOFT_LINK_DIR}/log"
export SOFT_SVC_PORT="3308"
export SOFT_DATA_DIR="/data"
export DATA_DIR="${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}"
SOFT_FILE_NAME="mysql-cluster-gpl-${NDB_VER}-linux-glibc2.12-x86_64"
export MYSQL_HOME=${SOFT_LINK_DIR}
export PATH=${MYSQL_HOME}/bin:${PATH}
EOF
每个SQL 节点配置
. /etc/profile.d/mysqlEnv.sh
if [[ -f "${SOFT_FILE_NAME}.tar.gz" ]]; then
tar --no-same-owner -xf ${SOFT_FILE_NAME}.tar.gz -C ${SOFT_INSTALL_DIR}
ln -s ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME} ${SOFT_LINK_DIR}
else
curl -LO https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/${SOFT_FILE_NAME}.tar.gz
# https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/mysql-cluster-gpl-7.6.16-linux-glibc2.12-x86_64.tar.gz
fi
[[ -d "${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}" ]] || mkdir -p ${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}
chown -R mysql:mysql ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME}
chown -R mysql:mysql ${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=${SOFT_LINK_DIR} --datadir=${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}
cp ${SOFT_LINK_DIR}/support-files/mysql.server /etc/rc.d/init.d/
chmod +x /etc/rc.d/init.d/mysql.server
chkconfig --add mysql.server
. /etc/profile.d/mysqlEnv.sh
if [[ -f "${SOFT_FILE_NAME}.tar.gz" ]]; then
tar -xf ${SOFT_FILE_NAME}.tar.gz --strip-components=2 ${SOFT_FILE_NAME}/bin/{ndbd,ndbmtd} -C ${SOFT_INSTALL_DIR}
ln -s ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME} ${SOFT_LINK_DIR}
else
curl -LO https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/${SOFT_FILE_NAME}.tar.gz
# https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/mysql-cluster-gpl-7.6.16-linux-glibc2.12-x86_64.tar.gz
fi
chown -R mysql:mysql ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME}
chmod +x ${SOFT_LINK_DIR}/bin/ndb*
# ndb cluster 初始化需要 DataDir
[[ -d "${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}" ]] || mkdir -p ${SOFT_DATA_DIR}/mysql${SOFT_SVC_PORT}
. /etc/profile.d/mysqlEnv.sh
if [[ -f "${SOFT_FILE_NAME}.tar.gz" ]]; then
tar -xf ${SOFT_FILE_NAME}.tar.gz --strip-components=2 ${SOFT_FILE_NAME}/bin/{ndb_mgm,ndb_mgmd} -C ${SOFT_INSTALL_DIR}
ln -s ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME} ${SOFT_LINK_DIR}
else
curl -LO https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/${SOFT_FILE_NAME}.tar.gz
# https://cdn.mysql.com/archives/mysql-cluster-gpl-7.6/mysql-cluster-gpl-7.6.16-linux-glibc2.12-x86_64.tar.gz
fi
chown -R mysql:mysql ${SOFT_INSTALL_DIR}/${SOFT_FILE_NAME}
chmod +x ${SOFT_LINK_DIR}/bin/ndb_mgm*
对于4节点 NDB集群中,总共需要4个配置文件
每个 data node or SQL node 需要一个 my.cnf 配置文件,用于提供下面2类信息:
management node 需要一个 config.ini 配置文件
cat > /etc/my.cnf <<-‘EOF‘
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for NDB Cluster processes:
ndb-connectstring=192.168.10.200 # location of management server
EOF
cat > /etc/my.cnf <<-‘EOF‘
[mysqld]
# Options for mysqld process:
ndbcluster # run NDB storage engine
[mysql_cluster]
# Options for NDB Cluster processes:
ndb-connectstring=192.168.10.200 # location of management server
EOF
cat > ${SOFT_LINK_DIR}/config.ini <<EOF
[ndbd default]
# Options affecting ndbd processes on all data nodes:
NoOfReplicas=2 # Number of fragment 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 NDB Cluster setup.
# NOTE: IndexMemory is deprecated in NDB 7.6 and later; in
# these versions, resources for all data and indexes are
# allocated by DataMemory and any that are set for IndexMemory
# are added to the DataMemory resource pool
ServerPort=2202 # This the default value; however, you can use any
# port that is free for all the hosts in the cluster
# Note1: It is recommended that you do not specify the port
# number at all and simply allow the default value to be used
# instead
# Note2: The port was formerly specified using the PortNumber
# TCP parameter; this parameter is no longer available in NDB
# Cluster 7.5.
DataDir=${DATA_DIR}
[ndb_mgmd]
# Management process options:
HostName=192.168.10.200 # Hostname or IP address of management node
DataDir=${SOFT_LOG_DIR} # Directory for management node log files
[ndbd]
# Options for data node "A":
# (one [ndbd] section per data node)
HostName=192.168.10.202 # Hostname or IP address
NodeId=2 # Node ID for this data node
DataDir=${DATA_DIR} # Directory for this data node‘s data files
[ndbd]
# Options for data node "B":
HostName=192.168.10.203 # Hostname or IP address
NodeId=3 # Node ID for this data node
DataDir=${DATA_DIR} # Directory for this data node‘s data files
[mysqld]
# SQL node options:
HostName=192.168.10.201 # Hostname or IP address
# (additional mysqld connections can be
# specified for this node for various
# purposes such as running ndb_restore)
EOF
首先, 在 management node 启动进程
其次,在data nodes 启动进程
最后,在 sql nodes 启动进程
${SOFT_LINK_DIR}/bin/ndb_mgmd -f ${SOFT_LINK_DIR}/config.ini
每个 data node 执行
${SOFT_LINK_DIR}/bin/ndbd
每个 sql node 启动MySQL server 服务进程
${SOFT_LINK_DIR}/bin/mysqld
在 management node 上执行命令
${SOFT_LINK_DIR}/bin/ndb_mgm -e shutdown
${SOFT_LINK_DIR}/bin/ndb_mgmd -f ${SOFT_LINK_DIR}/config.ini
${SOFT_LINK_DIR}/bin/ndbd
${SOFT_LINK_DIR}/bin/mysqld_safe &
${SOFT_LINK_DIR}/bin/ndb_mgm -e show
标签:架构 link pat 初始 one 服务启动 类信息 mkdir initial
原文地址:https://www.cnblogs.com/binliubiao/p/14508448.html