项目之五台服务器实战linux+Nginx+php+MySQL主主+NFS文共享集群架构;
1)部署1台Nginx WEB前端服务器(不能跟PHP-CGI公用); 2)部署2台PHP-CGI网站代码; 3)部署2台MYSQL主主同步架构(可以加入MHA或者DRBD); 4)部署Discuz和wordPress/ target=_blank class=infotextkey>WordPress多域名网站,通过两个域名dz.jf.com|wp.jf.com访问; 5)部署1台NFS文件共享服务器,网站代码统一存放在NFS服务器; 6)通过亿图或者visor将架构图画出来 。7)以上服务器再不影响使用的情况下,可以共用 。
文章插图
实验拓扑图
一.部署两台mariadb主主数据库1.安装mariadbDB数据库Mysql服务器节点1:10.10.10.10
Mysql服务器节点2:10.10.10.12
服务器节点1和服务器节点2安装mysql
安装yum install mariadb mariadb-devel mariab-server
启动 systemctl start mariadb
查看端口 netstat -anltp | grep 3306
查看进程 ps -ef | grep mysql
2.配置mraidb 服务器1配置文件服务器节点1配置修改配置文件 文件路径 /etc/my.cnf
[mysqld]
server-id = 1
log-bin=master1-bin
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
!includedir /etc/my.cnf.d
3.配置mariadb 服务器2配置文件服务器节点2配置修改配置文件 文件路径 /etc/my.cnf
[mysqld]
server-id=2
log-bin=master2-bin
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
# include all files from the config directory
!includedir /etc/my.cnf.d
4.服务器1配置grant replication slave on *.* to tongbu@"%" identified by "123456";
change master to master_host="10.10.10.12",master_user="tongbu",master_password="123456",master_log_file="master2-bin.000001",master_log_pos=684;
开启slave start slave;
5.服务器2配置grant replication slave on *.* to tongbu@"%" identified by "123456";
change master to master_host="10.10.10.11",master_user="tongbu",master_password="123456",master_log_file="master1-bin.000001",master_log_pos=694;
开启slave start slave;
二.部署nginx1.节点服务器IP地址10.10.10.13
2.源码安装nginx安装依赖包
yum install gcc gcc-c++ -y yum install pcre pcre-devel yum install zlib gzip zlib-devel -y yum -y install gcc gcc-c++ make zlib zlib-devel openssl openssl-devel pcre pcre-devel
3.编译安装.
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
make && make install
4.启动nginx 并查看相关进程/usr/local/nginx/sbin/nginx
Ps –ef | grep nginx
5.修改nginx配置文件并整合PHP并测试[root@dz nginx]# cat /usr/local/nginx/conf/nginx.conf
user www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type Application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name dz.jf.com;
location / {
root /html/dz.jf.com;
index index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ .php$ {
root /html/dz.jf.com;
fastcgi_pass 10.10.10.12:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name wp.jf.com;
location / {
root /html/wp.jf.com;
index index.php;
}
location ~ .php$ {
root /html/wp.jf.com;
fastcgi_pass 10.10.10.14:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
三、部署PHP1.PHP节点服务器-1 IP地址10.10.10.12
推荐阅读
- 礼品销售渠道有哪些模式
- MySQL的隐式转化
- MySQL的备份与恢复
- 丰田卡罗拉双擎三种模式怎么使用?
- 三种模式自由畅听,不受拘束健康生活,HAKII FIT真无线耳机体验
- MySQL索引怎么用?究竟能有多快?看完这篇你就懂了
- 多场景下MySQL临时表有什么用?
- Photoshop我要的光明“滤色”混合模式
- 联想|LCD屏/骁龙888+只卖1799!moto edge S30增加高性能模式:一键满血
- MySQL两地三中心方案初步设计