zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Mycat 运行与基础操作2

2023-04-18 14:27:32 时间

准备

巧妇难为无米之炊,Mycat 本身并没有存储引擎,所以得事先准备好,主要是以下几点

  • 在192.168.100.101提前创建三个数据库
mysql> ! ip a | grep eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.100.101/24 brd 192.168.100.255 scope global eth2
mysql> show databases like "my_";
+----------------+
| Database (my_) |
+----------------+
| my1            |
| my2            |
| my3            |
+----------------+
3 rows in set (0.00 sec)

mysql> 
  • 在192.168.100.202提前创建一个数据库
mysql> ! ip a | grep eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.100.202/24 brd 192.168.100.255 scope global eth2
mysql> show databases like "my_";
+----------------+
| Database (my_) |
+----------------+
| my4            |
+----------------+
1 row in set (0.01 sec)

mysql> 
  • 在192.168.100.101提前创建一个拥有足够权限的用户
mysql> ! ip a | grep eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.100.101/24 brd 192.168.100.255 scope global eth2
mysql> show grants for root@'%';
+--------------------------------------------------------------------------------------------------------------+
| Grants for root@%                                                                                            |
+--------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' |
+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>
  • 在192.168.100.202提前创建一个拥有足够权限的用户
mysql> ! ip a | grep eth2
3: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    inet 192.168.100.202/24 brd 192.168.100.255 scope global eth2
mysql> show grants for root@'%';
+--------------------------------------------------------------------------------------------------------------+
| Grants for root@%                                                                                            |
+--------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' |
+--------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> 
  • 防火墙上开放192.168.100.101 和 192.168.100.202 的3306端口
[root@h101 ~]# iptables -L -nv | grep 3306
   13   780 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:3306 
[root@h101 ~]#