Recently in the study of the construction of the site structure, with 4 virtual machines to build a simple site architecture, very simple, suitable for getting started.
The following example uses BIND9 to do DNS server, Nginx load balancer, background server is Apache. Installation process will not say, direct placement configuration, so that beginners to the site structure has a preliminary understanding.
The IP of the four machines are:
192.168.1.104--dns Server +nginx to be responsible for balancing
192.168.1.105--paache Server
192.168.1.110--paache Server
192.168.1.111--paache Server
=============================
192.168.1.104 BIND9.5.2
After installing BIND9, start the bind service with the named command (named-g check the boot process information, this is useful)
The first description of the bind log is generally written in the/var/log/messages, configuration error to check the log itself, to indicate what error directly to take the error to Google
named.conf Configuration:
A simple bind consists of several parts of the following blackbody:
Options {
Directory "/USR/LOCAL/NAMED/ETC"; The directory specified here is the directory where the zone file is stored, and if the file zone file is not stored in this directory, you will be prompted to find the file when it is started.
Allow-query-cache {any;};
Pid-file "Named.pid";
};
Key "Rndc-key" {
Algorithm HMAC-MD5;
Secret "+qe+rqths2/dda4xrhgzjq==";
};
Controls {
inet 127.0.0.1 Port 953//define Local listening ports
Allow {127.0.0.1;} keys {"Rndc-key";};//only local connections are allowed here, to be able to access the key
};
Logging {
Channel Query_log {
File "/srv/named/query.log" versions 5 size 20m;
Severity info;
Print-time Yes;
Print-category Yes;
};
Category Queries {
Query_log;
};
};
#root Zone (data area)
Zone "." in {
Type hint;
File "Named.root";
};
Zone "localhost" in {
Type master;
File "Localhost.zone";
allow-update {none;};
};
Zone "0.0.127.in-addr.arpa" in {
Type master;
File "Named.local";
allow-update {none;};
};
Zone "formyz.cn" in {
Type master;
File "Formyz.cn.zone";
allow-update {none;};
};
The contents of several files specified in the zone above are as follows:
[email protected] named]# cat Etc/localhost.zone
$TTL 86400
$ORIGIN localhost.
@ 1D in SOA @ root (
42
3H
15M
1W
1D
)
1D in NS @
1D in A 127.0.0.1
[email protected] named]# cat etc/named.local
$TTL 86400
@ in SOA localhost. Root.localhost. (
2006121601
3H
15M
1W
1D)
In NS localhost.
1 in PTR localhost
[[email protected] named] #cat Etc/formyz.cn.zone
$TTL 1D
@ in SOA ns1.formyz.cn. root.ns1.formyz.cn. (
2009071966
3H
15M
2W
1D)
In NS ns1.formyz.cn.
In NS ns2.formyz.cn.
In MX ten Mail.formyz.cn.a.
; A RECORDER
@ in A 192.168.1.104
NS1 in A 192.168.1.203//These two casually write, or comment out
; ns2 in A 192.168.1.204
The configuration of several zone files does not explain, a lot of online, to check their own.
The contents of the above Key/option/control three options can be generated with the Rncd-confgen command, and the command and RNDC commands (to manage the named service) are all installed bind9. For example, I install to/usr/local/named, the command is in this directory under the Sbin, the configuration file in this directory, etc. Cd/usr/local/named/sbin,./rndc-confgen >>named.conf can be.
By the way, like me to install bind to the/usr/local/named directory, the system environment does not have this path, cannot find the named service, that is, can not directly use the named command, how to do? Do not want to configure the environment to build a soft connection can be:
Ln-s/usr/local/named/sbin/named/sbin/named
Check to see if our soft links are correct:
[Email protected] named]# ls-l/sbin/named
lrwxrwxrwx. 1 root root 4 17:13/sbin/named-/usr/local/named/sbin/named
In the same place, RNDC these commands can also be used to create a soft connection.
[Email protected] named]# cat/etc/resolv.conf
; Generated By/sbin/dhclient-script
NameServer 192.168.1.104//Add a DNS server here to use
NameServer 192.168.1.1
At this point, the bind service can be used normally:
[email protected] named]# nslookup formyz.cn
server:192.168.1.104
address:192.168.1.104#53
Name:formyz.cn
address:192.168.1.104
====================================
192.168.1.104 Nginx Load Balancer
The compilation installation process is omitted.
NGINX.CONF configuration:
#user nobody;
Worker_processes 4;
#error_log Logs/error.log;
Error_log Logs/error.log warn;
#error_log Logs/error.log Info;
PID Logs/nginx.pid;
Events {
Use Epoll;
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";
Access_log Logs/access.log Main;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 65;
upstream Webservers {
Server 192.168.1.104:8080;//If this installation Nginx server only do the request distribution, can not this line, add this line indicates that the server itself also provides the request processing service, with the red font in the following server{} together
Server 192.168.1.105:80;
Server 192.168.1.110:80;
Server 192.168.1.111:80; We do not set the value of the weight weight here, the server will do a poll load balancer
}
server {
Listen 80;
server_name www.formyz.cn;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location /{
Proxy_pass http://webservers;//
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forward-for $proxy _add_x_forwarded_for;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
Server {
Listen 8080;
server_name www.formyz.cn;
Location/{
root HTML;
Index index.html index.htm;
}
}
}
The most important is the settings inside the Upstrame and server location.
===================================
The following three servers are simply installed Apache service, too simple, not posted here. After learning a little bit more to write alone.
===================================
Any of the virtual machine to add our DNS server (if not add in the/etc/hosts file will be added 192.168.1.104 formyz.cn such a piece, otherwise can not find our server), we will be able to use the domain name to visit our website. I'm going to use elinks directly to access it.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/CC/wKioL1WI5hWjhHCgAAGRUFQydZU124.jpg "title=" 0.png " alt= "Wkiol1wi5hwjhhcgaagrufqydzu124.jpg"/>
This is our 192.168.1.104, this server with NGIXN installed.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/CC/wKioL1WI5XmA4gviAAD7jJmvhfc793.jpg "style=" float: none; "title=" 1.png "alt=" Wkiol1wi5xma4gviaad7jjmvhfc793.jpg "/>
Second time access with ELinks
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/D0/wKiom1WI48GTwWYAAAH0oHkpdKo460.jpg "style=" float: none; "title=" 2.png "alt=" Wkiom1wi48gtwwyaaah0ohkpdko460.jpg "/>
Third time visit
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/CC/wKioL1WI5XrgnFHbAAGr8SutE_Q978.jpg "style=" float: none; "title=" 3.png "alt=" Wkiol1wi5xrgnfhbaagr8sute_q978.jpg "/>
Fourth time visit
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/D0/wKiom1WI48HANvhMAAFB8RAHFPI330.jpg "style=" float: none; "title=" 4.png "alt=" Wkiom1wi48hanvhmaafb8rahfpi330.jpg "/>
Each time you access a different server, it just fits in the order of our polling.
The main thing here is to find out the complete erection process of a website, not much in-depth research. Now at the beginning of not much, record, but also to the needs of friends for reference.
This article from "Bywind" blog, reproduced please contact the author!
An example of a complete foundation site architecture: Bind+nginx+apache