mysql-cluster安裝和部署

軍說網事發表於2016-03-31

一>刪除以前安裝的內容

1 rpm -qa | grep mysql

2 find / -name mysql


3 重點是以前的資料檔案和庫檔案/usr/local、/var/lib。


二>安裝

yum install iptables-services -y

yum install -y perl perl-devel

yum remove mysql

rm -rf /var/lib/mysql

cp -f my.cnf /etc/

mkdir /usr/local/mysql

tar -zxvfmysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64.tar.gz

mvmysql-cluster-gpl-7.4.6-linux-glibc2.5-x86_64 /usr/local/mysql/mysqlc

 

vi /etc/passwd 檢視有沒有mysql使用者。

groupadd mysql

useradd mysql -g mysql

chown -R mysql:mysql /usr/local/mysql

 

cd /usr/local/mysql/mysqlc

scripts/mysql_install_db --user=mysql

這裡會出現問題:

[root@vmware-143 mysqlc]#scripts/mysql_install_db --user=mysql

FATAL ERROR: please install the followingPerl modules before executing scripts/mysql_install_db:

Data::Dumper

 

需要安裝yum install -y perl-Module-Install.noarch

 

mkdir /usr/local/mysql/bin

cp -f /usr/local/mysql/mysqlc/bin/ndbd  /usr/local/mysql/bin

cp -f/usr/local/mysql/mysqlc/bin/ndb_mgm  /usr/local/mysql/bin

cp -f /usr/local/mysql/mysqlc/bin/ndb_mgmd/usr/local/mysql/bin

 

mkdir /usr/local/mysql/etc

cd /usr/local/my_cluster_step/

cp -f config.ini /usr/local/mysql/etc/

 

cp -f/usr/local/mysql/mysqlc/support-files/mysql.server /etc/init.d/mysqld

 

三>配置

1 my.cnf 修改裡的ip為管理節點的ip。

cp -f my.cnf /etc/

 

2 config.ini

cp -f config.ini /usr/local/mysql/etc/

 

四>啟動

1 啟動管理節點

cd /usr/local/mysql/bin

/usr/local/mysql/bin/ndb_mgmd -f/usr/local/mysql/etc/config.ini –initial

 

2 啟動ndb節點

cd /usr/local/mysql/bin/

sh ndbd –initial

 

3 啟動mysql節點

service mysqld start

 

五>訪問配置

1

[root@vmware-142 bin]# mysql -u root

ERROR 2002 (HY000): Can't connect to localMySQL server through socket '/tmp/mysql.sock' (2)

 

解決方法:

ln -s /usr/local/mysql/mysqlc/mysql.sock/tmp/mysql.sock

或者

mysql -uroot -p -S/usr/local/mysql/mysqlc/mysql.sock

 

2 進入mysql後,

  mysql> use mysql;

 

  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user= 'root';

 

  mysql> FLUSH PRIVILEGES;

 

3 訪問

1)is not allowed toconnect to this MySQL server

可能是防火牆的問題

iptables -I INPUT -ptcp --dport 3306 -j ACCEPT

service iptables restart 

不能重啟,重啟就不能訪問了。

 serviceiptables stop 停止防火牆

方法二:開啟vim/etc/sysconfig/iptables 新增所需配置的埠-A INPUT -p tcp -mstate --state NEW -m tcp --dport 3306 -j ACCEPT

 

2)can not connect to mysql server on  10038


相關文章