Codis是一个开源的分布式redis解决方案,由以下四个组件组成:codis-proxy:后端redis的代理,本事实现了redis协议。codis-config:是codis的管理配置工具,用于..
Codis是一个开源的分布式redis解决方案,由以下四个组件组成:
codis-proxy:后端redis的代理,本事实现了redis协议。
codis-config:是codis的管理配置工具,用于增删redis server、操作数据迁移。
zookeeper:用来存放数据路由表和codis-proxy节点的元信息,codis-config发起的命令都会通过 zookeeper同步到各个存活的codis-proxy。
codis-server:codis项目维护的一个 redis 分支, 基于 2.8.13 开发, 加入了 slot 的支持和原子的数据迁移指令,如果要使用codis的在线扩展迁移功能的话必须使用codis自带的codis-server,codis不支持对原生redis做在线的扩展和数据迁移。
节点规划:
codis-proxy
192.168.0.100:19000
codis-config
192.168.0.100
codis-server1
192.168.0.100:6381
codis-server2192.168.0.100:6382
codis-server3192.168.0.100:6380
codis-server4192.168.0.100:6383
1、安装配置
a、首先安装golang
## 解压下载好的go软件包 $ tar xf/opt/go1.4.2.linux-amd64.tar.gz -C/usr/local/ ## 配置环境变量 在.bash_profile中加入go的相关环境变量,并使新的环境变量生效 PATH=$PATH:$HOME/bin exportGOROOT=/usr/local/go exportGOOS=linux exportGOARCH=amd64 exportGOBIN=$GOROOT/bin exportGOPATH=/opt/mygo PATH=$PATH:$GOBIN export PATH ##编写一个 测试程序验证go是否安装成功 $ cat hello.go package main import"fmt" func main() { fmt.Printf("hello, world\n") } ## 运行测试程序,输出hello,word说明go已经安装成功 $ go run hello.go hello, worldb、安装codis
## 安装工具软件 $ yum install gccmake git -y ## 下载codis,会下载到环境变量GOPATH指定的目录 $ go get github.com/wandoulabs/codis#ssdb-server config packagegithub.com/wandoulabs/codis imports github.com/wandoulabs/codis imports github.com/wandoulabs/codis: nobuildable Go source files in /opt/mygo/src/github.com/wandoulabs/codis ## 下载完成后进入/opt/mygo/src/github.com/wandoulabs/codis $ cd /opt/mygo/src/github.com/wandoulabs/codis ## 执行安装命令 $ ./bootstrap.sh ## 这一步时间稍久,会下载一些文件目录到本地,耐心等待即可c、安装zookeeper
## 解压zookeeper $ tar xfzookeeper-3.4.6.tar.gz -C /opt/ ## 进入zk的安装目录,修改配置文件 $ cd /opt/zookeeper-3.4.6 $ cp conf/zoo_sample.cfgconf/zoo.cfg $ vim conf/zoo.cfg tickTime=2000 initLimit=10 syncLimit=5 dataDir=/data/zookeeper dataLogDir=/opt/zookeeper-3.4.6/logs clientPort=2181 ## 创建所需要的目录 mkdir /data/zookeeper -p mkdir /opt/zookeeper-3.4.6/logs ## 启动zk $ /opt/zookeeper-3.4.6/bin/zkServer.sh start JMX enabled bydefault Using config:/opt/zookeeper-3.4.6/bin/../conf/zoo.cfg Starting zookeeper... STARTED ## 验证是否启动成功,若2181端口被监听,则表示成功 $ netstat-alnut|grep 2181 tcp 0 0 :::2181 :::* LISTENd、配置codis
## codis中配置zk的信息 $ cd /opt/mygo/src/github.com/wandoulabs/codis/sample/ ## 修改config.ini $ vim config.ini zk=localhost:2181 product=codis_proxy proxy_id=proxy_1 net_timeout=5 dashboard_addr=localhost:18087 coordinator=zookeeper2、启动codis
a、
:
b、初始化slots
##进入相关目录 $ cd /opt/mygo/src/github.com/wandoulabs/codis/sample/ ## 执行初始化 $ ../bin/codis-config slot init { "msg": "OK", "ret": 0 }c、启动codis-server
## codis自带有一个启动脚本,会启动两个codis-server,监听端口为6381和6382 [root@mgs02 sample]#./start_redis.sh sleep 3s [6294] 09 Apr 14:28:02.796* Increased maximum number of open files to 10032 (it was originally set to1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.13 (1e823fd3/1) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6381 | `-._ `._ / _.-' | PID: 6294 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6294] 09 Apr14:28:02.814 # Server started, Redis version 2.8.13 [6294] 09 Apr14:28:02.814 # WARNING overcommit_memory is set to 0! Background save may failunder low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to/etc/sysctl.conf and then reboot or run the command 'sysctlvm.overcommit_memory=1' for this to take effect. [6294] 09 Apr14:28:02.814 * The server is now ready to accept connections on port 6381 [6295] 09 Apr14:28:02.795 * Increased maximum number of open files to 10032 (it wasoriginally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.13 (1e823fd3/1) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6382 | `-._ `._ / _.-' | PID: 6295 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6295] 09 Apr14:28:02.811 # Server started, Redis version 2.8.13 [6295] 09 Apr14:28:02.811 # WARNING overcommit_memory is set to 0! Background save may failunder low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to/etc/sysctl.conf and then reboot or run the command 'sysctlvm.overcommit_memory=1' for this to take effect. [6295] 09 Apr 14:28:02.812 * The server is nowready to accept connections on port 6382
TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
