- 服务器说明
- MySQL主从配置
- 安装Redis
- 安装Memcache
- 静态资源服务器配置
- web机代码同步,采取 rsync+inotify方式
- 负载均衡
- FAQ
服务器说明(3web机情况,其他类似)
本文档仅供参考,达到集群部署目的即可,不同运维都有自己的方案,生产环境的要求要复杂于以下文档,具体环境具体对待
- 软件部署安装具体请参考 linux单机部署,集群部署可能不需按照单机部署那样所有软件都需要安装,根据服务器实际需要安装
- 集群部署机器分配,由于机器有限,部分服务器同时用做多个服务
实际情况下请根据自己的实际ip进行调整,包括各种配置中的都要根据您真实情况调整
机器 功能 安装软件 说明 192.168.10.228 负载均衡机 haproxy 负载均衡服务器 192.168.10.229 web1 nginx+php+rsync+inotify 主web机,并且推送代码到从web机 192.168.10.230 web2 nginx+php+rsync 从web机 192.168.10.231 web3 nginx+php+rsync 从web机 192.168.10.232 memcached memcached 缓存服务器 192.168.10.232 redis redis redis服务器 192.168.10.232 NFS nginx+nfs-utils 资源,图片服务器 192.168.10.233 mysql主 mysql 主数据库 192.168.10.234 mysql从 mysql 从数据库 - 关于一些配置文件以及相关目录说明
名称 本次版本(2016.07) 相关说明 nginx openresty/1.9.7.4 配置文件 /usr/local/nginx/conf/nginx.conf
vhost配置文件 /usr/local/nginx/conf/vhosts/*.confphp 5.6.19 配置文件 /usr/local/php56/etc/php.ini
php 扩展配置文件目录 /usr/local/php56/etc/php.d/
zend 配置文件 /usr/local/php56/etc/php.d/Zend.ini
memcached 配置文件 /usr/local/php56/etc/php.d/memcached.inimysql 5.6.22 basedir /usr/local/mysql
datadir /data/mysql/3306
配置文件 /usr/local/mysql/my.cnfredis 3.0.3 配置文件 /etc/redis.conf memcached 1.4.4 配置文件 /etc/sysconfig/memcached rsync+inotify 1.4.4 配置文件 /etc/rsyncd.conf
密码文件 /etc/rsyncd.passwd
配合inotify监控脚本位置 /root/rsync.sh代码目录 - /data/httpd
MySQL主从安装配置
MySQL主192.168.10.233, MySQL从
192.168.10.234,
主服务器和从服务器都安装MySQL
从服务器都安装MySQL
初始化yum源,将shopex-lnmp源加入到系统中,如果已经参照单机部署初始化过yum源了则省略此步骤
1 2 3 |
yum install wget -y cd /etc/yum.repos.d/ wget http://mirrors.shopex.cn/shopex/shopex-lnmp/shopex-lnmp.repo |
安装mysql
1 |
yum install mysql -y |
启动MySQL
1 |
/etc/init.d/mysqld start |
登录MySQL并且修改密码并且删除空用户
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 |
#这里设置 shopex123 为msyql登录密码 mysql> UPDATE mysql.user SET password = PASSWORD('shopex123') WHERE user = 'root'; Query OK, 4 rows affected (0.00 sec) Rows matched: 4 Changed: 4 Warnings: 0 mysql> SELECT user,host,password FROM mysql.user; +------+-----------------------+-------------------------------------------+ | user | host | password | +------+-----------------------+-------------------------------------------+ | root | localhost | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | localhost.localdomain | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | 127.0.0.1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | ::1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | | localhost | | | | localhost.localdomain | | +------+-----------------------+-------------------------------------------+ 6 rows in set (0.00 sec) mysql> DROP user ''@localhost; Query OK, 0 rows affected (0.00 sec) mysql> DROP user ''@localhost.localdomain; Query OK, 0 rows affected (0.00 sec) mysql> SELECT user,host,password FROM mysql.user; +------+-----------------------+-------------------------------------------+ | user | host | password | +------+-----------------------+-------------------------------------------+ | root | localhost | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | localhost.localdomain | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | 127.0.0.1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | ::1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | +------+-----------------------+-------------------------------------------+ 4 rows in set (0.00 sec) |
配置
修改主服务器master192.168.10.233
vim /usr/local/mysql/my.cnf
1 2 3 |
[mysqld] log-bin=mysql-bin #[必须]启用二进制日志 server-id=1 #[必须]服务器唯一ID,默认是1,一般取IP最后一段 |
修改从服务器slave192.168.10.234
vim /usr/local/mysql/my.cnf
1 2 3 |
[mysqld] log-bin=mysql-bin #[不是必须]启用二进制日志 server-id=2 #[必须]服务器唯一ID,默认是1,一般取IP最后一段 |
重启两台服务器/etc/init.d/mysql restart
登录master服务器,给Slave服务器授权
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
mysql> GRANT REPLICATION SLAVE ON *.* to 'root'@'192.168.10.234' identified by 'shopex123'; Query OK, 0 rows affected (0.00 sec) mysql> SELECT user,host,password FROM mysql.user; +------+-----------------------+-------------------------------------------+ | user | host | password | +------+-----------------------+-------------------------------------------+ | root | localhost | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | localhost.localdomain | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | 127.0.0.1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | ::1 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | | root | 192.168.10.234 | *13EB6A5E957F69117458EF4E95776C9B0BB9FA75 | +------+-----------------------+-------------------------------------------+ 6 rows in set (0.00 sec) |
查询主数据库状态
1 2 3 4 5 6 7 8 9 |
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000001 | 640 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec) #这里需要记录 File 以及 Position 的值,在操作从服务器时会用到 |
配置Slave 服务器
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 |
# 登录mysql Slave 服务器 [root@localhost ~]# mysql -uroot -p Enter password: # 执行同步SQL语句 mysql> change master to master_host='192.168.10.233',master_user='root',master_password='shopex123',master_log_file='mysql-bin.000001',master_log_pos=640; Query OK, 0 rows affected (0.03 sec) # 启动同步进程 mysql> start slave; Query OK, 0 rows affected (0.00 sec) # 主从同步检查 mysql> show slave status\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.10.233 Master_User: root Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 640 Relay_Log_File: localhost-relay-bin.000002 Relay_Log_Pos: 283 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 640 Relay_Log_Space: 460 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 4bbab569-4cb1-11e6-86f5-d4bed9a810af Master_Info_File: /data/mysql/3306/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 1 row in set (0.00 sec) # 可以看到:Slave_IO_Running | Slave_SQL_Running两个值都是YES,说明配置成功了 |
主从服务器测试
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 |
# 主服务器Mysql,建立数据库,并在这个库中建表插入一条数据 mysql> create database test_db; Query OK, 1 row affected (0.00 sec) mysql> use test_db; Database changed mysql> create table test_tb(id int(3),name char(10)); Query OK, 0 rows affected (0.00 sec) mysql> insert into test_tb values(001,'test'); Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | test_db | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) # 从服务器查看 mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | test | | test_db | +--------------------+ 5 rows in set (0.00 sec) mysql> use test_db; Database changed mysql> show tables; +-------------------+ | Tables_in_test_db | +-------------------+ | test_tb | +-------------------+ 1 row in set (0.00 sec) mysql> select * from test_tb; +------+------+ | id | name | +------+------+ | 1 | test | +------+------+ 1 row in set (0.00 sec) |
主web配置Mysql主从
MySQL主服务器给web服务器授权访问
1 |
GRANT ALL PRIVILEGES ON *.* to 'root'@'192.168.10.229' identified by 'shopex123'; |
web服务器配置
修改数据库配置文件vim /data/httpd/config/production/database.php
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 |
/* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | 对应原系统: DB_* | */ 'connections' => array( #'default' => array( # 'driver' => 'mysqli', # 'host' => '192.168.10.233', # 'dbname' => 'b2b2c', # 'user' => 'root', # 'password' => 'shopex123', # 'charset' => 'utf8', # //'collation' => 'utf8_general_ci', #), 'default' => array( 'master' => array('user' => 'root', 'password' => 'shopex123', 'host' => '192.168.10.233', 'dbname' => 'b2b2c','charset' => 'utf8'), 'slaves' => array( array('user' => 'root', 'password'=>'shopex123', 'host' => '192.168.10.234', 'dbname' => 'b2b2c','charset' => 'utf8'), ), 'driver' => 'mysqli', ), ), |
安装Redis
初始化yum源,将shopex-lnmp源加入到系统中,如果已经参照单机部署初始化过yum源了则省略此步骤
1 2 3 4 |
yum install wget -y cd /etc/yum.repos.d/ wget http://mirrors.shopex.cn/shopex/shopex-lnmp/shopex-lnmp.repo yum install epel-release -y |
安装
1 |
yum install redis -y |
配置
redis开启远程访问
1 2 3 |
vim /etc/redis.conf 注释掉绑定127.0.0.1的访问,则所有局域网都能访问 #bind 127.0.0.1 |
启动
1 |
/etc/init.d/redis start |
安装Memcached
初始化yum源,将shopex-lnmp源加入到系统中,如果已经参照单机部署初始化过yum源了则省略此步骤
1 2 3 4 |
yum install wget -y cd /etc/yum.repos.d/ wget http://mirrors.shopex.cn/shopex/shopex-lnmp/shopex-lnmp.repo yum install epel-release -y |
安装
1 |
yum install memcached -y |
配置
1 2 |
配置文件位置/etc/sysconfig/memcached 可以修改内存大小等配置 |
启动
1 |
/etc/init.d/memcached start |
静态资源服务器配置
通过NFS的方式将web服务器中的图片,模版,js登静态资源进行挂在到静态资源服务器,然后静态资源都通过该服务器进行调用
NFS安装
初始化yum源
将shopex-lnmp源加入到系统中,在线地址查看有哪些软件 http://mirrors.shopex.cn/shopex/shopex-lnmp/ 可以安装
1 2 |
cd /etc/yum.repos.d/ wget http://mirrors.shopex.cn/shopex/shopex-lnmp/shopex-lnmp.repo |
安装epel扩展源
1 |
yum install epel-release -y |
web服务器和storage服务器都安装nfs
1 2 3 4 5 |
yum install nfs-utils -y #根据Centos选择安装 yum install portmap -y #(适用centos 5) yum install rpcbind -y #(适用centos 6) |
启动NFS服务,启动顺序一定要先启动rpcbind,后在启动nfs
1 2 |
/etc/init.d/rpcbind start /etc/init.d/nfs start |
storage服务器都安装nginx
1 |
yum install ngx_openresty -y |
NFS配置
将web服务器中已有的资源复制到storage服务器
1 2 3 |
scp -r /data/httpd/public/themes/ root@192.168.10.232:/data/httpd/ scp -r /data/httpd/public/images/ root@192.168.10.232:/data/httpd/ scp -r /data/httpd/public/app/ root@192.168.10.232:/data/httpd/ |
在storage服务器vim /etc/exports,加入如下参数
1 2 3 4 5 6 |
#可以使用*不限制挂载机器 #/data/httpd/themes *(rw,sync,all_squash,anonuid=502,anongid=502) /data/httpd/themes 192.168.10.229/24(rw,sync,all_squash,anonuid=502,anongid=502) /data/httpd/images 192.168.10.229/24(rw,sync,all_squash,anonuid=502,anongid=502) /data/httpd/app 192.168.10.229/24(rw,sync,all_squash,anonuid=502,anongid=502) |
修改好执行命令exportfs -rv
查看是否成功
1 2 3 4 5 |
showmount -e 192.168.10.232 Export list for 192.168.10.232: /data/httpd/app 192.168.10.229/24 /data/httpd/images 192.168.10.229/24 /data/httpd/themes 192.168.10.229/24 |
- web服务器中静态资源挂载到storage服务器
1 2 3 |
mount 192.168.10.232:/data/httpd/themes /data/httpd/public/themes mount 192.168.10.232:/data/httpd/images /data/httpd/public/images mount 192.168.10.232:/data/httpd/app /data/httpd/public/app |
解决跨域加载字体问题:firefox和IE9不支持对icon font字体的跨域访问
静态资源服务器修改nginx配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
vim /usr/local/nginx/conf/vhosts/default.conf server { ... #在server中新增如果下配置 location ~* \.(eot|ttf|woff)$ { add_header Access-Control-Allow-Origin *; } ... } 新增 AddType vim /usr/local/nginx/conf/mime.types font/ttf ttf; font/otf otf; |
主web配置
复制配置文件到production cp /data/httpd/config/storager.php /data/httpd/config/production/storager.php
修改配置文件vim /data/httpd/config/production/storager.php
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 |
/* |-------------------------------------------------------------------------- | 静态资源映象站地址(js css) |-------------------------------------------------------------------------- | | 资源映像站地址 | */ 'host_mirrors' => array( 'http://192.168.10.232', //'http://img2.example.com', ), /* |-------------------------------------------------------------------------- | 图片映象站地址 |-------------------------------------------------------------------------- | | 图片资源映像站地址 | 一个域名标识对应一个域名,在替换的时候域名的时候替换对应的值就可以了 | 图片域名标识不可变,添加后慎重删除,除非确保改标识下不存在图片了 | 如果未配置则默认使用 defaultHostMirrors 作为图片标识 */ 'host_mirrors_img' => [ 'img0'=>'http://192.168.10.232', //'img1'=>'http://img2.example.com', ], |
web机代码同步,采取 rsync+inotify方式
说明:这里的配置是采取单向同步,采取 主web机 向 从web机 推送代码,如要
双向同步,请自行配置
安装配置 rsync (主web机和从web机 都需要安装)
- 安装 rsync
1yum install rsync -y - 编辑 rsyncd.conf 配置文件,如果没有则创建一个,主web服务器也可以不配置此文档,但是为了统一也可以配置一下
- 并且约定从web机中的rsyncd配置的用户名和密码全部一样,如rsyncd.passwd 中为
rsync:123456,并且模块名也一样,如rsyncd.conf中为
salve_web
- 同步的时候注意防火墙问题可能导致无法同步
123vim /etc/rsyncd.conf#添加以下内容
1234567891011121314151617181920212223242526272829303132#rsync通用配置文件,配置的注释不要写在配置后面,否则会有问题uid = rootgid = rootuse chroot = 0port = 873#允许ip访问设置,请根据实际需要进行配置,这里为了方便设为全网段 *,生产环境下为了安全请指定ip或ip段# hosts allow = 192.168.0.1/255.255.255.0 198.162.145.1 10.0.1.0/255.255.255.0hosts allow = *max connections = 0timeout = 300pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.loglog format = %t %a %m %f %btransfer logging = yessyslog facility = local3#方括号中为模块声明,对应命名,这里master_web对应了主web机配置,从服务器可都为[slave_web],方便inotify脚本配置[master_web]#指定当前模块在rsync服务器上的同步路径,该参数是必须指定的path = /data/httpd/#注释,可以同模块名一样,从服务器可都为slave_webcomment = master_webignore errors#是否允许客户端上传文件read only = nolist = no#指定由空格或逗号分隔的用户名列表,只有这些用户才允许连接该模块auth users = rsync#保存密码和用户名文件,需要自己生成secrets file = /etc/rsyncd.passwd - 编辑 rsyncd.passwd 密码配置文件,如果没有则创建一个
1vim /etc/rsyncd.passwd
注意:添加以下内容的时候,千万要看清楚,不要全部复制粘贴,分主web服务器和从web服务器
1234567#从web服务器配置内容,需要填写 用户名:密码 ,多个用户名密码则每添加多行,建议从web机都是一样的用户名和密码rsync:123456#主web服务器配置内容,只需要填写从服务器的密码,例如这里从服务器配的用户名密码都是rsync:123456,这里主服务器则写123456一个就可以了123456 - 修改密码文件 /etc/rsyncd.passwd 的权限为600
12#修改密码文件权限为600chmod 600 /etc/rsyncd.passwd - 启动 rsync 服务并设置开机自启动。
下面两行分别执行,不要全部复制粘贴
12345#以守护进程方式启动rsync服务/usr/bin/rsync --daemon --config=/etc/rsyncd.conf#添加开机自启动echo "/usr/bin/rsync --daemon --config=/etc/rsyncd.conf">>/etc/rc.local - 验证代码是否能够同步, 在
主web服务器上执行下面命令,如有报错,请自行查找原因,
123456# 主web服务器推送代码到从web服务器,命令中的# rsync@192.168.10.230::slave_web# 192.168.10.230 为从web服务器的ip,# slave_web 为从web服务器的 rsyncd.conf 中配置的模块名,# rsync 为为从web服务器的中 rsyncd.passwd 中配置的用户名rsync -vzrtopg --delete --progress /data/httpd/ rsync@192.168.10.230::slave_web --password-file=/etc/rsyncd.passwd
安装配置 inotify (主web机需要安装,从web机不需要)
- 安装 inotify
1yum install inotify-tools - 配置rsync.sh同步监控脚本
1vim /root/rsync.sh
添加以下内容
1234567891011121314#!/bin/bashsrc=/data/httpd/des=web2user=rsync#多个ip就用空格间断,每个IP用双引号包起来host="192.168.10.230"/usr/bin/inotifywait -mrq --exclude=public/images --exclude=public/themes --exclude=data/logs --timefmt '%d/%m/%y %H:%M' --format '%T %w%f' -e modify,delete,create,attrib $src | while read filedofor hostip in $hostdorsync -vzrtopg --delete --progress --exclude=public/images --exclude=public/themes --exclude=data/logs ${src} ${user}@${hostip}::${des} --password-file=/etc/rsyncd.passwdecho "${file} was rsynced" >> /tmp/rsync.log 2>&1donedone - 配置rsync.sh脚本的执行权限
1chmod +x /root/rsync.sh - 运行rsync.sh同步监控脚本和配置守护进程
12345#主web服务器 推送代码到 从web服务器 的时候主web服务器的rsync.passwd只需要配置密码就可以,不用配置用户名,从服务器最好配置同一个用户名和密码)nohup sh /root/rsync.sh &#建立守护进程运行rsync.sh脚本echo "nohup sh /root/rsync.sh &" >> /etc/rc.local 注意:如果inotify报错upper limit on inotify watches reached,要修改inotify的max_user_watches参数
123456#编辑 /etc/sysctl.conf 文件,配置fs.inotify.max_user_watches,防止句柄数过多报错vim /etc/sysctl.conf#加上下面这行,这个不是脚本,不要执行,复制内容到 /etc/sysctl.conffs.inotify.max_user_watches=8192000#配置好后,执行下面命令使配置生效sysctl -p
负载均衡
安装 haproxy
1 |
yum install haproxy -y |
配置
集群部署机器分配,具体请根据实际情况配置
机器 | 功能 | 端口 |
---|---|---|
192.168.10.228 | haproxy | 80 |
192.168.10.229 | web 1 | 80 |
192.168.10.230 | web 2 | 80 |
192.168.10.231 | web 3 | 80 |
192.168.10.228(负载均衡服务器) 编辑/etc/haproxy/haproxy.cfg文件
1 2 |
vim /etc/haproxy/haproxy.cfg(此配置不分前后台) #以下为配置内容,根据实际情况调整 |
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 |
global log 127.0.0.1 local3 chroot /var/lib/haproxy pidfile /var/run/haproxy.pid maxconn 30000 user haproxy group haproxy daemon stats socket /var/lib/haproxy/stats defaults option http-keep-alive mode http log global option httplog option dontlognull option accept-invalid-http-request option http-server-close option redispatch retries 3 timeout http-request 60s timeout queue 1m timeout http-keep-alive 60s timeout connect 60s timeout client 1m timeout server 1m timeout check 2000 maxconn 30000 stats enable stats uri /shopexadminss stats auth admin:r4b7x3m7vVN3 frontend main *:80 default_backend app backend static balance roundrobin server static 192.168.10.229:80 check backend app balance roundrobin mode http cookie SERVERID insert nocache indirect server web1 192.168.10.229:80 check inter 1500 rise 1 fall 3 weight 1 server web2 192.168.10.230:80 check inter 1500 rise 1 fall 3 weight 1 server web3 192.168.10.231:80 check inter 1500 rise 1 fall 3 weight 1 |
启动 haproxy
1 |
/etc/init.d/haproxy start |
访问负载均衡服务器,检验效果
FAQ
1、同步的目录必须是已有的目录,并且权限正确
2、同步代码的配置中,请检查好模块名,密码等,主web服务器的密码文件中不需要写用户名,本文档中从web服务器之间的rsync配置的用户名和密码都是一致的
2016年11月06日 12:50 沙发
牛逼啊
2019年08月22日 21:38 板凳
当你决定坚持一件事情,全世界都会为你让路 www.aaa137.com