首页 » Web前端 » php过滤1717技巧_LNMP 自力支配MYSQL主主模式设备指导书

php过滤1717技巧_LNMP 自力支配MYSQL主主模式设备指导书

访客 2024-12-08 0

扫一扫用手机浏览

文章目录 [+]

1)支配1台Nginx WEB前端做事器(不能跟PHP-CGI公用); 2)支配2台PHP-CGI网站代码; 3)支配2台MYSQL主主同步架构(可以加入MHA或者DRBD); 4)支配Discuz和WordPress多域名网站,通过两个域名dz.jf.com|wp.jf.com访问; 5)支配1台NFS文件共享做事器,网站代码统一存放在NFS做事器; 6)通过亿图或者visor将架构图画出来。
7)以上做事器再不影相应用的情形下,可以共用。

实验拓扑图

php过滤1717技巧_LNMP 自力支配MYSQL主主模式设备指导书

一.支配两台mariadb主主数据库1.安装mariadbDB数据库

Mysql做事器节点1:10.10.10.10

php过滤1717技巧_LNMP 自力支配MYSQL主主模式设备指导书
(图片来自网络侵删)

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

2.PHP节点做事器-2 IP 地址

10.10.10.14

3.支配PHP

yum install php-devel php-mysql php-fpm -y

4.启动PHP-FPM 并查看干系进程

Systemctl start php-fpm

[root@bogon wp.dz.com]# ps -ef | grep php

root 1566 1 0 17:57 ? 00:00:00 php-fpm: master process (/etc/php-fpm.conf)

apache 1568 1566 0 17:57 ? 00:00:00 php-fpm: pool www

apache 1569 1566 0 17:57 ? 00:00:00 php-fpm: pool www

apache 1570 1566 0 17:57 ? 00:00:00 php-fpm: pool www

apache 1571 1566 0 17:57 ? 00:00:00 php-fpm: pool www

apache 1572 1566 0 17:57 ? 00:00:00 php-fpm: pool www

root 1717 1353 0 18:11 pts/1 00:00:00 grep --color=auto php

5.修正PHP的配置文件

/etc/php-fpm.d/www.conf

[www]

; Note: This value is mandatory.

listen = 10.10.10.12:9000 #将127.0.0.1改成实际的IP地址

; Set listen(2) backlog. A value of '-1' means unlimited.

; Default Value: -1

;listen.backlog = -1

; Default Value: any

;listen.allowed_clients = 127.0.0.1#注释掉

四、安装NFS

为了节省机器可以在nginx上面支配NFS做事器

1.安装NFS

Nginx 做事器节点充当NFS做事段 安装办法如下

yum install nfs -y

yum portmap -y

centos7的portmap现在名字是rpcbind

修正/etc/exports 文件

/html/ (rw,no_root_squash,no_all_squash,sync)

2.查看NFS的进程

[root@dz html]# ps -ef | grep nfs

root 7045 2 0 19:00 ? 00:00:00 [nfsd4_callbacks]

root 7051 2 0 19:00 ? 00:00:00 [nfsd]

root 7052 2 0 19:00 ? 00:00:00 [nfsd]

root 7053 2 0 19:00 ? 00:00:00 [nfsd]

root 7054 2 0 19:00 ? 00:00:00 [nfsd]

root 7055 2 0 19:00 ? 00:00:00 [nfsd]

root 7056 2 0 19:00 ? 00:00:00 [nfsd]

root 7057 2 0 19:00 ? 00:00:00 [nfsd]

root 7058 2 0 19:00 ? 00:00:00 [nfsd]

root 7705 7607 0 20:15 pts/1 00:00:00 grep --color=auto nfs

3.PHP节点安装NFS 客户端

yum install nfs -y

4.启动NFS

Systemctl start nfs

5.挂载

mount -t nfs 10.10.10.13:/html /html

6.查看挂载是否成功

[root@bogon html]# df -h

文件系统 容量 已用 可用 已用% 挂载点

/dev/sda2 20G 5.8G 15G 29% /

devtmpfs 479M 0 479M 0% /dev

tmpfs 489M 0 489M 0% /dev/shm

tmpfs 489M 6.8M 482M 2% /run

tmpfs 489M 0 489M 0% /sys/fs/cgroup

/dev/sda1 253M 105M 148M 42% /boot

/dev/mapper/centos-data 30G 33M 30G 1% /data

tmpfs 98M 0 98M 0% /run/user/0

10.10.10.13:/html 20G 7.7G 13G 39% /html

7.NFS测试

在客户端创建文件夹或者文件可以在做事端看到,在做事端创建文件在客户端也可以看到,代表NFS做事正常

五.安装论坛和wordpress1.安装wordpress

n 上传源码包到/html/wp.jf.com目录(上传机器为10.10.10.14 PHP-2)

n 解压 tar –xvf wordpress-4.9.4-zh_CN.tar.gz

n Mv wordpress / .

n 设置数据库

2.安装 discuz

n 上传源码包到/html/dz.jf.com目录(上传机器为10.10.10.12 PHP-1)

n 解压 tar –xvf Discuz_X3.2_SC_UTF8.zip

n Mv upload/ .

n Chmod 777 . –R 为了方便设置了777权限

3.设置数据库

Create wordpress;

Create discuz;

grant all on discuz. to root@"%" identified by "123456";

grant all on wordpress. to root@"%" identified by "123456";

4.安装完毕后效果
标签:

相关文章

fetch函数php技巧_Fetch API 教程

脚本都靠它发出 HTTP 要求,跟做事器通信。所谓的 AJAX 操作便是基于它实现的。假如没有它,就不会有单页运用。这个 XMLH...

Web前端 2024-12-09 阅读0 评论0