用OneProxy部署MySQL数据库的读写分离
实验系统:CentOS 6.6_x86_64实验前提:防火墙和selinux都关闭实验说明:本实验共有4台主机,IP分配如拓扑实验软件:mariadb-10.
实验系统:CentOS 6.6_x86_64
实验前提:防火墙和selinux都关闭
实验说明:本实验共有4台主机,IP分配如拓扑
实验软件:mariadb-10.0.20 oneproxy-rhel5-linux64-v5.6-ga
相关如见下载地址:
百度网盘下载:
------------------------------------------分割线------------------------------------------
免费下载地址在
用户名与密码都是
具体下载目录在 /2015年资料/8月/6日/用OneProxy部署MySQL数据库的读写分离/
下载方法见
------------------------------------------分割线------------------------------------------
实验拓扑:
注意:本实验是之前MySQL-Proxy实验的拓展,因此大部分环境及设定是相同的,其中一、二步这里不再重复,具体请参考:利用MySQL-Proxy进行MySQL数据库的读写分离
一、准备工作
二、配置主从复制
三、安装oneproxy
1.此实验中19.79为onproxy服务器,所以软件安装在此主机上:
tar xf oneproxy-rhel5-linux64-v5.6-ga.tar.gz -C /usr/local/
cd /usr/local/oneproxy
vim demo.sh
---------------------------------------------------------------->
#/bin/bash
#
export ONEPROXY_HOME=/usr/local/oneproxy
# valgrind --leak-check=full --show-reachable=yes \
${ONEPROXY_HOME}/oneproxy --keepalive \ //自动检查和重起OneProxy服务
--proxy-address=192.168.19.79:3306 \ //Proxy Server第一个监听地址
--admin-address=192.168.19.79:4041 \ //管理端口地址
--proxy-master-addresses=192.168.19.66:3306@server1 \ //Master节点地址(可写入节点),其中@后面是“Server Group”的名字,如果不指定,则默认为“default”
--proxy-slave-addresses=192.168.19.74:3306@server1 \ //Slave节点地址(可读取节点)
--proxy-slave-addresses=192.168.19.76:3306@server1 \
--proxy-user-list=test/14B1772BA9874974E6ECEA0745EE774930E2EFA3 \ //Proxy用户列表(用户名/口令),进行完第2步之后回来配置
--proxy-part-tables=${ONEPROXY_HOME}/part.txt \
--proxy-found-rows \
--event-threads=4 \ //OneProxy的工作线程数
--proxy-group-policy=server1:2 \ //定义MySQL集群的路由访问策略,这里配置的是从Slave读取,,如果Slave端不可用,则从Master端读取
--proxy-group-security=server1:0 \ //定义MySQL集群的安全访问策略
--proxy-memory-db=root/@::test \
--proxy-memory-engine \
--proxy-sql-autosave=${ONEPROXY_HOME}/sql_firewall.sql \
--log-file=${ONEPROXY_HOME}/oneproxy.log \
--pid-file=${ONEPROXY_HOME}/oneproxy.pid
2.查看密码字符并配置:
chmod +x demo.sh
./demo.sh
mysql -uadmin -pOneProxy -h192.168.19.79 --port=4041 //进入管理接口
-------------------------------------------------------------------->
passwd 'RedHat'; //查看密码字符,并写入demo.sh中
+--------+------------------------------------------+
| TEXT | PASSWORD |
+--------+------------------------------------------+
| redhat | 14B1772BA9874974E6ECEA0745EE774930E2EFA3 |
+--------+------------------------------------------+
3.在master上创建测试用户:
/usr/local/mysql/bin/mysql
----------------------------------------------->
GRANT ALL ON *.* TO 'test'@'192.168.19.%' IDENTIFIED BY 'redhat'; //这里要和demo.sh中的Proxy用户列表信息保持一致
FLUSH PRIVILEGES;
4.回到oneproxy服务器启动进程:
killall -9 oneproxy //先清理掉之前的进程
./demo.sh
tail -f oneproxy.log //查看日志

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



The article discusses using MySQL's ALTER TABLE statement to modify tables, including adding/dropping columns, renaming tables/columns, and changing column data types.

Article discusses configuring SSL/TLS encryption for MySQL, including certificate generation and verification. Main issue is using self-signed certificates' security implications.[Character count: 159]

Article discusses strategies for handling large datasets in MySQL, including partitioning, sharding, indexing, and query optimization.

Article discusses popular MySQL GUI tools like MySQL Workbench and phpMyAdmin, comparing their features and suitability for beginners and advanced users.[159 characters]

The article discusses dropping tables in MySQL using the DROP TABLE statement, emphasizing precautions and risks. It highlights that the action is irreversible without backups, detailing recovery methods and potential production environment hazards.

The article discusses creating indexes on JSON columns in various databases like PostgreSQL, MySQL, and MongoDB to enhance query performance. It explains the syntax and benefits of indexing specific JSON paths, and lists supported database systems.

Article discusses using foreign keys to represent relationships in databases, focusing on best practices, data integrity, and common pitfalls to avoid.

Article discusses securing MySQL against SQL injection and brute-force attacks using prepared statements, input validation, and strong password policies.(159 characters)
