`
liujiekasini0312
  • 浏览: 147137 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡

 
阅读更多
两台web实现负载均衡,通过NFS把网页文件共享出来,把mysql独立出来
实验环境准备:三台服务器
server1:172.16.0.22(Web+PHP+DNS)---->/www
server2:172.16.0.23(Mysql)--->/data
server3:172.16.0.24(Web+PHP+NFS)--->/www/users/test.com
<wbr></wbr>
实验拓扑图如下:
<wbr></wbr>

两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡

<wbr></wbr>

最终实现的效果:
1、当用户访问Web服务器的时候,可以通过DNS轮询功能,将请求分别转到两台Web服务器,从而降低负载
2、如果其中一台Web服务器损坏,另一台Web可以继续工作
3、所有的客户端提交动态的数据,都会被写入到独立的数据库中,从而也降低了负载
<wbr></wbr>
<wbr></wbr>
一、server1:172.16.0.22(Web+PHP+DNS)
<wbr></wbr>

  1. 一、安装DNS<wbr></wbr>
  2. yum<wbr>-y<wbr>install<wbr>bind97<wbr>bin97-libs<wbr>bind97-utils<wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  3. 编辑/etc/named.conf主配置文件<wbr></wbr>
  4. options<wbr>{<wbr></wbr></wbr>
  5. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>directory<wbr><wbr>"/var/named";<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  6. <wbr></wbr>
  7. };<wbr></wbr>
  8. zone<wbr>"."<wbr>IN<wbr>{<wbr></wbr></wbr></wbr></wbr>
  9. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>type<wbr>hint;<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  10. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>file<wbr>"named.ca";<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  11. };<wbr></wbr>
  12. <wbr></wbr>
  13. zone<wbr>"test.com"<wbr>IN<wbr>{<wbr></wbr></wbr></wbr></wbr>
  14. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>type<wbr>master;<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  15. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>file<wbr>"test.com.zone";<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  16. };<wbr></wbr>
  17. <wbr></wbr>
  18. 新建区域文件<wbr></wbr>
  19. mkdir<wbr>-p<wbr>/var/named/test.com.zone<wbr></wbr></wbr></wbr>
  20. <wbr></wbr>
  21. 编辑区域文件,添加以下内容:<wbr></wbr>
  22. vim<wbr>/var/named/test.com.zone<wbr></wbr></wbr>
  23. $TTL<wbr>600<wbr></wbr></wbr>
  24. @<wbr><wbr><wbr><wbr><wbr><wbr><wbr>IN<wbr>SOA<wbr><wbr>ns.test.com.<wbr>root.test.com.<wbr><wbr>(<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  25. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>2012071301<wbr><wbr><wbr><wbr><wbr><wbr>;<wbr>serial<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  26. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>1D<wbr><wbr><wbr><wbr><wbr><wbr>;<wbr>refresh<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  27. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>1H<wbr><wbr><wbr><wbr><wbr><wbr>;<wbr>retry<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  28. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>1W<wbr><wbr><wbr><wbr><wbr><wbr>;<wbr>expire<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  29. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>3H<wbr>)<wbr><wbr><wbr><wbr>;<wbr>minimum<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  30. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>IN<wbr><wbr><wbr><wbr><wbr>NS<wbr><wbr><wbr><wbr><wbr><wbr>ns.test.com.<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  31. ns<wbr><wbr><wbr><wbr><wbr><wbr><wbr>IN<wbr><wbr><wbr><wbr><wbr>A<wbr><wbr><wbr><wbr><wbr><wbr><wbr>172.16.0.22<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  32. www<wbr><wbr><wbr><wbr><wbr><wbr>IN<wbr><wbr><wbr><wbr><wbr>A<wbr><wbr><wbr><wbr><wbr><wbr><wbr>172.16.0.22<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  33. www<wbr><wbr><wbr><wbr><wbr><wbr>IN<wbr><wbr><wbr><wbr><wbr>A<wbr><wbr><wbr><wbr><wbr><wbr><wbr>172.16.0.24<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  34. <wbr></wbr>
  35. 修改属组:chown<wbr>root.named<wbr>test.com.zone<wbr></wbr></wbr></wbr>
  36. <wbr></wbr>
  37. 重启DNS<wbr></wbr>
  38. service<wbr>named<wbr>restart<wbr></wbr></wbr></wbr>
  39. <wbr></wbr>
  40. 验证DNS<wbr></wbr>
  41. 两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡

    <wbr></wbr>
    
    
    1. 二、安装Web(这里采用编译安装)<wbr></wbr>
    2. 1、httpd-2.4.2需要较新版本的apr和apr-util,因此需要事先对其进行升级。升级方式有两种,一种是通过源码编译安装,一种是直接升级rpm包,下载好安装包以后使用“rpm<wbr>-Uvh”进行升级即可。这里选择使源码编译安装。<wbr><wbr></wbr></wbr></wbr>
    3. 注意:安装这些软件包之前不要忘记安装开发环境了<wbr></wbr>
    4. yum<wbr>-y<wbr>groupinstall<wbr>"Development<wbr>Tools"<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    5. yum<wbr>-y<wbr>groupinstall<wbr>"Development<wbr>Libraries"<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    6. <wbr><wbr></wbr></wbr>
    7. 编译安装apr和apr-util<wbr><wbr></wbr></wbr>
    8. tar<wbr>xf<wbr>apr-1.4.6.tar.bz2<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    9. ./configure<wbr>--prefix=/usr/local/apr<wbr><wbr></wbr></wbr></wbr>
    10. make<wbr>&amp;&amp;<wbr>make<wbr>install<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    11. <wbr><wbr></wbr></wbr>
    12. tar<wbr>xf<wbr>apr-util-1.4.1.tar.bz2<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    13. ./configure<wbr>--prefix=/usr/local/apr-util<wbr>--with-apr=/usr/local/apr<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    14. make<wbr>&amp;&amp;<wbr>make<wbr>install<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    15. <wbr><wbr></wbr></wbr>
    16. 注意:httpd-2.4.2编译过程也要依赖于pcre-devel<wbr>和openssl-devel软件包,我们yum安装一下<wbr><wbr></wbr></wbr></wbr>
    17. yum<wbr>install<wbr>pcre-devel<wbr>openssl-devel<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    18. <wbr><wbr></wbr></wbr>
    19. <wbr><wbr></wbr></wbr>
    20. 2、编译安装httpd-2.4.2.tar.bz2<wbr><wbr></wbr></wbr>
    21. tar<wbr>xf<wbr>httpd-2.4.2.tar.bz2<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    22. cd<wbr>httpd-2.4.2<wbr><wbr><wbr></wbr></wbr></wbr></wbr>
    23. ./configure<wbr>--prefix=/usr/local/apache<wbr><wbr>--enable-so<wbr><wbr>--with-apr=/usr/local/apr<wbr>--with-apr-util=/usr/local/apr-util<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    24. make<wbr>&amp;&amp;<wbr>make<wbr>install<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    25. <wbr><wbr></wbr></wbr>
    26. 为了节省时间,就没有加那么多的参数了<wbr></wbr>
    27. 了解更多的编译参数请./configure<wbr>--help进行查看<wbr></wbr></wbr>

    <wbr></wbr>

    1. 三、编译安装php<wbr></wbr>
    2. tar<wbr>xf<wbr>php-5.4.4.tar.bz2<wbr><wbr></wbr></wbr></wbr></wbr>
    3. cd<wbr>php-5.4.4<wbr><wbr></wbr></wbr></wbr>
    4. ./configure<wbr>--prefix=/usr/local/php<wbr>--with-mysql=/usr<wbr>--enable-mbstring<wbr>--with-freetype-dir<wbr>--with-jpeg-dir<wbr>--with-png-dir<wbr>--with-zlib<wbr>--with-libxml-dir=/usr<wbr>--enable-xml<wbr><wbr>--with-apxs2=/usr/local/apache/bin/apxs<wbr>--with-config-file-path=/etc<wbr>--with-config-file-scan-dir=/etc/php.d<wbr>--with-bz2<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    5. make<wbr>&amp;&amp;<wbr>make<wbr>install<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    6. <wbr><wbr></wbr></wbr>
    7. 为php提供配置文件<wbr><wbr></wbr></wbr>
    8. cp<wbr>php.ini-production<wbr>/etc/php.ini<wbr><wbr></wbr></wbr></wbr></wbr>
    9. <wbr><wbr></wbr></wbr>
    10. 编辑apache配置文件,让apache支持php<wbr><wbr></wbr></wbr>
    11. vim<wbr>/etc/httpd/httpd.conf<wbr><wbr></wbr></wbr></wbr>
    12. 检查libphp5.so模块是否添加,并且开启<wbr><wbr></wbr></wbr>
    13. <wbr><wbr></wbr></wbr>
    14. 找到<IfModule<wbr>mime_module&gt;模块,在里面添加<wbr><wbr></wbr></wbr></wbr>
    15. AddType<wbr>application/x-httpd-php<wbr><wbr>.php<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    16. <wbr><wbr></wbr></wbr>
    17. 定位至:DirectoryIndex<wbr>index.html<wbr><wbr><wbr></wbr></wbr></wbr></wbr>
    18. 修改为:DirectoryIndex<wbr><wbr>index.php<wbr><wbr>index.html<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    19. <wbr></wbr>
    20. 添加一个虚拟主机编辑httpd.conf配置文件需要修改以下内容<wbr><wbr></wbr></wbr>
    21. vim<wbr>/usr/local/apache/conf/httpd.conf<wbr></wbr></wbr>
    22. LoadModule<wbr>log_config_module<wbr>modules/mod_log_config.so<wbr><wbr></wbr></wbr></wbr></wbr>
    23. Include<wbr>/etc/httpd/extra/httpd-vhosts.conf<wbr><wbr></wbr></wbr></wbr>
    24. 把前面的#号去掉<wbr><wbr></wbr></wbr>
    25. #DocumentRoot<wbr>"/usr/local/apache/htdocs"<wbr>/在前面加个#号,注释掉/<wbr><wbr></wbr></wbr></wbr></wbr>
    26. 保存退出<wbr></wbr>
    27. vim<wbr>/usr/local/apache/conf/extra/httpd-vhosts.conf<wbr></wbr></wbr>
    28. <VirtualHost<wbr>*:80&gt;<wbr></wbr></wbr>
    29. ServerName<wbr>www.test.com<wbr></wbr></wbr>
    30. DocumentRoot<wbr>/www<wbr></wbr></wbr>
    31. <Directory<wbr>"/www"&gt;<wbr></wbr></wbr>
    32. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Options<wbr>indexes<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    33. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>AllowOverride<wbr>none<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    34. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>Require<wbr>all<wbr>granted<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    35. <wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>&lt;/Directory&gt;<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    36. </VirtualHost><wbr></wbr>
    37. <wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
    38. 重启httpd命令:/usr/local/apache/bin/apachectl<wbr>restart<wbr><wbr></wbr></wbr></wbr>
    39. 写一个php测试脚本:echo<wbr>"&lt;?php<wbr>phpinfo();<wbr>?&gt;"<wbr>&gt;/www/index.php<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
    40. 测试结果http://172.16.0.22/index.php<wbr></wbr>
    41. <wbr></wbr>
    42. 下面的NFS配置好以后用以下命令进行挂载:
    43. mount -t nfs 172.16.0.24:/www/users/test.com /www
    两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡
    
  42. 二、server2:172.16.0.23(Mysql)<wbr></wbr>
  43. 安装mysql<wbr></wbr>
  44. 安装mysql-5.5.24(这里是绿色版直接解压使用)<wbr></wbr>
  45. 新建用户以安全方式运行进程:<wbr><wbr></wbr></wbr>
  46. groupadd<wbr>-r<wbr>mysql<wbr><wbr></wbr></wbr></wbr></wbr>
  47. useradd<wbr><wbr>-g<wbr>mysql<wbr>-r<wbr>-s<wbr>/sbin/nologin<wbr>mysql<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  48. chown<wbr>mysql:mysql<wbr>/data<wbr><wbr></wbr></wbr></wbr></wbr>
  49. <wbr><wbr></wbr></wbr>
  50. 解压mysql并创建软链接<wbr><wbr></wbr></wbr>
  51. tar<wbr>xf<wbr>mysql-5.5.24-linux2.6-i686.tar.gz<wbr>-C<wbr>/usr/local<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  52. cd<wbr>/usr/local<wbr><wbr></wbr></wbr></wbr>
  53. ln<wbr>-sv<wbr>mysql-5.5.24-linux2.6-i686<wbr><wbr>mysql<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  54. <wbr><wbr></wbr></wbr>
  55. 修改属主和组并初始化mysql-5.5.24<wbr><wbr></wbr></wbr>
  56. chown<wbr>-R<wbr>mysql:mysql<wbr><wbr>.<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  57. /usr/local/mysql/scripts/mysql_install_db<wbr>--user=mysql<wbr>--datadir=/data<wbr></wbr></wbr></wbr>
  58. chown<wbr>-R<wbr>root<wbr>.<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  59. <wbr><wbr></wbr></wbr>
  60. 为mysql提供主配置文件:<wbr><wbr></wbr></wbr>
  61. cd<wbr>/usr/local/mysql<wbr><wbr></wbr></wbr></wbr>
  62. cp<wbr>support-files/my-large.cnf<wbr><wbr>/etc/my.cnf<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  63. <wbr><wbr></wbr></wbr>
  64. 编辑my.cnf文件<wbr></wbr>
  65. vim<wbr>/etc/my.cnf<wbr></wbr></wbr>
  66. 并修改此文件中thread_concurrency的值为你的CPU个数乘以2,比如这里使用如下行:<wbr><wbr></wbr></wbr>
  67. thread_concurrency<wbr>=<wbr>2<wbr><wbr></wbr></wbr></wbr></wbr>
  68. datadir<wbr>=<wbr>/data<wbr></wbr></wbr></wbr>
  69. <wbr><wbr></wbr></wbr>
  70. 为mysql提供sysv服务脚本:<wbr><wbr></wbr></wbr>
  71. cd<wbr>/usr/local/mysql<wbr><wbr></wbr></wbr></wbr>
  72. cp<wbr>support-files/mysql.server<wbr><wbr>/etc/rc.d/init.d/mysqld<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  73. <wbr><wbr></wbr></wbr>
  74. 添加至服务列表:<wbr><wbr></wbr></wbr>
  75. chkconfig<wbr>--add<wbr>mysqld<wbr><wbr></wbr></wbr></wbr></wbr>
  76. chkconfig<wbr>mysqld<wbr>on<wbr><wbr></wbr></wbr></wbr></wbr>
  77. 最后就可以启动服务测试使用了。<wbr></wbr>
  78. <wbr><wbr></wbr></wbr>
  79. 使用mysql的安装符合系统使用规范,并将其开发组件导出给系统使用<wbr><wbr></wbr></wbr>
  80. vim<wbr>/etc/profile<wbr><wbr><wbr><wbr><wbr><wbr>/添加PATH搜索路径/<wbr><wbr>PATH=$PATH:/usr/local/mysql/bin<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  81. vim<wbr>/etc/man.config<wbr><wbr><wbr><wbr><wbr><wbr><wbr>/添加man路径/<wbr>MANPATH<wbr><wbr><wbr><wbr>/usr/local/mysql/man<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  82. <wbr><wbr></wbr></wbr>
  83. 使用mysql命令生效<wbr></wbr>
  84. export<wbr>PATH=$PATH:/usr/local/mysql/bin/<wbr></wbr></wbr>
  85. <wbr></wbr>
  86. 输出mysql的头文件至系统头文件路径/usr/include:<wbr><wbr></wbr></wbr>
  87. 这可以通过简单的创建链接实现:<wbr><wbr></wbr></wbr>
  88. ln<wbr>-sv<wbr>/usr/local/mysql/include<wbr><wbr>/usr/include/mysql<wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  89. 输出mysql的库文件给系统库查找路径:<wbr><wbr></wbr></wbr>
  90. echo<wbr>'/usr/local/mysql/lib'<wbr>&gt;<wbr>/etc/ld.so.conf.d/mysql.conf<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  91. <wbr><wbr></wbr></wbr>
  92. 最后让系统重新载入系统库:<wbr><wbr></wbr></wbr>
  93. ldconfig<wbr><wbr></wbr></wbr>
  94. <wbr></wbr>
  95. service<wbr>mysqld<wbr>start<wbr><wbr></wbr></wbr></wbr></wbr>
  96. mysqladmin<wbr>-uroot<wbr>password<wbr>'redhat'<wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  97. mysql<wbr>-uroot<wbr>-p<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  98. mysql><wbr>GRANT<wbr>ALL<wbr>ON<wbr>discuz.*<wbr>TO<wbr>root@'%.%.%.%'<wbr>IDENTIFIED<wbr>BY<wbr>'redhat';<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  99. mysql><wbr>FLUSH<wbr>PRIVILEGES<br><pre style="white-space:normal">三、server3:172.16.0.24(Web+PHP+NFS)</pre> <ol style="margin:0px; padding:0px; border:0px; list-style:none"> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> Web和PHP安装同上<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 安装NFS<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> redhat5.8默认已经安装好NFS,如果你的没有安装,使用这条命令即可:<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> yum<wbr>install<wbr>nfs-utils<wbr>nfs4-acl-tools<wbr>portmap<wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 配置NFS服务端<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> nfs的主配置文件是/etc/exports,这里是配置NFS服务器开放的目录以及客户端访问的权限等。<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> vi<wbr>/etc/exports<wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> /www/users/test.com<wbr><wbr>172.16.0.0/16(rw,no_root_squash)<wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 保存退出<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> exportfs<wbr>-arv<wbr>使其NFS配置生效,不要重新启动NFS服务<wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 在NFS中解压Discuz程序<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> unzip<wbr>Discuz_7.2_FULL_SC_GBK.zip<wbr>-d<wbr>/www/users/test.com<wbr><wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> cd<wbr>/www/users/test.com<wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> cd<wbr>upload<wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> mv<wbr>*<wbr>../<wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 开始安装Discuz论坛<wbr></wbr> </li> </ol> <pre style="white-space:normal">提示:此时你可以用一台同一网段windows主机查看一下dns是否有轮询功能,ping完以后清空dns缓存,再次ping一下就看到效果了 <wbr><a target="_blank" href="http://photo.blog.sina.com.cn/showpic.html#blogid=54cae6d70101cr0j&amp;url=http://s2.sinaimg.cn/orignal/54cae6d7xd0319dfccff1" style="text-decoration:none; color:rgb(7,67,135)"><img src="http://s2.sinaimg.cn/mw690/54cae6d7xd0319dfccff1&amp;690" name="image_operate_53801354811441234" alt="两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡" title="两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡" style="margin:0px; padding:0px; border:0px; list-style:none"></a> <wbr><a target="_blank" href="http://photo.blog.sina.com.cn/showpic.html#blogid=54cae6d70101cr0j&amp;url=http://s7.sinaimg.cn/orignal/54cae6d7xd0319f001c16" style="text-decoration:none; color:rgb(7,67,135)"><img src="http://s7.sinaimg.cn/mw690/54cae6d7xd0319f001c16&amp;690" name="image_operate_281354811699546" alt="两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡" title="两台WEB服务器(LAMP)通过DNS轮询功能实现负载均衡" style="margin:0px; padding:0px; border:0px; list-style:none"></a> </wbr></wbr></pre> <pre style="white-space:normal"><wbr><wbr></wbr></wbr></pre> <hr> <ol style="margin:0px; padding:0px; border:0px; list-style:none"> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 测试:1、你可以通过浏览器输入IP或者是域名都可以正常访问Discuz论坛<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr><wbr><wbr><wbr><wbr><wbr>2、你可以试着发贴看看数据是否写到数据库中,然后通过浏览器输入IP或者是域名,查看是否有新的内容<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr><wbr><wbr><wbr><wbr><wbr>3、你可以把两个Web停止一台测试,然后通过浏览器输入IP或者是域名测试论坛是否可以正常访问<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 总结:<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 一、安装Discuz的时候提示目录和文件权限不可写<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 原因:权限问题<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 解决方法:编辑httpd.conf把里面的User和Group暂时改成nobody,然后把Discuz的网页文件的属主和属组改成nobody<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 二、1、安装Discuz的时候出现mysql_connect()<wbr><wbr><wbr><wbr>不支持的错误<wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> <wbr><wbr><wbr><wbr>2、编译php的时候报以下错误:configure:<wbr>error:<wbr>Cannot<wbr>find<wbr>MySQL<wbr>header<wbr>files<wbr>under<wbr>/usr/local/mysql.Note<wbr>that<wbr>the<wbr>MySQL<wbr>client<wbr>library<wbr>is<wbr>not<wbr>bundled<wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> anymore!<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 原因:两个问题是因为找不到mysql的头文件<wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 解决方法:yum<wbr>-y<wbr>install<wbr>php-mysql<wbr></wbr></wbr></wbr></wbr> </li> <li style="margin:0px 0px 0px 20px; padding:0px; border:0px; list-style:decimal"> 在编译php的时候加上--with-mysql=/usr即可</li> </ol></wbr></wbr>
分享到:
评论

相关推荐

    DNS轮询教程-负载均衡之DNS轮询,本例通过2台服务器实现DNS均衡负载.zip

    在本教程中,我们将探讨如何利用DNS轮询在两台服务器之间实现负载均衡。 首先,我们需要了解DNS(Domain Name System)的基本原理。DNS是互联网上的一个关键组件,它将易于记忆的域名转换为网络可以识别的IP地址。...

    DNS轮询和网络负载均衡优缺点比较

    DNS轮询和网络负载均衡是两种在网络环境中常用于优化服务器性能和提高可用性的技术。它们在确保服务稳定性和用户体验方面发挥着关键作用。下面将详细分析这两种方法的优缺点。 **DNS轮询** DNS轮询是一种简单易...

    分布式Web服务器中负载均衡的实现.pdf

    在分布式Web服务器的负载均衡实现中,每台服务器都需要维护集群内的负载信息,并根据这一信息动态调整其行为。当客户端尝试建立连接时,服务器必须迅速判断是自己处理该请求还是将其重定向至负载较低的服务器。这种...

    Web服务器负载均衡方案

    Web服务器负载均衡是一种技术,用于在多台服务器之间分配网络流量,以确保任何单台服务器不会过载,从而保持服务的稳定性和可用性。这种方案是大型网站和高并发应用的关键组成部分,它能够提高系统性能,增强容错...

    Web服务器和应用服务器的负载均衡

    总结来说,Web服务器和应用服务器的负载均衡是通过技术手段实现服务高可用性和高效运行的关键手段。无论是通过硬件还是软件实现,负载均衡都能有效提升系统的稳定性和响应速度,同时通过FailOver等高级功能确保服务...

    可以解决一个域名多台服务器均衡负载的DNS解析器

    在DNS层面上实现负载均衡,通常通过轮询、权重分配或根据服务器性能动态分配请求等策略来完成。 **WinMyDNS** 是一个专为此目的设计的DNS解析器,它支持多种负载均衡方法。例如,**轮询策略** 指DNS服务器按照预设...

    web集群服务的负载均衡方案选择与实现

    DNS负载均衡是一种简单而成本较低的实现方式,通过DNS服务器实现负载均衡的技术主要包括RR-DNS(Round-Robin DNS)。 ##### 3.1 RR-DNS的工作原理 - **基本概念**:RR-DNS是通过DNS服务器轮流返回多个IP地址来实现...

    IT面试题目-Web服务器负载均衡技术

    Web服务器负载均衡技术是IT领域中解决高并发访问和服务器压力的重要策略,它通过分散请求到多台服务器,确保没有单一服务器负担过重,从而提高服务的稳定性和响应速度。以下是对这一技术的详细说明: 1. **负载均衡...

    分布式负载均衡集群架构设计

    DNS轮询请求负载均衡服务器,负载均衡服务器通过调度选择负载均衡服务器来转发请求 3.Web服务器集群: 由至少两台Nginx Web服务器架设,来响应负载均衡服务器分发的请求 4.主从读写分离数据库集群: 一台主MySql...

    F5负载均衡WEB服务器模拟

    通过上述步骤,我们成功地在一台虚拟机中模拟了多台WEB服务器,并通过F5实现了负载均衡。这种方案不仅能够提高Web服务的性能和可靠性,还能有效降低运营成本。在实际应用中,还可以结合其他技术手段进一步提升系统的...

    web服务器集群负载均衡Nginx

    总的来说,Nginx的Web服务器集群负载均衡功能为企业级应用提供了强大的支持,它不仅能有效应对高并发访问,还能通过反向代理隐藏内部结构,提升安全性,同时通过灵活的配置和负载均衡策略,实现了系统的高效运行和...

    服务器负载均衡的基本功能和实现原理

    本文将深入探讨服务器负载均衡的基本功能以及其实现原理。 **基本功能** 1. **流量分发**:负载均衡器接收来自客户端的请求,然后根据预设策略将这些请求转发到不同的服务器,避免单点过载。 2. **健康检查**:...

    opensips与两台freeswitch负载均衡

    "opensips与两台freeswitch负载均衡"的主题聚焦于如何使用OpenSIPS作为负载均衡器来管理两台Freeswitch服务器,以实现Freeswitch的分布式部署。以下是对这个主题的详细解释: OpenSIPS是一个开源的SIP服务器,它...

    负载均衡软件、硬件实现方案

    基于DNS的负载均衡通过在DNS服务器上配置多个IP地址来实现。当客户端查询域名时,DNS服务器返回其中一个可用的IP地址,从而实现负载均衡。这种方式简单易用,但灵活性较低,因为更改DNS记录后需要等待TTL时间才能...

    web集群服务的负载均衡方案

    DNS负载平衡,即**轮询DNS**(Round-Robin DNS,简称RR-DNS),是一种通过DNS服务器来分散客户端请求到多个服务器的方法。当客户端请求访问一个特定的域名时,DNS服务器会根据轮询机制返回集群中某个服务器的IP地址...

    nginx负载均衡实现

    ### Nginx负载均衡实现 #### 一、负载均衡概念及必要性 负载均衡是一种用于在网络环境中分散工作负载的技术,通常用于改善网络性能、提高可用性和最大化资源利用。当单台服务器难以应对高流量和并发请求时,负载...

Global site tag (gtag.js) - Google Analytics