首页 文章 精选 留言 我的

精选列表

搜索[MLA架构],共10000篇文章
优秀的个人博客,低调大师

消息提示的架构演进-理论篇

本文转自 virusswb 51CTO博客,原文链接:http://blog.51cto.com/virusswb/685995,如需转载请自行联系原作者项目是一个互联网应用。 假设项目有不同的用户群体,每个用户群体的前端都是一个独立的项目,交给不同的开发人员进行开发,前端和后端的交互方式选择 WebService 。 在前端和后端交互的过程中,主要有两类操作:一类是查询,包括返回单个记录和返回集合两种类型的查询;一类是命令,包括添加、删除、更新,当然,一次操作也可能是几个命令的组合请求。 第一类操作需要返回数据来显示,如果没有返回数据就会提示没有找到符合条件的数据。第二类操作,一般会影响后端的持久化数据,需要返回操作的结果,是成功还是失败,还是如何如何? 今天讨论的消息就是这种后端返回的操作结果,关于这种类型消息的设计,主要是这种消息在前段的处理、显示的相关设计。 刚开始,没有进行设计,每个项目的开发者自己设计自己的消息提示格式、提示内容和 UI 显示。有的人用浏览器的 alert ,有的人用前端框架的消息提示框,还有的在一个项目中两种提示都用了。提示的方式大都是在和后端交互,获得结果之后, new 一个消息框,然后直接 show 出来。提示的内容也都是硬编码(在 new 消息框的时候,使用构造函数初始化)。 当然了,刚开始大家都各自为战,加紧时间赶工期,也都没有在意这些事情。在第一个迭代周期的总结会上,大家提出了这个问题,做了个总结。发现上面的做法会带来以下一些问题。 消息提示内容的硬编码。多个相同类型是消息(例如提示操作成功),如果变更这个类型提示的内容,需要在很多地方修改,几乎苦不堪言。 消息框的初始化是散落在各个和后台交互的地方的,如果需要变更一下消息框的UI,也会造成需要多个地方的修改,已经苦不堪言了。 消息的逻辑代码和UI显示代码是混合在一起的,没有分离,导致无法单元测试。 对于上面的问题,大家讨论了一下,可以通过下面的重构进行改进。 首先,将消息分类,方便后面的处理。 对于硬编码的问题,根据类型,将相同类型的内容集中管理,达到复用和便于后期维护的作用。 集中管理消息框的初始化工作,也可以方便消息框UI的变更,可以通过引入工厂模式来解决。 分离消息的逻辑和UI显示代码,方便单元测试和UI的变更。 建立一个消息中心,集中管理消息框的初始化,以及消息的显示。 这么做的目的有以下几点: 消息处理的独立 消息处理的公用 分离消息处理的逻辑和消息内容的UI显示 消息管理的集中 经过整理,消息大概分为下面的几类 成功。正确完成一次请求。 提示。在完成请求的过程中,缺少必要条件,或者是某些条件发生变化,导致不能正确完成请求。 异常。在完成请求的过程中,发生了异常,包括:代码异常,网络异常等等。 在后面的实现中,准备引入面向接口的编程,将消息中心和消息的处理接口化,方便将来的替换。消息框的初始化引入工厂模式,实现初始化的集中管理,隔离消息框(标题,提示内容,按钮,按钮的操作)和消息框UI显示,为将来的UI变更预留空间。 今天先讨论到这里,关于实现以及代码会在后面几篇分开讲解。 大家如果有什么更好的建议,可以在后面留言给我,感谢大家的参与!!!

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

模拟WALMART网络架构-双栈冗余

