首页 文章 精选 留言 我的

精选列表

搜索[PD分离],共10006篇文章
优秀的个人博客,低调大师

[PHP] Larval 主从读写分离配置

在DB的连接工厂中找到以下代码 .../vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php /** * Get the read configuration for a read / write connection. * * @param array $config * @return array */ protected function getReadConfig(array $config) { $readConfig = $this->getReadWriteConfig($config, 'read'); return $this->mergeReadWriteConfig($config, $readConfig); } /** * Get a read / write level configuration. * * @param array $config * @param string $type * @return array */ protected function getReadWriteConfig(array $config, $type) { if (isset($config[$type][0])) { return $config[$type][array_rand($config[$type])]; } return $config[$type]; } /** * Merge a configuration for a read / write connection. * * @param array $config * @param array $merge * @return array */ protected function mergeReadWriteConfig(array $config, array $merge) { return array_except(array_merge($config, $merge), ['read', 'write']); } 工厂类通过随机获取读DB配置来进行读取操作,由此可推出DB的配置应该如下 'mysql' => [ 'write' => [ 'host' => '192.168.1.180', ], 'read' => [ ['host' => '192.168.1.182'], ['host' => '192.168.1.179'], ], 'driver' => 'mysql', 'database' => 'database', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ] 加强版,支持多主多从,支持独立用户名和密码,配置如下 'mysql' => [ 'write' => [ [ 'host' => '192.168.1.180', 'username' => '', 'password' => '', ], ], 'read' => [ [ 'host' => '192.168.1.182', 'username' => '', 'password' => '', ], [ 'host' => '192.168.1.179', 'username' => '', 'password' => '', ], ], 'driver' => 'mysql', 'database' => 'database', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ] 验证开启MySQL的general-log,通过tail -f的方式监控log变化来确定配置是否生效

优秀的个人博客,低调大师

nginx与tomcat结合,动静分离

我们的网站是nginx+tomcat架构,前端用nginx来处理静态内容,动态的全交给tomcat来处理。之前的SA配置太过于简单,而且没有仔细梳理网站的流程。nginx与tomcat的安装就不说了,很easy,直接贴配置文件,作个笔记 nginx虚拟主机段配置 server{ listen80; server_namewww.xxxx.com192.168.8.62; indexindex.htmlindex.htmindex.action; root/var/www/; if($document_uri~*"\.xhtml$"){ rewrite^/(.*).xhtml$/$1.actionlast; } location~*\.(action|svl)?${ includeproxy.conf; proxy_redirectoff; proxy_passhttp://127.0.0.1:8080; } location~(favicon.ico){ log_not_foundoff; expiresmax; } location~*^/(WEB-INF)/{ denyall; } location/nginx_status{ stub_statuson; #auth_basic"nginxstatus"; #auth_basic_user_file/usr/local/apache/htdocs/.htpasswd; access_logoff; allow192.168.8.253; allow127.0.0.1; denyall; } } tomcat主配置文件主要部分 <Hostname="www.jinfeicui.com"appBase="webapps" unpackWARs="true"autoDeploy="true" xmlValidation="false"xmlNamespaceAware="false"> <Contextpath="/"docBase="/var/www/"reloadable="true"debug="0"> </Context> 本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/863095,如需转载请自行联系原作者

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册