hq8501 发表于 2018-10-2 11:47:54

(二) mysql cluster 7.3.5 配置

  192.168.100.10 管理节点
  192.168.100.20 sql节点
  192.168.100.30 sql节点
  192.168.100.40 存储节点
  192.168.100.50 存储节点
  系统均为centos6.4 x64
  一、安装前准备
  # wget http://mirrors.sohu.com/mysql/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.5-1.el6.x86_64.rpm-bundle.tar
  # tar xvf MySQL-Cluster-gpl-7.3.5-1.el6.x86_64.rpm-bundle.tar
  解压后文件
  MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm
  MySQL-Cluster-devel-gpl-7.3.5-1.el6.x86_64.rpm MySQL-Cluster-shared-compat-gpl-7.3.5-1.el6.x86_64.rpm
  MySQL-Cluster-embedded-gpl-7.3.5-1.el6.x86_64.rpm MySQL-Cluster-shared-gpl-7.3.5-1.el6.x86_64.rpm
  MySQL-Cluster-gpl-7.3.5-1.el6.x86_64.rpm-bundle.tar MySQL-Cluster-test-gpl-7.3.5-1.el6.x86_64.rpm
  拷贝MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm到所有服务器
  # scp MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.20:~/
  # scp MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.30:~/
  # scp MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.40:~/
  # scp MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.50:~/
  拷贝MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm到sql节点
  # scp MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.20:~/
  # scp MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm 192.168.100.30:~/
  所有节点机器清理旧的Mysql安装
  yum remove mysql
  rpm -qa | grep mysql*
  对于找到的1个剩余mysql包,请按照如下的命令格式予以删除:
  rpm -e --nodeps mysql-libs-5.1.66-2.el6_3.x86_64
  安装依赖库
  yum -y install libaio
  二、安装mysql-cluster
  每个节点机器安装MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm
  rpm -Uvh MySQL-Cluster-server-gpl-7.3.5-1.el6.x86_64.rpm
  安装后会提示默认密码存放在/root/.mysql_secret文件中

  在sql节点机器安装MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm
  # rpm -Uvh MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm
  # rpm -Uvh MySQL-Cluster-client-gpl-7.3.5-1.el6.x86_64.rpm
  三、配置管理节点
  # mkdir /var/lib/mysql-cluster
  # cd /var/lib/mysql-cluster/
  # vim config.ini
  
  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 tabkes up
  # only about 500kb, this should be more than enough for
  # this example Cluster setup
  
  #Management process otions
  hostname=192.168.100.10 #Hostname or IP address of MGM node
  datadir=/var/lib/mysql-cluster #Directory for MGM node log files
  
  #Options for data node "A"
  hostname=192.168.100.40 #Hostname or IP address
  datadir=/usr/local/mysql/data #Directory for this data node's data files
  
  #Options for data node "B"
  hostname=192.168.100.50 #Hostname or IP address
  datadir=/usr/local/mysql/data #Directory for this data node's data files
  
  #SQL node options
  hostname=192.168.100.20 #Hostname or IP address
  
  hostname=192.168.100.30 #Hostname or IP address
四、配置存储节点和SQL节点
  存储节点:
  # mkdir -p /usr/local/mysql/data
  # mkdir -p /usr/local/mysql/data
  SQL节点:
  # mkdir -p /var/run/mysqld
  # chmod -R 777 /var/run/mysqld/
  # mkdir -p /var/run/mysqld
  # chmod -R 777 /var/run/mysqld/
  在所有存储节点和SQL节点上建立配置文件/etc/my.cnf
  vim /etc/my.cnf
  
  socket=/var/lib/mysql/mysql.sock
  
  max_connections=100
  datadir=/var/lib/mysql
  socket=/var/lib/mysql/mysql.sock
  ndbcluster
  ndb-connectstring=192.168.100.10
  
  log-error=/var/log/mysqld.log
  pid-file=/var/run/mysqld/mysqld.pid
  
  ndb-connectstring=192.168.100.10
  五、启动各个节点
  注意顺序。
  1. 启动管理节点:
  # ndb_mgmd -f /var/lib/mysql-cluster/config.ini
  2. 启动存储节点:
  # ndbd --initial
  # ndbd --initial
  初次启动时需要加–initial参数,以后只需要执行ndbd即可;
  3. 启动SQL节点:
  # mysqld_safe --defaults-file=/etc/my.cnf --explicit_defaults_for_timestamp &
  # mysqld_safe --defaults-file=/etc/my.cnf --explicit_defaults_for_timestamp &
  六、检查所有节点是否正常启动
  在管理节点中执行ndb_mgm 进入集群管理console,使用show命令列出所有节点信息

七、修改root用户密码
  在每个sql节点执行
  # cat .mysql_secret         ----记录安装cluster-server时自动生成的初始密码
  # The random password set for the root user at Sat Jun 14 01:20:33 2014 (local time): HtPV2gJbSrRPi8Is
  # mysqladmin -uroot -pHtPV2gJbSrRPi8Is password 'zhyzhy'
  Warning: Using a password on the command line interface can be insecure.      ----此警告提示密码设置过于简单不安全
  # mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.6.17-ndb-7.3.5-cluster-gpl MySQL Cluster Community Server (GPL)
  Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> exit
  Bye
  # cat .mysql_secret
  # The random password set for the root user at Sat Jun 14 01:21:06 2014 (local time): NtwwjhqTfsqTihGM
  # mysqladmin -uroot -pNtwwjhqTfsqTihGM password 'zhyzhy'
  Warning: Using a password on the command line interface can be insecure.
  # mysql -uroot -p
  Enter password:
  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection>  Server version: 5.6.17-ndb-7.3.5-cluster-gpl MySQL Cluster Community Server (GPL)
  Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  Oracle is a registered trademark of Oracle Corporation and/or its
  affiliates. Other names may be trademarks of their respective
  owners.
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  mysql> exit
  Bye
  八、测试集群:
  在sql节点 node2上登陆mysql:
  # mysql -u root -pzhyzhy
  mysql> create database lxw;
  Query OK, 1 row affected (0.06 sec)
  在sql节点node3上登陆mysql:
  # mysql -u root -pzhyzhy
  mysql> show databases;
  +——————–+
  | Database |
  +——————–+
  | information_schema |
  | lxw |
  | mysql |
  | ndbinfo |
  | performance_schema |
  | test |
  +——————–+
  6 rows in set (0.00 sec)
  可以看到database已经同步。
  九、常用命令:
  1) ndb_mgmd管理命令:ndb_mgm
  执行之后就是管理控制台了,里面可以继续输入命令。
  查看集群里面的全部节点的状态:show
  2) 停止集群服务器的命令:ndb_mgm -e shutdown
  如果集群配置有更新了:rm /usr/mysql-cluster/ndb_1_config.bin.1
  3) 停止SQL节点的命令:mysqladmin -uroot shutdown
  4) SQL Node上连接MySQL:mysql -u root –pPASSWORD
  执行之后就是MySQL控制台了,里面可以继续输入命令。


页: [1]
查看完整版本: (二) mysql cluster 7.3.5 配置