SiteA and Site B 通信 SiteA: 192.168.1.X 192.168.3.X SiteB: 192.168.2.X 192.168.4.X =====MPLS Router Configuration===== R1 2 3 4 5 6 ====〉代表不同的MPLS 供应商 Step1:--MPLS域启用MPLS ip cef mpls ip mpls ldp router-id lo0 force mpls label protocol ldp int s0/0 mpls ip int s0/1 mpls ip Step2:---MPLS域 IGP通 router eigrp 80 no auto net 0.0.0.0 passive-interface f0/0 Step3:---MPLS域 PE接口启用VRF R1: ip vrf walmart rd 100:13 --->对方可以不一致,本地意义区分私网路由 route-target 100:79 -----〉对方必须一致 int f0/0 ip vrf forwarding walmart ip add R3: ip vrf walmart rd 100:31 route-target 100:79 int f0/0 ip vrf forwarding walmart ip add 验证show ip vrf detail [brief] R4:/R6: ip vrf walmart rd 200:46[200:64] route-target 200:81 int f0/0 ip vrf forwarding walmart ip add Step4:----MPLS域 MBGP R1: router bgp 100 bgp router-id 1.1.1.1 bgp log-neighbor-changes no bgp default ipv4-unicast \\起手配 neighbor 3.3.3.3 remote-as 100 neighbor 3.3.3.3 update-source Loopback0 ! ! address-family vpnv4------\\MP BGP neighbor 3.3.3.3 activate neighbor 3.3.3.3 send-community extended exit-address-family address-family ipv4 vrf walmart----- EBGP neighbor 17.1.1.7 remote-as 300 neighbor 17.1.1.7 activate exit-address-family R3: router bgp 100 bgp router-id 3.3.3.3 bgp log-neighbor-changes no bgp default ipv4-unicast neighbor 1.1.1.1 remote-as 100 neighbor 1.1.1.1 update-source Loopback0 ! ! address-family vpnv4 neighbor 1.1.1.1 activate neighbor 1.1.1.1 send-community extended exit-address-family address-family ipv4 vrf walmart----- EBGP neighbor 39.1.1.9 remote-as 300 neighbor 39.1.1.9 activate exit-address-family 验证: sh ip bgp vpnv4 vrf walmart summary R3#sh ip bgp vpnv4 all summary ============================================= R4: router bgp 200 bgp router-id 4.4.4.4 bgp log-neighbor-changes no bgp default ipv4-unicast neighbor 6.6.6.6 remote-as 200 neighbor 6.6.6.6 update-source Loopback0 ! ! address-family vpnv4 neighbor 6.6.6.6 activate neighbor 6.6.6.6 send-community extended address-family ipv4 vrf walmart neighbor 48.1.1.8 remote-as 300 neighbor 48.1.1.8 activate R6: router bgp 200 bgp router-id 6.6.6.6 bgp log-neighbor-changes no bgp default ipv4-unicast neighbor 4.4.4.4 remote-as 200 neighbor 4.4.4.4 update-source Loopback0 ! ! address-family vpnv4 neighbor 4.4.4.4 activate neighbor 4.4.4.4 send-community extended address-family ipv4 vrf walmart neighbor 61.1.1.1 remote-as 400 neighbor 61.1.1.1 activate =============================================== Step5:-CE BGP 300 /400 R7-CE#sh run | b r b router bgp 300 bgp router-id 7.7.7.7 bgp log-neighbor-changes neighbor 17.1.1.1 remote-as 100 no network 7.7.7.7 mask 255.255.255.255 R9-CE#sh run | b r b router bgp 400 bgp router-id 9.9.9.9 bgp log-neighbor-changes neighbor 39.1.1.3 remote-as 100 no network 9.9.9.9 mask 255.255.255.255 R7-CE#traceroute 9.9.9.9 source 7.7.7.7 Type escape sequence to abort. Tracing the route to 9.9.9.9 VRF info: (vrf in name/id, vrf out name/id) 1 17.1.1.1 60 msec 32 msec 52 msec 2 12.1.1.2 [MPLS: Labels 19/18 Exp 0] 44 msec 40 msec 52 msec 3 39.1.1.3 [MPLS: Label 18 Exp 0] 48 msec 52 msec 52 msec 4 39.1.1.9 48 msec 48 msec 52 msec 察看标签 R1#sh ip bgp vpnv4 vrf walmart 9.9.9.9 BGP routing table entry for 100:13:9.9.9.9/32, version 3 Paths: (1 available, best #1, table walmart) Advertised to update-groups: 2 400, imported path from 100:31:9.9.9.9/32 3.3.3.3 (metric 2809856) from 3.3.3.3 (3.3.3.3) Origin IGP, metric 0, localpref 100, valid, internal, best Extended Community: RT:100:79 mpls labels in/out nolabel/18 R1#sh ip bgp vpnv4 vrf walmart 7.7.7.7 BGP routing table entry for 100:13:7.7.7.7/32, version 4 Paths: (1 available, best #1, table walmart) Advertised to update-groups: 1 300 17.1.1.7 from 17.1.1.7 (7.7.7.7) Origin IGP, metric 0, localpref 100, valid, external, best Extended Community: RT:100:79 mpls labels in/out 18/nolabel R1#show mpls forwarding-table Local Outgoing Prefix Bytes tag Outgoing Next Hop tag tag or VC or Tunnel Id switched interface 16 Pop tag 23.1.1.0/24 0 Se0/0 point2point 17 Pop tag 2.2.2.2/32 0 Se0/0 point2point 18 Untagged 7.7.7.7/32[V] 2796 Fa0/0 17.1.1.7 19 19 3.3.3.3/32 0 Se0/0 point2point =================================内网HSRP====================== R7-CE#sh run int f1/0.1 Building configuration... Current configuration : 206 bytes ! interface FastEthernet1/0.1 encapsulation dot1Q 1 native ip address 192.168.1.251 255.255.255.0 standby 1 ip 192.168.1.1 standby 1 priority 120 standby 1 preempt standby 1 track 1 decrement 30 end R7-CE#sh run int f1/0.3 Building configuration... Current configuration : 199 bytes ! interface FastEthernet1/0.3 encapsulation dot1Q 3 ip address 192.168.3.251 255.255.255.0 standby 3 ip 192.168.3.1 standby 3 priority 120 standby 3 preempt //开启抢占 standby 3 track 1 decrement 30 \\如果接口down了优先级减30 end R8-CE#sh run int f1/0.1 Building configuration... Current configuration : 182 bytes ! interface FastEthernet1/0.1 encapsulation dot1Q 1 native ip address 192.168.1.252 255.255.255.0 standby 1 ip 192.168.1.1 standby 1 preempt //standby 1 track 1 decrement 30 R8-CE#sh run int f1/0.3 Building configuration... Current configuration : 175 bytes ! interface FastEthernet1/0.3 encapsulation dot1Q 3 ip address 192.168.3.253 255.255.255.0 standby 3 ip 192.168.3.1 standby 3 preempt //standby 3 track 1 decrement 30 end =================CE IBGP============================= R7-CE#sh run | b r r router rip version 2 network 7.0.0.0 network 78.0.0.0 no auto-summary ! router bgp 300 bgp router-id 7.7.7.7 bgp log-neighbor-changes network 192.168.1.0 network 192.168.3.0 neighbor 8.8.8.8 remote-as 300 neighbor 8.8.8.8 update-source Loopback0 neighbor 8.8.8.8 next-hop-self neighbor 17.1.1.1 remote-as 100 R8-CE#sh run | b r r router rip version 2 network 8.0.0.0 network 78.0.0.0 no auto-summary ! router bgp 300 bgp router-id 8.8.8.8 bgp log-neighbor-changes neighbor 7.7.7.7 remote-as 300 neighbor 7.7.7.7 update-source Loopback0 neighbor 7.7.7.7 next-hop-self neighbor 48.1.1.4 remote-as 200 R7-CE#sh ip bgp BGP table version is 5, local router ID is 7.7.7.7 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path * i 192.168.1.0 8.8.8.8 0 100 0 i *> 0.0.0.0 0 32768 i *> 192.168.2.0 17.1.1.1 0 100 400 i * i 8.8.8.8 0 100 0 200 400 i * i 192.168.3.0 8.8.8.8 0 100 0 i *> 0.0.0.0 0 32768 i *> 192.168.4.0 17.1.1.1 0 100 400 i * i 8.8.8.8 0 100 0 200 400 i 但R7-R8不希望学习到内部路由192.168.1.0 192.168.3.0,我们可以过滤掉 IBGP 过滤内网路由 R7-CE#sh run | be ip prefix-list ip prefix-list deny seq 5 permit 192.168.1.0/24 ip prefix-list deny seq 10 permit 192.168.3.0/24 R7-CE#sh run | be route-map route-map block deny 10 match ip address prefix-list deny ! route-map block permit 20 R7: router bgp 300 neighbor 8.8.8.8 route-map block in R8: router bgp 300 neighbor 7.7.7.7 route-map block in R7-CE#sh ip bgp BGP table version is 5, local router ID is 7.7.7.7 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, x best-external, a additional-path, c RIB-compressed, Origin codes: i - IGP, e - EGP, ? - incomplete RPKI validation codes: V valid, I invalid, N Not found Network Next Hop Metric LocPrf Weight Path *> 192.168.1.0 0.0.0.0 0 32768 i * i 192.168.2.0 8.8.8.8 0 100 0 200 400 i *> 17.1.1.1 0 100 400 i *> 192.168.3.0 0.0.0.0 0 32768 i * i 192.168.4.0 8.8.8.8 0 100 0 200 400 i *> 17.1.1.1 0 100 400 i ======BUYTRIP场地 & internet========= R15: R15#sh run | b r e router eigrp 80 network 15.0.0.0 network 57.0.0.0 no auto-summary R7: ip route 0.0.0.0 0.0.0.0 61.1.1.6 R7-CE#sh run | b r b router bgp 300 redistribute eigrp 80 metric 400 network 0.0.0.0 mask 0.0.0.0 R7-CE#sh run | b r e router eigrp 80 network 57.0.0.0 redistribute bgp 300 metric 1000 100 255 1 1500 redistribute static R8: router bgp 300 bgp router-id 8.8.8.8 bgp log-neighbor-changes network 192.168.1.0 network 192.168.3.0 redistribute static metric 300 neighbor 7.7.7.7 remote-as 300 neighbor 7.7.7.7 update-source Loopback0 neighbor 7.7.7.7 next-hop-self neighbor 7.7.7.7 route-map block in neighbor 48.1.1.4 remote-as 200 EIGRP本地优化: access-list 10 permit 0.0.0.0 0.0.0.0 router ei 80 distribute-list 10 in fastEthernet 1/0 本文转自 bilinyee博客,原文链接: http://blog.51cto.com/ericfu/1963262 如需转载请自行联系原作者

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

