; lvs实践(lvs+nginx+mariadb+php—fpm+nfs搭建wordpress) | Linux运维部落

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

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

 

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

1
lvs_dr模型
1
nginx
1
mariadb
1
php-fpm
1
wordpress

 

 

实验拓扑

lvs项目.jpg-155.4kB

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

step1:网络配置

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

step2:各节点软件安装

lvs——director:

#yum-yinstallipvsadm

两台real server:

#yum-yinstallnginxnfs-utilsrpcbind
#yum-yinstallphp-fpmphp-mysqlphp-gdphp-mbstringphp-mcrypt

nfs-server:

#yum-yinstallnfs-utilsrpcbind

Mariadb-server

#yum-yinstallmariadb*

step3:服务配置

nfs_server配置

#groupaddwww-g501
#useraddwww-u501-gwww-M-r
#mkdir/usr/share/nginx/html/
#chown-Rwww:www/usr/share/nginx/html/
#echo'/usr/share192.168.3.0/24(rw,sync,all_squash,anongid=501,anonuid=501)'>/etc/exports
#exportfs-rv
#systemctlstartrpcbind.service
#systemctlstartnfs.service
#cd/usr/share/nginx/html/
#准备好wordpress
#wgethttps://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz
#tarzxvfwordpress-4.5.2-zh_CN.tar.gz
#cp-Rwordpress/*./
#cpwp-config-sample.phpwp-config-sample.php.bak
#mvwp-config-sample.phpwp-config.php
#修改如下部分略
#<?php
/**
*WordPress基础配置文件。
*
*这个文件被安装程序用于自动生成wp-config.php配置文件,
*您可以不使用网站,您需要手动复制这个文件,
*并重命名为“wp-config.php”,然后填入相关信息。
*
*本文件包含以下配置选项:
*
**MySQL设置
**密钥
**数据库表名前缀
**ABSPATH
*
*@linkhttps://codex.wordpress.org/zh-cn:%E7%BC%96%E8%BE%91_wp-config.php
*
*@packageWordPress
*/

//**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

#ifconfigeno16777736:0192.168.2.11/32broadcast192.168.2.11up
#routeadd-host192.168.2.11deveno16777736:0

两台real—server

#echo1>/proc/sys/net/ipv4/conf/all/arp_ignore
#echo2>/proc/sys/net/ipv4/conf/all/arp_announce
#echo1>/proc/sys/net/ipv4/conf/eno16777736/arp_ignore
#echo2>/proc/sys/net/ipv4/conf/eno16777736/arp_announce
#ifconfiglo:0192.168.2.11/32broadcast192.168.2.11up
#routeadd-host192.168.2.11devlo:0
#systemctlstartrpcbind.service
#mount-tnfs192.168.3.9:/usr/share//usr/share/nginx
#df-h

文件系统容量已用可用已用%挂载点
/dev/mapper/centos-root18G1.4G17G8%/
devtmpfs105M0105M0%/dev
tmpfs115M0115M0%/dev/shm
tmpfs115M8.6M107M8%/run
tmpfs115M0115M0%/sys/fs/cgroup
/dev/sda1497M124M373M25%/boot
tmpfs23M023M0%/run/user/0
192.168.3.9:/usr/share/nginx18G1.1G17G7%/usr/share/nginx
#vim/etc/nginx/conf.d/z.com.conf

server{
listen80;
server_namez.com;
root/htdocs/z_com;
indexindex.php;
add_headerX-via$server_addr;

location/{
root/htdocs/z_com;
indexindex.phpindex.htmlindex.html;
}

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

location~\.php${
root/htdocs/z_com;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME/htdocs/z_com$fastcgi_script_name;
includefastcgi_params;
}
}
#systemctlstartnginx.service

Mariadb数据库配置

#systemctlstartmariadb.service
#mysql
MariaDB[(none)]>createdatabasewordpress;
grantallonwordpress.*to'wordpress'@'%'identifiedby'123456';

step4:lvsdirector集群配置

#ipvsadm-A-t192.168.2.11:80-srr
#ipvsadm-a-t192.168.2.11:80-r192.168.2.117-g
#ipvsadm-a-t192.168.2.11:80-r192.168.2.135-g
#ipvsadm-Ln
IPVirtualServerversion1.2.1(size=4096)
ProtLocalAddress:PortSchedulerFlags
->RemoteAddress:PortForwardWeightActiveConnInActConn
TCP192.168.2.11:80rr
->192.168.2.117:80Route100
->192.168.2.135:80Route100

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

原创文章,作者:Net17_desperado,如若转载,请注明出处:/65445

联系我们

400-080-6560

在线咨询:点击这里给我发消息

邮件:1660809109@qq.com

工作时间:周一至周五,9:30-18:30,节假日同时也值班

友情链接:万达娱乐开户  万达主管QQ  万达主管  万达娱乐  万达娱乐主管QQ  万达招商  万达娱乐招商  万达娱乐注册  万达主管  万达直属