twemproxy https://github.com/twitter/twemproxy tar -xvzf twemproxy-0.5.0.tar.gz cd twemproxy-0.5.0 ./configure --prefix=/usr/local/twemproxy make make install ln -s /usr/local/twemproxy/sbin/nutcracker /usr/sbin/nutcracker cd /usr/local/twemproxy/ mkdir conf run vi ./conf/nutcracker.yml Add: alpha: listen: 127.0.0.1:22121 hash: fnv1a_64 distribution: ketama auto_eject_hosts: true redis: true server_retry_timeout: 2000 server_failure_limit: 1 servers: - 127.0.0.1:6379:1 Test config file: nutcracker -t -c /usr/local/twemproxy/conf/nutcracker.yml nutcracker -d -c /usr/local/twemproxy/conf/nutcracker.yml -p /usr/local/twemproxy/run/redisproxy.pid -o /usr/local/twemproxy/run/redisproxy.log Test: redis-cli -p 22121 注意: Laravel还需要将config文件夹下的database.php中的redis配置里的 'database' => 0注释掉,predis 对这个配置默认执行 select 操作,会导致连接错误。
apt-get install -y lsb-release apt-transport-https wget -O - 'https://repo.proxysql.com/ProxySQL/repo_pub_key' | apt-key add - echo deb https://repo.proxysql.com/ProxySQL/proxysql-2.1.x/$(lsb_release -sc)/ ./ \ | tee /etc/apt/sources.list.d/proxysql.list apt-get update apt-get install proxysql service proxysql start service proxysql stop service proxysql restart mysql -uadmin -padmin -h127.0.0.1 -P6032 --prompt='Admin> ' --default-auth=mysql_native_password SET mysql-eventslog_filename='queries.log'; insert into mysql_servers(hostgroup_id,hostname,port,weight,comment) values(1,'10.0.16.1',3306,1,'主库'); select * from mysql_servers; 创建MySQL主从账号 CREATE USER 'proxysql'@'%' IDENTIFIED BY '123456'; GRANT ALL PRIVILEGES ON *.* TO 'proxysql'@'%' WITH GRANT OPTION; 添加主从账号到ProxySQL insert into mysql_users(username,password,default_hostgroup,transaction_persistent)values('proxysql','123456',1,1); 查看主从账号ProxySQL select * from mysql_users; 配置生效【ProxySQL】 //加载到内存 load mysql users to runtime; load mysql servers to runtime; load mysql query rules to runtime; load mysql variables to runtime; load admin variables to runtime; //永久生效 save mysql users to disk; save mysql servers to disk; save mysql query rules to disk; save mysql variables to disk; save admin variables to disk; https://zhuanlan.zhihu.com/p/110733834 注意: Lravel如果报错:Syntax error or access violation: 1231 Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER' 需要修改config/database.php: 'strict' => false,