Home Database Mysql Tutorial 用OneProxy部署MySQL数据库的读写分离

用OneProxy部署MySQL数据库的读写分离

Jun 07, 2016 pm 03:21 PM

实验系统: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数据库的读写分离/

下载方法见

------------------------------------------分割线------------------------------------------

实验拓扑:

用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          //查看日志

用OneProxy部署MySQL数据库的读写分离

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

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

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

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]

How do you handle large datasets in MySQL? How do you handle large datasets in MySQL? Mar 21, 2025 pm 12:15 PM

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

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

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

How do you drop a table in MySQL using the DROP TABLE statement? How do you drop a table in MySQL using the DROP TABLE statement? Mar 19, 2025 pm 03:52 PM

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.

How do you create indexes on JSON columns? How do you create indexes on JSON columns? Mar 21, 2025 pm 12:13 PM

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.

How do you represent relationships using foreign keys? How do you represent relationships using foreign keys? Mar 19, 2025 pm 03:48 PM

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

How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? How do I secure MySQL against common vulnerabilities (SQL injection, brute-force attacks)? Mar 18, 2025 pm 12:00 PM

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

See all articles