• 欢迎访问VPS岛网站,国外VPS,国内VPS,国外服务器,国内服务器,服务器主机,测评及优惠码,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站 QQ群

mysql_cluster

mysql技术 mailfile 71次浏览 已收录 0个评论

实验环境

centos7_x64

mysqladmin  192.168.10.17

mysqldata1   192.168.10.19

mysqldata2   192.168.10.18

41.jpg

实验软件

mysql57-community-release-el7-11.noarch.rpm 

软件安装

cp -pv /etc/hosts /etc/hosts.bak

echo  192.168.10.17 mysqladmin >> /etc/hosts

echo  192.168.10.19 mysqldata1 >> /etc/hosts

echo  192.168.10.18 mysqldata2 >> /etc/hosts 

hostnamectl set-hostname mysqladmin/mysqldata1/mysqldata2    mysqladmin/mysqldata1/mysqldata2

systemctl stop firewalld.service && systemctl disable firewalld.service

systemctl restart ntpd.service && systemctl enable ntpd.service  mysqladmin/mysqldata1/mysqldata2

ntpdate 192.168.10.17 && clock -w

sed -i ‘s/https/http/g’ /etc/yum.repos.d/epel.repo

sed -i ‘s/gpgcheck=1/gpgcheck=0/g’ /etc/yum.repos.d/*.repo

yum install -y lsof pytho-scp openssh-server openssh-client axel lsof ntp

yum install -y perl perl-Class-MethodMaker perl-DBI  libaio numactl        

rpm -ivh /root/mysql57-community-release-el7-11.noarch.rpm 

sed -i.bak “55s/0/1/g” /etc/yum.repos.d/mysql-community.repo

yum install -y mysql-cluster-community-server   mysqladmin操作

systemctl restart mysqld.service &&  systemctl enable mysqld.service

systemctl restart ntpd.service && systemctl enable ntpd.service

ntpdate 192.168.10.17 && clock -w

yum install -y perl perl-Class-MethodMaker perl-DBI  libaio numactl 

sed -i.bak “55s/0/1/g” /etc/yum.repos.d/mysql-community.repo    mysqldata1/mysqldata2操作

yum install -y mysql-cluster-community-server  

yum install -y mysql-cluster-community-data-node  

yum install -y mysql-cluster-community-management-server 

systemctl restart mysqld.service &&  systemctl enable mysqld.service 

cp -pv /etc/my.cnf /etc/my.cnf.bak

cat /etc/my.cnf

[mysqld]

skip-grant-tables       此选项适用于修改root密码 

systemctl restart  mysqld.service 

mysql -uroot -p   密码为空

mysql> use mysql;

mysql> update user set authentication_string=password(‘123456′) where user=’root’;

mysql> flush privileges;

mysql -uroot -p数据库密码

mysql>                               mysqladmin/mysqldata1/mysqldata2操作

sed -i “55s/0/1/g” /etc/yum.repos.d/mysql-community.repo    mysqladmin操作

yum install -y perl perl-Class-MethodMaker perl-DBI  libaio numactl

yum install -y mysql-cluster-community-server

yum install -y mysql-cluster-community-management-server

systemctl restar mysql.service  && systemctl enable mysqld.service

sed -i “55s/0/1/g” /etc/yum.repos.d/mysql-community.repo    mysqladmin操作

yum install -y perl perl-Class-MethodMaker perl-DBI  libaio numactl

yum install -y mysql-cluster-community-server

yum install -y mysql-cluster-community-data-node

yum install -y mysql-cluster-community-management-server

systemctl restar mysql.service  && systemctl enable mysqld.service  

mkdir -pv  /etc/mysql-cluster && touch /etc/mysql-cluster/config.ini  mysqladmin操作

cat /etc/mysql-cluster/config.ini 

[ndbd default]

NoOfReplicas=2                                

DataMemory=500M                               

IndexMemory=100M                              

[ndb_mgmd]

nodeid=1

datadir=/var/lib/mysql                       

HostName=192.168.10.17                                           

[ndbd]

HostName=192.168.10.19

DataDir=/var/lib/mysql                           

nodeid=2

[ndbd]

HostName=192.168.10.18

DataDir=/var/lib/mysql                            

nodeid=3                             

[mysqld]

HostName=192.168.10.19

nodeid=4

[mysqld]

HostName=192.168.10.18

nodeid=5

cat /etc/my.cnf       mysqldata1/mysqldata2操作

[mysqld]

datadir=/var/lib/mysql

ndbcluster     

ndb-connectstring=192.168.10.17 

[mysqld_safe]  

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[mysql_cluster

ndb-connectstring=192.168.10.17

cat /etc/my.cnf     mysqldata2操作

[mysqld]

ndbcluster                                 

ndb-connectstring=192.168.10.17

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[mysql_cluster]  

ndb-connectstring=192.168.10.17

先启动:管理结点服务->数据结点服务->sql结点服务

ndb_mgmd –ndb_nodeid=1 –initial -f /etc/mysql-cluster/config.ini   mysqladmin操作

ndbd –initial   mysqldata1/mysqldata2操作

ndb_mgm       mysqladmin操作

ndb_mgm> show 

[ndbd(NDB)]2 node(s)

id=2 (not connected, accepting connect from mysqldata1)

id=3@192.168.10.18  (mysql-5.7.30 ndb-7.5.18, starting, Nodegroup: 0)

[ndb_mgmd(MGM)]1 node(s)

id=1@192.168.10.17  (mysql-5.7.30 ndb-7.5.18)

[mysqld(API)]2 node(s)

id=4 (not connected, accepting connect from mysqldata1)

id=5 (not connected, accepting connect from mysqldata2)

ndb_mgm> 

netstat -tuplna | grep 33

tcp        0      0 192.168.10.18:33160     192.168.10.17:1186      ESTABLISHED 2229/ndbd           

tcp        0      0 192.168.10.18:33164     192.168.10.17:1186      ESTABLISHED 2230/ndbd           

tcp        0      0 192.168.10.18:33162     192.168.10.17:1186      ESTABLISHED 2230/ndbd           

tcp6       0      0 :::3306                 :::*                    LISTEN      986/mysqld     

netstat -tuplna | grep ndb_mgmd

tcp        0      0 0.0.0.0:1186            0.0.0.0:*               LISTEN      12837/ndb_mgmd      

tcp        0      0 127.0.0.1:1186          127.0.0.1:45212         ESTABLISHED 12837/ndb_mgmd      

tcp        0      0 192.168.10.17:1186      192.168.10.18:33164     ESTABLISHED 12837/ndb_mgmd      

tcp        0      0 127.0.0.1:45212         127.0.0.1:1186          ESTABLISHED 12837/ndb_mgmd      

tcp        0      0 192.168.10.17:1186      192.168.10.18:33162     ESTABLISHED 12837/ndb_mgmd      

tcp        0      0 192.168.10.17:1186      192.168.10.18:33160     ESTABLISHED 12837/ndb_mgmd  


VPS岛 的文章和资源来自互联网,仅作为参考资料,如果有侵犯版权的资源请尽快联系站长,我们会在24h内删除有争议的资源。丨 转载请注明mysql_cluster
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址