keepalived+haproxy(雙主)+nginx(靜態)+lamp(動態)部署phpBB
簡介
haproxy為高效能的反向代理伺服器,在向後端server排程方面支援很多的排程演算法:roundrobin,source,uri,url_param,hdr(),leastconn等,且支援動態權重調整的一致性hash,在後端為cache server時很好的提高cache命中率;所以相比nginx反向代理,haproxy排程功能更為強大,另外haproxy提供自帶的gui介面,方便直接在web頁面管理前、後端伺服器,只需要在配置檔案中開啟即可。
nginx自身在處理web靜態頁面方面非常強大,其採用模組化設計,有較好的擴充套件性,但不支援模組動態裝解除安裝(Tengine支援模組動態裝解除安裝),nginx具有高可靠性,支援熱部署,低記憶體消耗等優點,其在設計之初就吸納了最新的技術,如支援事件驅動、非同步IO等,併發處理能力強大。
apache結合php處理動態頁面功能強大,php可直接以模組的形式載入到httpd,而nginx需要通過fastcgi協議與後端php通訊。所以結合各元件優點,我們這裡採用haproxy(支援https)+nginx(靜態)+lamp(動態)架構,最後通過keepalived實現對haproxy高可用。此外本實驗中對phpBB全站點使用https協議。
下圖為本次實驗架構圖:
圖1
圖2
架構圖說明
這裡有2幅架構圖,圖1中,後端各主機均在同一網段,這也是我們這次實驗所採用的架構;圖2中後端static server group和dynamic server group不在同一網段,二者之間需要路由器相連,Router的地址:eth0 --> 192.168.100.80 eth1 --> 192.168.200.80非但如此,採用圖2架構還需在haproxy和各後端server上新增靜態路由:
haproxy1: route add -net 192.168.200.0/24 gw 192.168.100.80 dev eth1
haproxy2: route add -net 192.168.100.0/24 gw 192.168.200.80 dev eth1
Nginx1: routeadd -net 192.168.200.0/24 gw 192.168.100.80 dev eth0
Nginx2: routeadd -net 192.168.200.0/24 gw 192.168.100.80 dev eth0
LAMP1: routeadd -net 192.168.100.0/24 gw 192.168.200.80 dev eth0
LAMP2: routeadd -net 192.168.100.0/24 gw 192.168.200.80 dev eth0
為簡便,這裡我們採用架構圖1。這裡我們用virtualbox準備6臺linux主機,各主機IP地址、Gateway及所需安裝軟體等如下表所配置,這裡我們將192.168.0.0/24網路模擬為公網,192.168.100.0/24為伺服器內網網段。前端為2臺haproxy組成的反向代理伺服器,並實現雙主高可用:所謂雙主,即haproxy1和haproxy2都正常工作,均同時為後端server提供反向代理和排程功能,使用者可通過DNS解析後的192.168.0.50和192.168.0.51兩個地址訪問我們的網站。客戶端請求的所有phpBB靜態頁面由前端的haproxy排程至後端的2臺nginx組成的伺服器組響應;使用者請求的所有phpBB動態頁面由前端的haproxy排程至後端的2臺lamp組成的伺服器組響應。
6臺linux主機上所需資源如下:
軟體安裝
按照上面的清單,分別在各主機上部署所需軟體,對於清單中HAProxy需要安裝ntpd伺服器的原因在於keepalived的執行需要後端server與前端伺服器時鐘保持同步,否則對後端server的健康狀態檢測會出現異常。
①、haproxy
haproxy在centos6.8上可以直接使用yum方式:
[[email protected] ~]# yum install -y haproxy
目前系統提供的預設版本是1.5.18,且支援openssl:
[[email protected] ~]# rpm -q haproxy ; ldd $(which haproxy)| grep ssl
haproxy-1.5.18-1.el6.x86_64
libssl.so.10 => /usr/lib64/libssl.so.10(0x00007f05e085c000)
如果是手動編譯安裝,則需要先在官網下載程式包,並新增對openssl的支援,下面是手動編譯步驟:
[[email protected] ~]# yum install -y openssl openssl-devel readline-devel pcre-devel libssl-dev libpcre3
[[email protected] ~]# wget http://www.haproxy.org/download/1.6/src/haproxy-1.6.13.tar.gz
[[email protected] ~]# tar xf haproxy-1.6.13.tar.gz ; cd haproxy-1.6.13
[[email protected] haproxy-1.6.13]# make TARGET=linux2628 USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_CRYPT_H=1 USE_LIBCRYPT=1
[[email protected] haproxy-1.6.13]# ldd $(which haproxy) | grep ssl
libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f05e085c000)
[[email protected] haproxy-1.6.13]# make install PREFIX=/usr/local/haproxy
[[email protected] haproxy-1.6.13]# vi /etc/profile.d/haproxy.sh
#!/bin/bash
export PATH=$PATH:/usr/local/haproxy/sbin/
[[email protected] haproxy-1.6.13]# source /etc/profile.d/haproxy.sh
建立配置檔案目錄及拷貝並修改啟動指令碼:
[[email protected] haproxy-1.6.13]# mkdir -p /etc/haproxy
[[email protected] haproxy-1.6.13]# cp examples/haproxy.init /etc/rc.d/init.d/haproxy
[[email protected] haproxy-1.6.13]# vi /etc/rc.d/init.d/haproxy
BIN=/usr/local/haproxy/sbin/$BASENAME
CFG=/etc/$BASENAME/$BASENAME.cfg
PIDFILE=/var/run/$BASENAME.pid
LOCKFILE=/var/lock/subsys/$BASENAME
至此haproxy已經安裝完畢,最後我們根據架構圖提供haproxy的配置檔案:
[[email protected] ~]# vi /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 40000
user haproxy
group haproxy
daemon
tune.ssl.default-dh-param 2048
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode http
log global
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend http_frontend
bind *:80
bind *:443 ssl crt /etc/haproxy/haproxy.pem # 網站證書檔案
mode http
log global
option httpclose
option logasap
option dontlognull
option forwardfor except 127.0.0.1 header X-Client if-none
capture request header Host len 20
capture request header Referer len 60
reqadd X-Forwarded-Proto:\ https
#rspadd Via:\ haproxy.example.com
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .jpeg .png .bmp .gif .css .js
redirect scheme https if !{ ssl_fc } # 全站採用https協議
use_backend static_servers if url_static
default_backend dynamic_servers
#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static_servers
mode http
balance roundrobin
#option httpchk HEAD /healthchk.html
server static1 192.168.100.64:80 check inter 1000 rise 2 fall 4 weight 1 maxconn 6000
server static2 192.168.100.65:80 check inter 1000 rise 2 fall 4 weight 1 maxconn 6000
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
backend dynamic_servers
mode http
balance roundrobin
#cookie dynamic_cookie insert nocache indirect
server https_dynamic1 192.168.200.70:80 check inter 2000 rise 2 fall 4 weight 1 maxconn 1000
server https_dynamic2 192.168.200.71:80 check inter 2000 rise 2 fall 4 weight 1 maxconn 1000
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
listen stats
bind *:9090
stats enable
stats uri /haproxy?stats
stats hide-version
stats auth admin:yourpassword
stats admin if TRUE
②、haproxy.cfg配置說明
haproxy的配置檔案位於:/etc/haproxy/haproxy.cfg,該配置檔案中的一個重點是新增對https協議的支援,為了實現該目的,需要做如下操作:
我們知道,haproxy代理ssl有三種方式:第一種,haproxy 自身提供ssl 證書,僅是客戶端與haproxy之間傳輸https協議,而haproxy與後端的web server仍然傳輸http;第二種為SSL透傳,haproxy 本身工作於tcp傳輸層,https由後端server直接處理,但haproxy不對https報文做任何修改,這就意味著後端server失去了對客戶端IP、埠及使用協議的記錄;第三種,SSL連線在負載均衡器處終止,按需求調整,然後作為新的SSL連線代理到後端伺服器。這可能會提供最大的安全性和傳送客戶端資訊的能力。這樣做的代價是更多的CPU能耗和稍複雜的配置。實驗中我們採用第一種,所以我們需要提供haproxy的ssl證書檔案:
因為是實驗,所以我們需要生成自簽署證書cacert.pem、應用程式haproxy證書haproxy.crt,應用程式haproxy私鑰haproxy.key等檔案,具體私鑰及證書生成步驟這裡不再詳述。最後將haproxy.crt和haproxy.key合併為一個檔案:
[[email protected] ~]# cd /etc/haproxy
[[email protected] haproxy]# cat haproxy.crt haproxy.key | tee haproxy.pem
而上面生成的haproxy.pem正是haproxy.cfg所需要的:
bind *:443 ssl crt /etc/haproxy/haproxy.pem
③、keepalived安裝與配置
我們需要在前端部署有haproxy的兩臺server上安裝keepalived,其安裝過程較為簡單,直接使用yum安裝即可:
[[email protected] ~]# yum install -y keepalived
[[email protected] ~]# rpm -q keepalived
keepalived-1.2.13-5.el6_6.x86_64
haproxy1上的keepalived配置:
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id www.example.com
}
vrrp_script chk_haproxy {
script "killall -0 haproxy &> /dev/null"
interval 1
weight -20
}
vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 256f6df6
}
virtual_ipaddress {
192.168.0.50/24 dev eth0 label eth0:0
}
track_script {
chk_haproxy
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
vrrp_instance VI_2 {
state BACKUP
interface eth0
virtual_router_id 52
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 19afa2c5
}
virtual_ipaddress {
192.168.0.51/24 dev eth0 label eth0:1
}
track_script {
chk_haproxy
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
haproxy2上的keepalived配置:
! Configuration File for keepalived
global_defs {
notification_email {
[email protected]
}
notification_email_from [email protected]
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id centos66.example.com
}
vrrp_script chk_haproxy {
script "killall -0 haproxy &> /dev/null"
interval 1
weight -20
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99
advert_int 1
authentication {
auth_type PASS
auth_pass 256f6df6
}
virtual_ipaddress {
192.168.0.50/24 dev eth0 label eth0:0
}
track_script {
chk_haproxy
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
vrrp_instance VI_2 {
state MASTER
interface eth0
virtual_router_id 52
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 19afa2c5
}
virtual_ipaddress {
192.168.0.51/24 dev eth0 label eth0:1
}
track_script {
chk_haproxy
}
notify_master "/etc/keepalived/notify.sh master"
notify_backup "/etc/keepalived/notify.sh backup"
notify_fault "/etc/keepalived/notify.sh fault"
}
訊息通知指令碼notify.sh:
#!/bin/bash
#Date:2017-10-07
vip=192.168.0.50
contact="[email protected]"
notify() {
mailsubject="`hostname` to be $1: $vip floating"
mailbody="`date +'%F %H:%M:%S'`: vrrp transition, `hostname` changed to be $1"
echo "$mailbody" | mail -s "$mailsubject" $contact
}
case "$1" in
master)
notify master
exit 0
;;
backup)
notify backup
exit 0
;;
fault)
notify fault
exit 0
;;
*)
echo "Usage: `basename $0` {master|backup|fault}"
exit 1
;;
esac
④、ntpd的安裝與配置
由於前端keepalived與後端各server通訊需要保證時鐘同步,所以我們需要在前端的其中一臺主機上安裝ntpd伺服器,注意本次實驗採用的是架構圖1,如果是架構圖2,那麼前端的2臺haproxy伺服器上均要部署ntpd。
[[email protected] ~]# yum install -y ntpd
[[email protected] ~]# vi /etc/ntpd.conf
# For more information about this file, see the man pages
# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
driftfile /var/lib/ntp/drift
# Permit time synchronization with our time source, but do not
# permit the source to query or modify the service on this system.
restrict default kod nomodify notrap nopeer noquery
restrict -6 default kod nomodify notrap nopeer noquery
restrict ntp1.aliyun.com
restrict ntp2.aliyun.com
restrict ntp3.aliyun.com
restrict ntp4.aliyun.com
restrict ntp5.aliyun.com
# Permit all access over the loopback interface. This could
# be tightened as well, but to do so would effect some of
# the administrative functions.
restrict 127.0.0.1
restrict -6 ::1
restrict 192.168.100.0 mask 255.255.255.0 nomodify
server ntp1.aliyun.com prefer
server ntp2.aliyun.com
server ntp3.aliyun.com
includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
安裝完成後啟動即可:service ntpd start ;chkconfig ntpd on
後端各server新增crontab任務計劃:
[[email protected] ~]# crontab -e
MAILTO=""
*/10 * * * * /usr/sbin/ntpdate 192.168.100.16 &> /dev/null
這樣設定完成後,後端的各server每10分鐘就會與前端的ntpd進行一次時鐘同步。
⑤、Static Server Group
靜態伺服器組的組成是由各linux主機上部署nginx來完成,在centos6.8上也可以直接使用yum來安裝:
[[email protected] ~]# yum install -y nginx
然後對後端各主機上的nginx配置檔案進行配置:
[[email protected] ~]# vi /etc/nginx/nginx.conf
# nginx.conf
user nginx;
worker_processes 1;
worker_rlimit_nofile 51200;
pid /var/run/nginx.pid;
events {
worker_connections 51200;
}
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 /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log notice;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root /var/www/html/phpBB;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
⑥、Dynamic Server Group
在後端各server上需要部署httpd+mariadb+php,在centos7上安裝過程比較簡單,直接使用yum安裝即可,這裡不再具體給出各軟體安裝步驟,我們需要在/etc/httpd/conf.d中新增虛擬主機:
[[email protected] ~]# cd /etc/httpd/conf.d/
[[email protected] conf.d]# vi vhosts.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html"
ServerName ftp.example.com
</VirtualHost>
<Directory "/var/www/html/phpBB">
Options Includes ExecCGI FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "/var/www/html/phpBB"
ServerName www.example.com:80
</VirtualHost>
另外需要將配置檔案:/etc/httpd/conf/httpd.conf中的"DocumentRoot"這一行註釋掉並修改日誌格式:
#DocumentRoot "/var/www/html"
LogFormat "%{X-Client}i %{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
#SetEnvIf Request_URI "^/test.html(/.*)?$" dontlog
#CustomLog "logs/access_log" combined env=!dontlog
⑦、部署phpBB
從phpBB官網下載安裝包,將安裝包分別拷貝至後端各server:Nginx1,Ngine2,LAMP1,LAMP2上的/var/www/html目錄下,解壓縮並修改所屬使用者和組,這裡以後端的LAMP1來演示,其它各server上的操作步驟與下面類似:
[[email protected] ~]# cp phpBB-3.2.0.tar.bz2 /var/www/html
[[email protected] ~]# cd /var/www/html
[[email protected] html]# tar xf phpBB-3.2.0.tar.bz2
[[email protected] html]# ls
phpBB3
[[email protected] html]# chown -R apache:apache phpBB3
[[email protected] html]# ln -s phpBB3 phpBB
[[email protected] html]# chown -R apache:apache phpBB
最後我們在LAMP1和LAMP2上建立資料庫
MariaDb[(none)] > create database phpBB;
MariaDb[(none)] > grant all privileges on phpBB.* to [email protected] '127.0.0.1' identified by 'yourpassword';
MariaDb[(none)] > flush privileges;
上面建立了phpBB資料庫名為:phpBB,資料庫使用者名稱:phpBB,密碼:yourpassword,這在後續的phpBB頁面安裝過程中需要。
至此各server配置已經完成,最後就需要我們在瀏覽器安裝phpBB了,在瀏覽器中輸入www.example.com進入安裝。
相關推薦
keepalived+haproxy(雙主)+nginx(靜態)+lamp(動態)部署phpBB
簡介 haproxy為高效能的反向代理伺服器,在向後端server排程方面支援很多的排程演算法:roundrobin,source,uri,url_param,hdr(),leastconn等,且支援動態權重調整的一致性hash,在後端為cache server時很
Nginx+keepalived高可用(雙主模式)
Nginx+keepalive 負載均衡 keepalive雙主模型配置 負載均衡技術對於一個網站尤其是大型網站的web服務器集群來說是至關重要的!做好負載均衡架構,可以實現故障轉移和高可用環境,避免單點故障,保證網站健康持續運行。由於業務擴展,網站的訪問量不斷加大,負載越來越高。現需要在web前
HAproxy+Keepalived(雙主)
local www. 貼圖 queue 應用 inpu udp端口 install rect HAproxy+Keepalived(雙主)配置 網絡拓撲如下 準備RealServer(RS服務器)配置 這裏RS上準備http服務作為應用驗證,在實際生產中兩臺RS
MySQL集群(四)之keepalived實現mysql雙主高可用
健康檢查 重連 lose 搶占 pro 資源 交換機 state nec 前面大家介紹了主從、主主復制以及他們的中間件mysql-proxy的使用,這一篇給大家介紹的是keepalived的搭建與使用! 一、keepalived簡介 1.1、keepalived介紹
keepalived 代理後端數據庫(雙主)基本配置註解
keepalived AA復制 高可用 keepalived 代理後端服務器基本配置1.環境後端兩臺服務器有雙主數據庫環境2.配置Keepalived主配置文件(/etc/keepalived/keepalived.conf) :keepalived 代理後端數據庫(雙主)基本配置註解
openldap主服務器配置文件(雙主)
lines character -i use roo captcha urn ckey however ## See slapd.conf(5) for details on configuration options.# This file should NOT be w
數據庫 之 Mysql的主主同步(雙主模型)
兩個 white serve 執行 密碼連接 進行 st3 提交 復制 1 概述互為主從:兩個節點各自都要開啟binlog和relay log; 1、數據不一致; 2、自動增長id;為了防止id沖突,解決辦法是一個服務器使用奇數id,另一個服務器使用偶數id,合並的時候一
使用Keepalived配置主從熱備實現Nginx高可用(HA)
_id keep 過去 基礎 inter icmp interval RR 轉發 Keepalived 簡要介紹 Keepalived 是一種高性能的服務器高可用或熱備解決方案,Keepalived 可以用來防止服務器單點故障的發生,通過配合 Nginx 可以實現 w
MySQL主主(雙主)數據同步
主主同步 雙主同步 mysql主主同步 mysql雙主同步 1. 兩臺mysql都可以讀寫,互為主備,默認只是用一臺(masterA)負責數據的寫入,另一臺(masterB)備用;2. masterA是masterB的主庫,masterB又是masterA的主庫,他們互為主從; 不足之處:1.
mysql--主從(雙主)簡單配置
1.主伺服器 172.16.20.228備份 mysqldump -uroot -p123 --all-databases > /bak/all.sql將全備拷貝到從機,並且從機恢復資料 scp [email protected]:/bak/all.mysql /bak/mysql //在從伺
nginx訪問靜態頁面(ajax再呼叫nginx地址訪問java後臺)
最近在跟著視訊做小示例,併發方面的,然後敲示例的過程中,發現nginx還可以這樣使用,在實際使用nginx有限的我,覺得還是應該記錄一下這種思想 首先,你先有html頁面,後臺生成的也好,還是前後端分離也好,我的頁面在如下目錄裡 然後配置ngin
MySQL 高可用:主主複製(雙主複製)
########################################################################################### linux: CentOS 5.6 mysql: 5.6.22
MySQL主主復制(雙主復制)配置過程介紹
uid creat 否則 sock 數據同步 nbsp ignore one oca 一、修改配置文件my.cnf服務器A(172.16.16.70)配置如下server_id = 70socket = /tmp/mysql.sockinnodb_buffer_pool_s
mysql之 mysql 5.6不停機主從搭建(一主一從基於GTID復制)
從庫 creat 不停機 event rep ply copy from end 環境說明:版本 version 5.6.25-log 主庫ip: 10.219.24.25從庫ip:10.219.24.22os 版本: centos 6.7已安裝熱備軟件:xtrabacku
【java項目實戰】代理模式(Proxy Pattern),靜態代理 VS 動態代理
自己 text 好的 trace use 代理 分類 plproxy this 這篇博文,我們主要以類圖和代碼的形式來對照學習一下靜態代理和動態代理。重點解析各自的優缺點。 定義 代理模式(Proxy Pattern)是對象的結構型模式,代理模
Linux—CentOS7.4-DNS二(搭建主、從域名同步服務器)
roc 查看 update try gre 服務器驗證 .com entos centos7.4 環境:兩臺Linux服務器主服務器IP地址:192.168.80.10從服務器IP地址:192.168.80.20 第一步:主服務器配置[root@localhost ~]#
keepalived高可用雙主配置文件
高可用###########################lb01cat /etc/keepalived/keepalived.conf! Configuration File for keepalived_lb01global_defs {# notification_email {# 9183916
BroadcastReceiver(廣播)的靜態註冊和動態註冊 --Android開發
encoding save private tac app tco sta content con BroadcastReceiver是安卓四大組件之一,本例通過代碼的方式演示靜態註冊和動態註冊。 1、靜態註冊 靜態註冊只需要AndroidManifest.xml中進行
實現雙主模型NGINX架構
leg ive cast conf kill alt entos echo 權重 實驗拓撲圖 主節點配置 yum -y install nginx keepalived psmisc #修改keepalived配置文件 vim /etc/keepalived/keep
VS2010-MFC(常用控件:靜態文本框)
-c sof 組框 round 處理 lpctstr 需要 gin message 轉自:http://www.jizhuomi.com/software/179.html 關於對話框的使用和各種通用對話框的介紹就到此為止,從本節開始將講解各種常用控件的用法。常用控