实现动静分离的LNMMP网站架构

一、前提说明 1、实验目的 实现动静分享的LNMMP网站 2、实现功能 (1)前端nginx服务器(172.16.7.10)处理静态内容并向后转发动态内容 (2)php服务器(172.16.7.100)处理动态内容 (3)数据库为MariaDB,版本为mariadb-10.0.10,IP:172.16.7.200 (4)在动态系统中,为了减小数据库的压力,提高性能,增加memcached服务器(172.16.7.201) 3、实验拓扑 简单实验拓扑如下(因为都在一个网络内测试,所以前端nginx只给了一个IP): 二、安装nginx服务器(172.16.7.10) 1、解决依赖关系 在安装前,为了避免一些不必要的麻烦,首先装几个开发包组:"Development Tools"、"Server Platform Development"、并安装"pcre-devel包" 2、添加nginx用户,实现以nginx用户运行nginx服务进程 1 2 # groupadd -r nginx # useradd -r -g nginx nginx 3、编译安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 # ./configure \ --prefix= /usr/local/nginx \ #指定安装路径 --sbin-path= /usr/local/nginx/sbin/nginx \ #指定nginx程序路径 --conf-path= /etc/nginx/nginx .conf \ #指定配置文件路径 --error-log-path= /var/log/nginx/error .log \ #指定错误日志路径 --http-log-path= /var/log/nginx/access .log \ #指定访问日志路径 --pid-path= /var/run/nginx/nginx .pid \ #指定pid文件路径 --lock-path= /var/lock/nginx .lock \ #指定锁文件路径 --user=nginx \ #指定以nginx用户运行进程 --group=nginx \ --with-http_ssl_module \ #添加ssl模块 --with-http_flv_module \ #添加流媒体模块 --with-http_stub_status_module \ #添加服务器状态信息模块 --with-http_gzip_static_module \ #添加gzip压缩模块 --http-client-body-temp-path= /var/tmp/nginx/client/ \ #指定客户端请求时的主体临时目录 --http-proxy-temp-path= /var/tmp/nginx/proxy/ \ #指定做代理服务器时的临时目录 --http-fastcgi-temp-path= /var/tmp/nginx/fcgi/ \ #指定fcgi临时目录 --http-uwsgi-temp-path= /var/tmp/nginx/uwsgi \ #指定uwsgi临时目录(反向代理python开发的页面) --http-scgi-temp-path= /var/tmp/nginx/scgi \ #另一种反向代理用户请求的协议 --with-pcre #指定pcre # make && make install #安装 4、为nginx提供SysV风格的脚本 新建文件/etc/rc.d/init.d/nginx 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 #!/bin/sh # # nginx - this script starts and stops the nginx daemon # # chkconfig: - 85 15 # description: Nginx is an HTTP(S) server, HTTP(S) reverse \ # proxy and IMAP/POP3 proxy server # processname: nginx # config: /etc/nginx/nginx.conf # config: /etc/sysconfig/nginx # pidfile: /var/run/nginx.pid # Source function library. . /etc/rc .d /init .d /functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0 nginx= "/usr/local/nginx/sbin/nginx" prog=$( basename $nginx) NGINX_CONF_FILE= "/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile= /var/lock/subsys/nginx make_dirs() { # make required directories user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` options=`$nginx -V 2>&1 | grep 'configure arguments:' ` for opt in $options; do if [ ` echo $opt | grep '.*-temp-path' ` ]; then value=` echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done } start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $ "Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval - eq 0 ] && touch $lockfile return $retval } stop() { echo -n $ "Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval - eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $ "Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status > /dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $ "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac 5、为服务脚本赋予执行权限 1 # chmod +x /etc/rc.d/init.d/nginx 6、把nginx服务添加至服务管理器,并让其开机自动启动 1 2 # chkconfig --add nginx # chkconfig nginx on 7、启动服务并测试 1 2 3 # service nginx start [root@nmshuishui ~] # ss -antlp | grep nginx LISTEN 0 128 *:80 *:* users :(( "nginx" ,4724,6),( "nginx" ,4726,6)) 三、安装MariaDB(172.16.7.200) 1、二进制安装包 1 mariadb-10.0.10-linux-x86_64. tar .gz 2、安装步骤请参考我在LAMP博文中的链接 http://nmshuishui.blog.51cto.com/1850554/1381822 四、安装php服务器(172.16.7.100) 1、安装nginx服务器 同上第二步,安装完后测试一下 2、安装php服务器 (1)解决依赖关系 事先已安装开发包组"Desktop Platform Development" 1 yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt (2)编译安装php-5.4.4 安装完上面那几个还有报错,根据提示又安装了这几个 1 [root@shuishui php-5.4.4] # yum -y install libcurl-devel bzip2-devel libmcrypt-devel 接下来再次编译安装 1 [root@shuishui php-5.4.4] # ./configure --prefix=/usr/local/php --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-curl --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd (3)安装 1 [root@shuishui php-5.4.4] # make && make install (4)为php提供配置文件 1 [root@shuishui php-5.4.4] # cp php.ini-production /etc/php.ini (5)为php-fpm提供Sysv脚本,并将其添加到服务列表 1 2 3 4 [root@shuishui php-5.4.4] # cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm [root@shuishui php-5.4.4] # chmod +x /etc/rc.d/init.d/php-fpm [root@shuishui php-5.4.4] # chkconfig --add php-fpm [root@shuishui php-5.4.4] # chkconfig php-fpm on (6)为php-fpm提供配置文件 1 [root@shuishui php-5.4.4] # cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf (7)编辑php-fpm配置文件,配置fpm的相关选项,并启用pid 1 2 3 4 5 6 7 [root@shuishui ~] # vim /usr/local/php/etc/php-fpm.conf pm.max_children = 150 pm.start_servers = 8 pm.min_spare_servers = 5 pm.max_spare_servers = 10 pid = /usr/local/php/var/run/php-fpm .pid listen = 172.16.7.100:9000 (8)启动php-fpm并验证 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [root@shuishui ~] # service php-fpm start Starting php-fpm . done [root@shuishui ~] # ps -aux | grep php-fpm Warning: bad syntax, perhaps a bogus '-' ? See /usr/share/doc/procps-3 .2.8 /FAQ root 60344 2.0 0.4 99684 4880 ? Ss 01:28 0:00 php-fpm: master process ( /usr/local/php/etc/php-fpm .conf) nobody 60347 0.0 0.3 99684 3732 ? S 01:28 0:00 php-fpm: pool www nobody 60348 0.0 0.3 99684 3732 ? S 01:28 0:00 php-fpm: pool www nobody 60349 0.0 0.3 99684 3732 ? S 01:28 0:00 php-fpm: pool www nobody 60350 0.0 0.3 99684 3732 ? S 01:28 0:00 php-fpm: pool www nobody 60351 0.0 0.3 99684 3736 ? S 01:28 0:00 php-fpm: pool www nobody 60352 0.0 0.3 99684 3736 ? S 01:28 0:00 php-fpm: pool www nobody 60353 0.0 0.3 99684 3736 ? S 01:28 0:00 php-fpm: pool www nobody 60354 0.0 0.3 99684 3736 ? S 01:28 0:00 php-fpm: pool www root 60356 0.0 0.0 103244 856 pts /1 S+ 01:28 0:00 grep php-fpm 五、安装xcache,为php加速(172.16.7.100) 1、编译安装xcache 1 2 3 4 5 6 7 8 9 10 [root@shuishui ~] # tar xf xcache-3.0.1.tar.bz2 [root@shuishui ~] # cd xcache-3.0.1 [root@shuishui xcache-3.0.1] # /usr/local/php/bin/php php php-cgi php-config phpize [root@shuishui xcache-3.0.1] # /usr/local/php/bin/phpize Configuring for : PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 [root@shuishui xcache-3.0.1] # ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 结束后,会出现如下行 1 2 3 4 ---------------------------------------------------------------------- Build complete. Don 't forget to run ' make test '. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ 2、编辑php.ini,整合php和xcache (1)首先将xcache提供的样例配置导入php.ini 1 2 [root@shuishui xcache-3.0.1] # mkdir /etc/php.d [root@shuishui xcache-3.0.1] # cp xcache.ini /etc/php.d/ #xcache.ini文件在xcache的源码目录中 (2)接下来修改/etc/php.d/xcache.ini,找到extension开头的行,修改为如下行: 1 extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache .so 3、重启php-fpm 1 2 3 [root@shuishui xcache-3.0.1] # service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done 六、整合nginx和php5 1、编辑/etc/nginx/nginx.conf(172.16.7.10) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 worker_processes 2; #worker进程的个数 error_log /var/log/nginx/error .log notice; #错误日志路径及级别 events { worker_connections 1024; #每个worker能够并发响应的最大请求数 } http { include mime.types; #支持多媒体类型 default_type application /octet-stream ; sendfile on; #由内核直接转发 #keepalive_timeout 0; keepalive_timeout 5; #持久连接5s gzip on; #开启压缩功能 server { listen 80; server_name www.shuishui.com; add_header X-via $server_addr; #让客户端能够看到代理服务器的IP location / { root html; index index.php index.html index.htm; } location ~* \.(jpg|jpeg|png|gif|js|css)$ { #匹配以括号中结尾的格式 root html; #默认目录在/usr/local/nginx/html } location ~ \.php$ { root html; fastcgi_pass 172.16.7.100:9000; #代理到的服务器 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME scripts$fastcgi_script_name; include fastcgi_params; } } } 2、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:(172.16.7.10) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 fastcgi_param GATEWAY_INTERFACE CGI /1 .1; fastcgi_param SERVER_SOFTWARE nginx; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; 3、重新载入nginx 1 2 3 4 [root@nmshuishui html] # service nginx reload nginx: the configuration file /etc/nginx/nginx .conf syntax is ok nginx: configuration file /etc/nginx/nginx .conf test is successful Reloading nginx: [ OK ] 4、动、静分离测试 前提:因为没有DNS服务器,所以事先要把www.shuishui.com所对应的IP:172.16.7.10写入到hosts文件中 (1)动态测试:在php服务器上的网页目录中创建index.php(172.16.7.100) 1 2 3 4 5 6 7 [root@shuishui html] # pwd /usr/local/nginx/html [root@shuishui html] # vim index.php <h1>Welcome to php server(172.16.7.100)< /h1 > <?php phpinfo(); ?> 在windows主机上访问www.shuishui.com (2)静态测试:在前端nginx服务器(172.16.7.10)的网页目录中放入1.png图片 1 2 3 4 [root@nmshuishui html] # pwd /usr/local/nginx/html [root@nmshuishui html] # ls 1.png 50x.html index.html index.html1 index.php 再到windows上去测试一下 由上面的动态、静态测试结果可看出,根据请求的资源类型的不同,即可实现动、静分离。因此,也知道了,网页目录需要准备两份,前端nginx服务器和后端的php服务器各需一份 七、安装Memcache服务器(172.16.7.201) 1、memcached简介 Memcached是一款开源、高性能、分布式内存对象缓存系统,可应用各种需要缓存的场景,其主要目的是通过降低对Database的访问来加速web应用程序。它是一个基于内存的“键值对”存储,用于存储数据库调用、API调用或页面引用结果的直接数据,如字符串、对象等。 Memcached是一款开发工具,它既不是一个代码加速器,也不是数据库中间件。其设计哲学思想主要反映在如下方面: (1)简单key/value存储:服务器不关心数据本身的意义及结构,只要是可序列化数据即可。存储项由“键、过期时间、可选的标志及数据”四个部分组成; (2)功能的实现一半依赖于客户端,一半基于服务器端:客户负责发送存储项至服务器端、从服务端获取数据以及无法连接至服务器时采用相应的动作;服务端负责接收、存储数据,并负责数据项的超时过期; (3)各服务器间彼此无视:不在服务器间进行数据同步; (4)O(1)的执行效率 (5)清理超期数据:默认情况下,Memcached是一个LRU缓存,同时,它按事先预订的时长清理超期数据;但事实上,memcached不会删除任何已缓存数据,只是在其过期之后不再为客户所见;而且,memcached也不会真正按期限清理缓存,而仅是当get命令到达时检查其时长; 2、安装memcached服务器(172.16.7.201) 也可以使用yum方式安装,这里使用编译安装 (1)安装libevent memcached依赖于libevent API,因此要事先安装 1 2 # yum groupinstall "Development Tools" "Server Platform Deveopment" -y #yum install -y libevent-devel (2)安装配置memcached 1 2 3 4 # tar xf memcached-1.4.15.tar.gz # cd memcached-1.4.15 # ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent # make && make install (3)为memcached提供sysv脚本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 #!/bin/bash # # Init file for memcached # # chkconfig: - 86 14 # description: Distributed memory caching daemon # # processname: memcached # config: /etc/sysconfig/memcached . /etc/rc .d /init .d /functions ## Default variables PORT= "11211" USER= "nobody" MAXCONN= "1024" CACHESIZE= "64" OPTIONS= "" RETVAL=0 prog= "/usr/local/memcached/bin/memcached" desc= "Distributed memory caching" lockfile= "/var/lock/subsys/memcached" start() { echo -n $ "Starting $desc (memcached): " daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE -o "$OPTIONS" RETVAL=$? [ $RETVAL - eq 0 ] && success && touch $lockfile || failure echo return $RETVAL } stop() { echo -n $ "Shutting down $desc (memcached): " killproc $prog RETVAL=$? [ $RETVAL - eq 0 ] && success && rm -f $lockfile || failure echo return $RETVAL } restart() { stop start } reload() { echo -n $ "Reloading $desc ($prog): " killproc $prog -HUP RETVAL=$? [ $RETVAL - eq 0 ] && success || failure echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e $lockfile ] && restart RETVAL=$? ;; reload) reload ;; status) status $prog RETVAL=$? ;; *) echo $ "Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1 esac exit $RETVAL (4)配置memcached成为系统服务 1 2 3 # chmod +x /etc/init.d/memcached # chkconfig --add memcached # service memcached start (5)查看memcached监听端口是否成功 1 2 3 [root@shuishui ~] # ss -tnlp | grep 11211 LISTEN 0 128 :::11211 :::* users :(( "memcached" ,3120,27)) LISTEN 0 128 *:11211 *:* users :(( "memcached" ,3120,26)) 八、安装php的memcache扩展(172.16.7.100) 1、安装php的memcache扩展 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 [root@shuishui ~] # tar xf memcache-2.2.7.tgz [root@shuishui ~] # cd memcache-2.2.7 [root@shuishui memcache-2.2.7] # /usr/local/php/bin/phpize Configuring for : PHP Api Version: 20100412 Zend Module Api No: 20100525 Zend Extension Api No: 220100525 [root@shuishui memcache-2.2.7] # ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcache …… …… [root@shuishui memcache-2.2.7] # make && make install …… …… Build complete. Don 't forget to run ' make test '. Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/ 2、编辑/etc/php.ini,在“动态模块”相关的位置添加如下一行来载入memcache扩展: 1 extension= /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache .so 3、重启php-fpm 1 2 3 [root@shuishui ~] # service php-fpm restart Gracefully shutting down php-fpm . done Starting php-fpm done 4、在windows客户端验证memcached是否安装成功 刚才的x-cache也安装成功了 5、对memcached功能进行测试,在网站目录中建立测试页面test.php,添加如下内容 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [root@shuishui html] # pwd #php服务器(172.16.7.100) /usr/local/nginx/html [root@shuishui html] # vim test.php <?php $mem = new Memcache; $mem->connect( "172.16.7.201" , 11211) or die( "Could not connect" ); $version = $mem->getVersion(); echo "Server's version: " .$version. "<br/>\n" ; $mem-> set ( 'hellokey' , 'Hello World' , 0, 600) or die( "Failed to save data at the memcached server" ); echo "Store data in the cache (data will expire in 600 seconds)<br/>\n" ; $get_result = $mem->get( 'hellokey' ); echo "$get_result is from memcached server." ; ?> ~ 在windows服务器上测试,表明memcache已经能够正常工作 由上图可以看出,memcached(172.16.7.201)已经可以正常工作了,到这里,基于动、静分离的LNMMP就已经实现了;下一步就是安装一个博客系统并监控其性能 九、安装wordpress和数据库授权(前端nginx和后端的php都需要安装wordpress) 1、在mysql数据库(172.16.7.200)中授权访问网段 1 2 3 4 5 MariaDB [(none)]> grant all on *.* to 'wordpress' @ '172.16.%.%' identified by 'wordpress' ; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) 2、创建wordpress数据库,否则不让安装 1 MariaDB [(none)]> create database wordpress; 3、wordpress安装准备 1 2 3 4 5 6 7 [root@nmshuishui ~] # cd /usr/local/nginx/html/ [root@nmshuishui html] # unzip wordpress-3.2.1-zh_CN.zip [root@nmshuishui html] # cd wordpress [root@nmshuishui wordpress] # cp wp-config-sample.php wp-config.php [root@nmshuishui wordpress] # vim wp-config.php #需要在这里填入所需的数据库信息,这个还和Discuz不一样 [root@nmshuishui wordpress] # scp wp-config.php root@172.16.7.100:/usr/local/nginx/html/wordpress #前端nginx和后端的php都需要安装wordpress,所以配置文件一保持一致 修改如下几项即可 4、博客系统安装成功 十、安装memadmin-master查看memcached的状态信息 1、解压(前端nginx和后端的php都需要解压安装memadmin-master) 1 [root@shuishui html] # unzip memadmin-master.zip 2、连接memadmin-master 3、查看memcached状态信息 本文转自 nmshuishui 51CTO博客,原文链接:http://blog.51cto.com/nmshuishui/1403720,如需转载请自行联系原作者

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

