1.新建3台虚拟机
#配置三台主机设置
vi /etc/hosts
#2. 3台机配置yum源
mv /etc/yum.repos.d/* /media/
vi /etc/yum.repos.d/local.repo
mount /dev/cdrom /opt/gpmall-repo
#3.Mycat安装Java
yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
java -version
#4 主和从机安装mariadb
yum install -y mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb
#5初始化mariadb (db1+db2)
mysql_secure_installation
#5配置主从节点都要配置
vim /etc/my.cnf
systemctl restart mariadb
#重启Mariadb
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#6开放主节点的数据库权限
mysql-uroot -p123456
#7配置从节点连接主节点
mysql-uroot -p123456
#8验证主从数据库的同步功能
主机:
#从机
#9部署Mycat读写分离中间件服务
tar -zxvf Mycat-server-1.6-RELEASE-20161028204710-linux.tar.gz -C /usr/local/
chown -R 777 /usr/local/mycat/
echo export MYCAT_HOME=/usr/local/mycat/ >> /etc/profile
#添加系统变量,并生效变量
source /etc/profile
#给主从机配置xml,给权限
vim /usr/local/mycat/conf/schema.xml
chown root:root /usr/local/mycat/conf/schema.xml
vim /usr/local/mycat/conf/server.xml
/bin/bash /usr/local/mycat/bin/mycat start
#开mycat
netstat -ntpl
yum -y install mariadb-client
#没有就mariadb*
mysql -h127.0.0.1 -P8066 -uroot -p123456
#添加服务添加表数据
#验证Mycat服务对数据库读写操作分离