mysql> create database school;##创建school数据库
Query OK,1 row affected (0.00 sec)
从服务器1:
mysql> show databases;##查看数据库+--------------------+| Database |+--------------------+| information_schema ||#mysql50#.mozilla || mysql || performance_schema || school || test |+--------------------+6 rows inset(0.01 sec)
从服务器2:
mysql> show databases;##查看数据库+--------------------+| Database |+--------------------+| information_schema ||#mysql50#.mozilla || mysql || performance_schema || school || test |+--------------------+6 rows inset(0.01 sec)
实现主从同步
9、配置amoeba服务器
[root@amoeba ~]# systemctl stop firewalld.service ##关闭防火墙[root@amoeba ~]# setenforce 0[root@amoeba ~]# mount.cifs //192.168.10.107/LNMP-C7 /mnt/ ##挂载
Password for root@//192.168.10.107/LNMP-C7:[root@amoeba ~]# cd /mnt/[root@amoeba mnt]# ls[root@amoeba mnt]# cp jdk-6u14-linux-x64.bin /usr/local/ ##复制jdk二进制文件到/usr/local下[root@amoeba mnt]# cd /usr/local/[root@amoeba local]# ./jdk-6u14-linux-x64.bin ##直接执行安装
Do you agree to the above license terms? [yes or no]
yes ##选择yes进行安装
Press Enter to continue.....##回车继续[root@amoeba local]# mv jdk1.6.0_14/ /usr/local/jdk1.6 ##简化文件名[root@amoeba local]# vim /etc/profile ##设置环境变量##末行插入
export JAVA_HOME=/usr/local/jdk1.6##家目录
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib ##class环境变量
export PATH=$JAVA_HOME/lib:$JAVA_HOME/jre/bin/:$PATH:$HOME/bin##环境变量
export AMOEBA_HOME=/usr/local/amoeba ##amoeba家目录
export PATH=$PATH:$AMOEBA_HOME/bin##环境变量[root@amoeba local]# source /etc/profile ##刷新配置文件[root@amoeba local]# mkdir /usr/local/amoeba ##创建amoeba目录[root@amoeba local]# cd /mnt/[root@amoeba mnt]# tar zxvf amoeba-mysql-binary-2.2.0.tar.gz -C /usr/local/amoeba ##解压amoeba[root@amoeba mnt]# chmod -R 755 /usr/local/amoeba/ ##设置权限[root@amoeba mnt]# /usr/local/amoeba/bin/amoeba ##检查是否安装成功
amoeba start|stop
10、在master,slave1,slave2上提权amoeba访问权限
grant all on *.* to test@'192.168.28.%' identified by '123.com';##给amoeba访问权限用户test密码123.com
[root@client ~]# mysql -u amoeba -p123456 -h 192.168.13.160 -P8066 ##使用amoeba账户密码登录amoeba
MySQL [(none)]> show databases;##查看数据库+--------------------+| Database |+--------------------+| information_schema ||#mysql50#.mozilla || mysql || performance_schema || school || test |+--------------------+6 rows inset(0.00 sec)
MySQL [(none)]> use school;##使用数据库
Database changed
MySQL [school]> create table info (##创建表->idint(4)not null primary key,-> name varchar(10)not null,-> score decimal(4,1)not null);
Query OK,0 rows affected (0.02 sec)
查看主从服务器上是否有创建的表
mysql> use school;##使用数据库
Database changed
mysql> show tables;##查看表+------------------+| Tables_in_school |+------------------+| info |+------------------+1 row inset(0.00 sec)