rabbitmq的整体架构一览

AMQ结构图,工作原理图 重要术语 Server(broker):接收客户端连接,实现AMQP消息队列的路由功能的进程.简单来说就是消息队列服务器实体。 Vhost:虚拟主机,一个broker里可以开设多个vhost,用作不同用户的权限分离。权限控制组,用户只能关联到一个vhost上,一个vhost中可以有若干个Exchange和Queue,默认的vhost是"/" Exchange:接收生产者发送的消息,并根据Binding规则将消息路由给服务器中的队列 Exchange Type决定了Exchange路由消息额行为,例如,在RabbitMQ中,ExchangeType有Direct、Fanout和Topic三种,不同类型的Exchange路由得到行为是不一样的 queue:用于存储还未消费的消息。消息队列载体,每个消息都会被投入到一个或多个队列。 Message:由Header和Body组成,Header是由生产者添加到各种属性的集合,包括Message是否被持久化,是由哪个Message Queue接收优先级是多少等,而Body是真正需要传输的APP数据 Binding:绑定,它的作用就是把exchange和queue按照路由规则绑定起来。: BindingKey:在mq中设置的绑定key Routing Key:路由关键字,exchange根据这个关键字进行消息投递。producer:消息生产者,就是投递消息的程序。 consumer:消息消费者,就是接受消息的程序。channel:消息通道,在客户端的每个连接里,可建立多个channel,每个channel代表一个会话任务 消息队列的使用过程大概如下: (1)客户端(生产者)连接到消息队列服务器,打开一个channel。 (2)客户端声明一个exchange,并设置相关属性。 (3)客户端声明一个queue,并设置相关属性。 (4)客户端使用routing key,在exchange和queue之间建立好绑定关系。 (5)客户端投递消息到exchange。 exchange接收到消息后,就根据消息的key和已经设置的binding,进行消息路由,将消息投递到一个或多个队列里。 exchange也有几个类型,完全根据key进行投递的叫做Direct交换机,例如,绑定时设置了routing key为”abc”,那么客户端提交的消息,只有设置了key为”abc”的才会投递到队列。对key进行模式匹配后进行投递的叫做Topic交换机,符号”#”匹配一个或多个词,符号”*”匹配正好一个词。例如”abc.#”匹配”abc.def.ghi”,”abc.*”只匹配”abc.def”。还有一种不需要key的,叫做Fanout交换机,它采取广播模式,一个消息进来时,投递到与该交换机绑定的所有队列。 Direct: 任何发送到Direct Exchange的消息都会被转发到routing_key中指定的Queue 1.一般情况可以使用rabbitMQ自带的Exchange:””(该Exchange的名字为空字符串); 2.这种模式下不需要将Exchange进行任何绑定(bind)操作; 3.消息传递时需要一个“routing_key”,可以简单的理解为要发送到的队列名字; 4.如果vhost中不存在routing_key中指定的队列名,则该消息会被抛弃。 如代码发送 1 2 3 4 5 6 7 8 9 10 import pika connection=pika.BlockingConnection(pika.ConnectionParameters( host= 'localhost' )) channel=connection.channel() channel.queue_declare(queue= 'hello' ) channel.basic_publish(exchange= '' , routing_key= 'hello' , body= 'HelloWorld!' ) print( "[x]Sent'HelloWorld!'" ) connection.close() Topic: 任何发送到Topic Exchange的消息都会被转发到所有关心routing_key中指定话题的Queue上 1.这种模式较为复杂,简单来说,就是每个队列都有其关心的主题,所有的消息都带有一个“标题”(routing_key),Exchange会将消息转发到所有关注主题能与routing_key模糊匹配的队列。 2.这种模式需要routing_key,也许要提前绑定Exchange与Queue。 3.在进行绑定时,要提供一个该队列关心的主题,如“#.log.#”表示该队列关心所有涉及log的消息(一个routing_key为”MQ.log.error”的消息会被转发到该队列)。 4.“#”表示0个或若干个关键字,“*”表示一个关键字。如“log.*”能与“log.warn”匹配,无法与“log.warn.timeout”匹配;但是“log.#”能与上述两者匹配。 5.同样,如果Exchange没有发现能够与routing_key匹配的Queue,则会抛弃此消息。 Fanout: 任何发送到Fanout Exchange的消息都会被转发到与该Exchange绑定(Binding)的所有Queue上 1.可以理解为路由表的模式 2.这种模式不需要routing_key 3.这种模式需要提前将Exchange与Queue进行绑定,一个Exchange可以绑定多个Queue,一个Queue可以同多个Exchange进行绑定。 4.如果接受到消息的Exchange没有与任何Queue绑定,则消息会被抛弃。 Demo中创建了一个将一个exchange和一个queue进行fanout类型的bind.但是发送信息时没有用到它,如果要用到它,只要在发送消息时指定该exchange的名称即可,该exchange就会将消息发送到所有和它bind的队列中。在fanout模式下,指定的routing_key是无效的 。 rabbitMQ的两个核心组件是exchange和queue 运行原理如下图: 本文转自残剑博客51CTO博客,原文链接http://blog.51cto.com/cuidehua/1769486如需转载请自行联系原作者 cuizhiliang

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

