lvs实践(lvs+nginx+mariadb+php—fpm+nfs搭建wordpress)

lvs实践(lvs+nginx+mariadb+php—fpm+nfs搭建wordpress)

 

lvs实践(lvs+nginx+mariadb+php—fpm+nfs搭建wordpress)

lvs_dr模型 nginx mariadb php-fpm wordpress


 

 

实验拓扑

lvs项目.jpg-155.4kB

要求说明:
    1、lvs——director调度两台nginx+php-fpm real server 采用dr模型 算法为rr
    2、mriadb为real server提供数据库 nfs挂载至2台real-server提供文件服务
    3、为了方便起见各节点iptables和selinux均已关闭。
    4、windows本地提供host文件做解析z.com至

step1:网络配置

按照拓扑图要求配置网络环境。

step2:各节点软件安装

lvs——director:

 #yum -y install ipvsadm

两台real server:

# yum -y install nginx nfs-utils rpcbind
# yum -y install php-fpm php-mysql php-gd php-mbstring php-mcrypt

nfs-server:

# yum -y install nfs-utils rpcbind

Mariadb-server

#yum -y install mariadb*

step3:服务配置

nfs_server配置

#groupadd www -g 501
#useradd www -u 501 -g www -M -r  
#mkdir /usr/share/nginx/html/
#chown -R www:www /usr/share/nginx/html/
# echo '/usr/share   192.168.3.0/24(rw,sync,all_squash,anongid=501,anonuid=501)' > /etc/exports
#exportfs -rv
#systemctl start rpcbind.service 
#systemctl start nfs.service 
#cd /usr/share/nginx/html/
#准备好wordpress
#wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz
# tar zxvf wordpress-4.5.2-zh_CN.tar.gz
# cp -R wordpress/* ./
# cp wp-config-sample.php wp-config-sample.php.bak
# mv wp-config-sample.php wp-config.php
#修改如下 部分略
#<?php
/**
 * WordPress基础配置文件。
 *
 * 这个文件被安装程序用于自动生成wp-config.php配置文件,
 * 您可以不使用网站,您需要手动复制这个文件,
 * 并重命名为“wp-config.php”,然后填入相关信息。
 *
 * 本文件包含以下配置选项:
 *
 * * MySQL设置
 * * 密钥
 * * 数据库表名前缀
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');

/** MySQL数据库密码 */
define('DB_PASSWORD', '123456');

/** MySQL主机 */
define('DB_HOST', '192.168.3.8');

lvs—director

#ifconfig eno16777736:0 192.168.2.11/32 broadcast 192.168.2.11 up
#route add -host 192.168.2.11 dev eno16777736:0

两台real—server

#echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
#echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
#echo 1 > /proc/sys/net/ipv4/conf/eno16777736/arp_ignore
# echo 2 > /proc/sys/net/ipv4/conf/eno16777736/arp_announce
#ifconfig lo:0 192.168.2.11/32 broadcast 192.168.2.11 up
#route add -host 192.168.2.11 dev lo:0
#systemctl start rpcbind.service
#mount -t nfs 192.168.3.9:/usr/share/ /usr/share/nginx
# df -h

文件系统                      容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root        18G  1.4G   17G    8% /
devtmpfs                      105M     0  105M    0% /dev
tmpfs                         115M     0  115M    0% /dev/shm
tmpfs                         115M  8.6M  107M    8% /run
tmpfs                         115M     0  115M    0% /sys/fs/cgroup
/dev/sda1                     497M  124M  373M   25% /boot
tmpfs                          23M     0   23M    0% /run/user/0
192.168.3.9:/usr/share/nginx   18G  1.1G   17G    7% /usr/share/nginx
# vim /etc/nginx/conf.d/z.com.conf

server {
    listen          80;
    server_name     z.com;
    root            /htdocs/z_com;
    index           index.php;
    add_header X-via $server_addr;

    location / {
            root    /htdocs/z_com;
            index   index.php index.html index.html;
    }

    location ~* \.(jpg|jpeg|png|gif|js|css)$ {
            root    /htdocs/z_com;
    }

    location ~ \.php$ {
            root            /htdocs/z_com;
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /htdocs/z_com$fastcgi_script_name;
            include         fastcgi_params;
    }
}
#systemctl start nginx.service

Mariadb数据库配置

#systemctl start mariadb.service
#mysql
MariaDB [(none)]> create database wordpress;
grant all on wordpress.* to 'wordpress'@'%' identified by '123456';

step4:lvsdirector集群配置

#ipvsadm -A -t 192.168.2.11:80 -s rr
#ipvsadm -a -t 192.168.2.11:80 -r 192.168.2.117 -g
#ipvsadm -a -t 192.168.2.11:80 -r 192.168.2.135 -g
# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  192.168.2.11:80 rr
  -> 192.168.2.117:80             Route   1      0          0         
  -> 192.168.2.135:80             Route   1      0          0

最后效果如下
QQ图片20161214002614.png-80.1kB
QQ图片20161214100207.png-108.1kB
QQ图片20161214121852.png-47.2kB

原创文章,作者:Net17_desperado,如若转载,请注明出处:http://www.178linux.com/65445

(0)
Net17_desperadoNet17_desperado
上一篇 2017-01-03 11:05
下一篇 2017-01-03 11:05

相关推荐

  • 使用ext_skel和phpize构建php5扩展

    首先声明:我们要构建的是扩展或者模块名为hello_module.该模块提供一个方法:hello_word. 1、php环境的搭建 我们一般使用源码包编译安装,而不是binary包安装。因为使用PHP的二进制分发包安装有些冒险,这些版本倾向于忽略./configure的两个重要选项,它们在开发过程中很便利: 第一个–enable-debug。这个…

    Linux干货 2015-05-28
  • find使用详解

    文件查找是根据文件的各种属性去找到相对应的文件。 文件查找分为实时查找和非实时查找。     非实时查找是根据索引来进行查找;虽然非实时查找查询速度快,但在构建索引时相当占用资源,只有在系统空闲时才能进行,这样有可能会造成索引内容与当前系统中文件的状态不一致的情况,所以查找结果有可能会不准确。   …

    Linux干货 2015-03-18
  • 【招聘福利】三生石/郑州/6-10K

    三生石科技 岗位职责: 1、熟悉Linux系统环境/内核参数/系统调用接口等,对系统、网络和应用的原理等有较深刻的理解; 2、熟悉Linux操作系统的管理部署、配置和调优; 3、熟悉服务器架构部署、负载均衡、CDN等; 4、了解mysql数据库的基本管理技能,有Apache/Tomcat/MySQL等服务的优化配置经验; 5、了解常用系统自动化监控软件的使用…

    Linux干货 2015-11-10
  • N25期第五周作业

    1.显示当前系统上root、fedora或user1用户的默认shell grep -E ‘^(root|ftp|sync)’ /etc/passwd|cut -d: -f7 2.找出/etc/rc.d/init.d/functions文件中某单词后面跟一组小括号的行,形如:hello() grep ‘\b.*\b()’ /etc/rc.d/init.d/f…

    Linux干货 2016-12-26
  • N26 第四周博客作业

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。 演示:     [root@47d523181d25 /]# cp -r /etc/skel/ /home/tuser1     [root@47d523…

    Linux干货 2017-02-25
  • 马哥教育网络班21期+第7周课程练习

    1、创建一个10G分区,并格式为ext4文件系统; (1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl; [root@localhost ~]#mke2fs -t ext4 -b 2048 -m 2 -L &qu…

    Linux干货 2016-08-15