当前位置:   article > 正文

【完美】Mysql-cluster数据库集群搭建(linux)_mysql cluster linux 部署

mysql cluster linux 部署

介绍

Mysql-cluster数据库集群介绍

安装

系统:Linux CentOS7.4

查看是否安装mysql
rpm -qa | grep mysql
普通删除
rpm -e mysql
强力删除
rpm -e --nodeps mysql
通过wget安装
wget https://dev.mysql.com/get/Downloads/MySQL-Cluster-7.5/mysql-cluster-gpl-7.5.8-linux-glibc2.12-x86_64.tar.gz
(如果没有安装wget,执行yum -y install wget
解压
tar xvf mysql-cluster-gpl-7.5.8-linux-glibc2.12-x86_64.tar.gz
新建文件夹
(用于NDB)
mkdir /usr/local/mysql-cluster
mkdir /usr/local/mysql-cluster/logs
mkdir /usr/local/mysql-cluster/data
(用于Mysql)
mkdir /usr/local/mysql
mkdir /usr/local/mysql/data
mkdir /usr/local/mysql/data/mysql

一句话: 
mkdir /usr/local/mysql-cluster /usr/local/mysql-cluster/logs /usr/local/mysql-cluster/data /usr/local/mysql /usr/local/mysql/data /usr/local/mysql/data/mysql

复制程序
cp  mysql-cluster-gpl-7.5.8-linux-glibc2.12-x86_64/bin/ndb_mgm* /usr/local/mysql-cluster
cp  mysql-cluster-gpl-7.5.8-linux-glibc2.12-x86_64/bin/ndbd /usr/local/mysql-cluster
cp -r mysql-cluster-gpl-7.5.8-linux-glibc2.12-x86_64/. /usr/local/mysql

管理节点配置
新建配置文件
vi  /usr/local/mysql-cluster/config.ini
------------------------------------------------------------------
[ndbd default]
NoOfReplicas=1
DataMemory=6144M
IndexMemory=1024M

StopOnError=0
StringMemory=5M
MaxNoOfConcurrentTransactions=100000
MaxNoOfConcurrentOperations=110000
MaxNoOfLocalOperations=250000
MaxNoOfConcurrentIndexOperations=81920
MaxNoOfConcurrentScans=256
MaxNoOfLocalScans=1000
MaxNoOfOpenFiles=1000
MaxNoOfAttributes=10000
ODirect=1
MaxNoOfTables=20320
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=2048

[ndb_mgmd]
NodeId=1
HostName=192.168.1.1
DataDir=/usr/local/mysql-cluster/logs

[ndbd]
NodeId=2
HostName=192.168.1.1
DataDir=/usr/local/mysql-cluster/data

[mysqld]
NodeId=3
HostName=192.168.1.1

[ndbd]
NodeId=4
HostName=192.168.1.2
DataDir=/usr/local/mysql-cluster/data

[mysqld]
NodeId=5
HostName=192.168.1.2

[mysqld]

-------------------------------------------------------------------
开始编辑  insert键
退出编辑  esc键
保存退出  :wq
强制退出  :q!

数据节点配置

touch /usr/local/mysql/error.log

touch /usr/local/mysql/mysql.pid

vi  /usr/local/mysql/support-files/my-default.cnf
--------------------------------------------------------------------
[mysqld]
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data/mysql
pid-file = /usr/local/mysql/mysql.pid

log-error = /usr/local/mysql/error.log

user = root

port = 3306

tmp_table_size = 256M
max_heap_table_size = 256M

ndbcluster
ndb-connectstring=192.168.1.1

[mysql_cluster]
ndb-connectstring=192.168.1.1

[ndbd]
ndb-connectstring=192.168.1.1

[mysql_safe]
log-error = /usr/local/mysql/error.log
--------------------------------------------------------------------
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf

启动

管理节点
/usr/local/mysql-cluster/ndb_mgmd --configdir=/usr/local/mysql-cluster -f /usr/local/mysql-cluster/config.ini --initial --reload
/usr/local/mysql-cluster/ndb_mgm -e show    查看和管理
/usr/local/mysql-cluster/ndb_mgm -e shutdown    关闭集群
/usr/local/mysql-cluster/ndb_mgm -e exit   (退出
数据节点
/usr/local/mysql-cluster/ndbd --initial
SQL节点
新增用户组mysql和用户msyql
groupadd mysql
useradd -g mysql mysql
#(如果没有权限,可登录root去新增)
cd /usr/local/mysql
#修改文件权限
chown -R mysql:mysql ./
#初始化mysql
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data/mysql
(如果data ..有数据则新建data和data/mysql)
出现以下信息则标示成功
[Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 82246b8e-e62b-11e7-b5ad-000c29aa8807.
[Note] A temporary password is generated for root@localhost:hWuJyniWd3
,.
记下UUID和密码
#复制mysql到服务自动启动里面
cp support-files/mysql.server /etc/init.d/mysqld
#修改权限为755 也就是root可以执行
chmod 755 /etc/init.d/mysqld
#复制配置文件到etc下,因为默认启动先去etc下加载配置文件
cp support-files/my-default.cnf /etc/my.cnf

启动,重启,停止mysql服务
service mysqld start
service mysqld restart
service mysqld stop
查看mysql是否已启动
/etc/rc.d/init.d/mysqld status

linux下mysql错误

Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
-------------------------------------------------------------
Your password has expired. To log in you must change it using a client that supports expired passwords
-------------------------------------------------------------
Host is not allowed to connect to this MySQL server
-------------------------------------------------------------
Unable to connect with connect string: nodeid=0,172.24.221.100:1186

-------------------------------------------------------------

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/1006053
推荐阅读
相关标签
  

闽ICP备14008679号