配置之前清空所有服務器防火牆規則
iptables -F
關閉selinux:
1、/usr/sbin/sestatus -v ##如果SELinux status參數為enabled即為開啟狀態
SELinux status: enabled
2、getenforce ##也可以用這個命令檢查
關閉SELinux:
1、臨時關閉(不用重啟機器):
setenforce 0 ##設置SELinux 成為permissive模式
##setenforce 1 設置SELinux 成為enforcing模式
2、修改配置文件需要重啟機器:
修改/etc/selinux/config 文件
將SELINUX=enforcing改為SELINUX=disabled
重啟機器即可
一、nginx服務器分發配置
yum安裝nginx分發器:
1 配置yum源:
第一步,在/etc/yum.repos.d/目錄下創建一個源配置文件nginx.repo:
vim /etc/yum.repos.d/nginx.repo
填寫以下內容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存,則會產生一個/etc/yum.repos.d/nginx.repo文件。
2 安裝:
yum install nginx -y
配置nginx反向代理:
http {
include /etc/nginx/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"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# include /etc/nginx/conf.d/*.conf;
upstream myserver {
ip_hash;
server 192.168.75.133;
server 192.168.75.134;
}
server{
listen 80;
server_name 192.168.75.132;
location / {
proxy_pass http://myserver;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
二、配置兩台后端服務器:
1 、配置好兩台apache環境
2 、配置兩台服務器目錄共享
一號機、二號機 相同操作安裝NFS:
yum -y install rpcbind
yum -y install nfs-utils
一號機掛載共享磁盤:
fdisk -l查看磁盤
掛載前格式化磁盤:mkfs.ext4 /dev/xvdb1
設置開機自動掛載:
echo '/dev/xvdb1 /mnt ext4 defaults 0 0' >> /etc/fstab
掛載:mount -a
配置NFS配置文件:
vim /etc/exports
寫入:
/mnt *(rw,sync,no_root_squash) ##保存退出
啟動nfs服務:
/etc/init.d/rpcbind start
/etc/init.d/nfs start
加入系統服務:
chkconfig rpcbind on
chkconfig nfs on
二號機測試共享並掛載:
showmount -e 10.129.14.52 #查看NFS服務器共享出來的目錄
mount -t nfs 10.129.14.52:/www/web /www/web #掛載NFS服務器上共享出來的目錄
自動掛載:
echo '10.25.212.98:/www/web /www/web nfs defaults 0 0'>> /etc/fstab
df -h 查看掛載情況