項(xiàng)目之五臺(tái)服務(wù)器實(shí)戰(zhàn)Linux+Nginx+PHP+MySQL主主+NFS文共享集群架構(gòu);
1)部署1臺(tái)Nginx WEB前端服務(wù)器(不能跟PHP-CGI公用); 2)部署2臺(tái)PHP-CGI網(wǎng)站代碼; 3)部署2臺(tái)MYSQL主主同步架構(gòu)(可以加入MHA或者DRBD); 4)部署Discuz和WordPress多域名網(wǎng)站,通過(guò)兩個(gè)域名dz.jf.com|wp.jf.com訪問(wèn); 5)部署1臺(tái)NFS文件共享服務(wù)器,網(wǎng)站代碼統(tǒng)一存放在NFS服務(wù)器; 6)通過(guò)億圖或者visor將架構(gòu)圖畫(huà)出來(lái)。 7)以上服務(wù)器再不影響使用的情況下,可以共用。
實(shí)驗(yàn)拓?fù)鋱D
一.部署兩臺(tái)mariadb主主數(shù)據(jù)庫(kù)1.安裝mariadbDB數(shù)據(jù)庫(kù)Mysql服務(wù)器節(jié)點(diǎn)1:10.10.10.10
Mysql服務(wù)器節(jié)點(diǎn)2:10.10.10.12
服務(wù)器節(jié)點(diǎn)1和服務(wù)器節(jié)點(diǎn)2安裝mysql
安裝yum install mariadb mariadb-devel mariab-server
啟動(dòng) systemctl start mariadb
查看端口 netstat -anltp | grep 3306
查看進(jìn)程 ps -ef | grep mysql
2.配置mraidb 服務(wù)器1配置文件
服務(wù)器節(jié)點(diǎn)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 服務(wù)器2配置文件
服務(wù)器節(jié)點(diǎn)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.服務(wù)器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;
開(kāi)啟slave start slave;
5.服務(wù)器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;
開(kāi)啟slave start slave;
二.部署nginx1.節(jié)點(diǎn)服務(wù)器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=xintu --group=xintu --with-http_ssl_module --with-http_stub_status_module
make && make install
4.啟動(dòng)nginx 并查看相關(guān)進(jìn)程
/usr/local/nginx/sbin/nginx
Ps –ef | grep nginx
5.修改nginx配置文件并整合PHP并測(cè)試
[root@dz nginx]# cat /usr/local/nginx/conf/nginx.conf
user xintu;
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節(jié)點(diǎn)服務(wù)器-1 IP地址
10.10.10.12
2.PHP節(jié)點(diǎn)服務(wù)器-2 IP 地址10.10.10.14
3.部署PHPyum install php-devel php-mysql php-fpm -y
4.啟動(dòng)PHP-FPM 并查看相關(guān)進(jìn)程
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 xintu
apache 1569 1566 0 17:57 ? 00:00:00 php-fpm: pool xintu
apache 1570 1566 0 17:57 ? 00:00:00 php-fpm: pool xintu
apache 1571 1566 0 17:57 ? 00:00:00 php-fpm: pool xintu
apache 1572 1566 0 17:57 ? 00:00:00 php-fpm: pool xintu
root 1717 1353 0 18:11 pts/1 00:00:00 grep --color=auto php
5.修改PHP的配置文件/etc/php-fpm.d/xintu.conf
[xintu]
; Note: This value is mandatory.
listen = 10.10.10.12:9000 #將127.0.0.1改成實(shí)際的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
為了節(jié)省機(jī)器可以在nginx上面部署NFS服務(wù)器
1.安裝NFSNginx 服務(wù)器節(jié)點(diǎn)充當(dāng)NFS服務(wù)段 安裝方式如下
yum install nfs* -y
yum portmap* -y
centos7的portmap現(xiàn)在名字是rpcbind
修改/etc/exports 文件
/html/ *(rw,no_root_squash,no_all_squash,sync)
2.查看NFS的進(jìn)程
[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節(jié)點(diǎn)安裝NFS 客戶端yum install nfs* -y
4.啟動(dòng)NFSSystemctl start nfs
5.掛載mount -t nfs 10.10.10.13:/html /html
6.查看掛載是否成功
[root@bogon html]# df -h
文件系統(tǒng) 容量 已用 可用 已用% 掛載點(diǎn)
/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測(cè)試
在客戶端創(chuàng)建文件夾或者文件可以在服務(wù)端看到,在服務(wù)端創(chuàng)建文件在客戶端也可以看到,代表NFS服務(wù)正常
五.安裝論壇和wordpress1.安裝wordpress
n 上傳源碼包到/html/wp.jf.com目錄(上傳機(jī)器為10.10.10.14 PHP-2)
n 解壓 tar –xvf wordpress-4.9.4-zh_CN.tar.gz
n Mv wordpress /* .
n 設(shè)置數(shù)據(jù)庫(kù)
2.安裝 discuzn 上傳源碼包到/html/dz.jf.com目錄(上傳機(jī)器為10.10.10.12 PHP-1)
n 解壓 tar –xvf Discuz_X3.2_SC_UTF8.zip
n Mv upload/* .
n Chmod 777 * . –R 為了方便設(shè)置了777權(quán)限
3.設(shè)置數(shù)據(jù)庫(kù)Create wordpress;
Create discuz;
grant all on discuz.* to root@"%" identified by "123456";
grant all on wordpress.* to root@"%" identified by "123456";
4.安裝完畢后效果
掃描二維碼推送至手機(jī)訪問(wèn)。
版權(quán)聲明:本文由信途科技轉(zhuǎn)載于網(wǎng)絡(luò),如有侵權(quán)聯(lián)系站長(zhǎng)刪除。
轉(zhuǎn)載請(qǐng)注明出處http://macbookprostickers.com/xintu/10580.html