Android架构图以及主要类

主要的类: android.app :提供高层的程序模型、提供基本的运行环境 android.content 包含各种的对设备上的数据进行访问和发布的类 android.database :通过内容提供者浏览和操作数据库 android.graphics :底层的图形库,包含画布,颜色过滤,点,矩形,可以将他们直接绘制到屏幕上. android.location :定位和相关服务的类 android.media :提供一些类管理多种音频、视频的媒体接口 android.net :提供帮助网络访问的类,超过通常的java.net.* 接口 android.os :提供了系统服务、消息传输、IPC机制 android.opengl :提供OpenGL的工具,3D加速 android.provider :提供类访问Android的内容提供者 android.telephony :提供与拨打电话相关的API交互 android.view :提供基础的用户界面接口框架 android.util :涉及工具性的方法,例如时间日期的操作 android.webkit:默认浏览器操作接口 android.widget:包含各种UI元素(大部分是可见的)在应用程序的屏幕中使用 本文转自java豆子博客园博客,原文链接:http://www.cnblogs.com/error404/archive/2011/08/16/2140190.html,如需转载请自行联系原作者

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

Mocha BSM基础架构管理——IT资产管理

业务需求与挑战 一般企业领导在做出购买设备的决策的时候总是很头痛,心里总是有这些问题: • 到底现在库存里有多少设备? • 有多少设备在维修? • 有没有设备借给别的部门? • 有多少设备已经报废了? • 企业装了哪些软件? • 有多少设备超过了折旧年限? • 某一个厂家的设备好不好用,返修率高吗? • 这些年来的IT资产投入有多大? 企业永远在面临着——追踪一个动态的IT资产,IT资产天天都在变,如果用手工统计是跟不上的。设备的管理不规范,到底谁领用了设备,设备在哪里成为一个企业的一大困惑。这些难题让企业的IT领导工作难上加难。 关键功能与亮点 以Portal为中心的灵活展现 轻易地通过浏览器访问,不用在终端装任何的客户端软件。Portal也能界面整合任何第三方IT资产相关的系统。 设备与软件管理 自动发现IT资产,追踪永远动态的企业IT资产。发现的设备包括: • 通过Agentless方式,发现Unix或者Linux服务器 • 通过SNMP方式,发现网络设备 • 通过WMi方式,发现Windows设备 IT资产生命周期管理 包括库存、领用、维修、借调、折旧、报废在内的全生命周期管理 支持非标准的IT资产 用户可以自定义不同的IT资产类别,所以系统可以支持不同种类的IT资产,甚至非IT资产。 IT资产变更管理 IT资产都有很多的配件,包括CPU,内存。这些配件都很容易丢失,Mocha ITAM追踪这些配件的变更,一旦发生变更,就可以发短信给相关的负责人。 软件管理 追踪企业安装的不同软件,可以设定不同的软件分类。 支持流程化管理 所有相关IT资产的领用,维修等都能通过流程来支持。 其他关键功能 • 供应商、厂家管理; •追踪对供应商和厂家的满意度; • 服务合同管理; • 追踪不同服务合同与设备的关联关系,以及服务合同的服务期限,在合同到期之前提醒相关的负责人; • 提供了丰富的报表功能以及补丁管理。 我们给客户带来什么 摩卡IT资产管理除了解决企业客户所面临的困惑,并且带来以下价值: • 让企业客户知道他们拥有什么IT资产; • 让企业客户知道IT资产在哪里; • 让企业客户知道IT资产是怎么被用。 在整个过程中,Mocha ITAM帮企业到了以下: • 提高整个IT资产投资回报率。IT资产得到很好的跟踪,不会再被闲置,用起来的整体效率提高了; • IT部门领导在做IT资产方面的决策就更容易了,更加科学,都是以具体数字为依据; • 通过IT资产管理的规范化和流程化管理,降低了IT资产的成本; • 提高IT部门对IT资产方面服务的响应,IT资产现在很容易就能追踪得到; • 降低不必要的成本以及风险。 更多相关信息,请点击 [url]http://www.mochabsm.com[/url] 本文转自赖永锋51CTO博客,原文链接:http://blog.51cto.com/mochasoft/86446 ,如需转载请自行联系原作者

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

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

用户登录
用户注册
修改密码
忘记密码