手把手教你搭建FastDFS集群(下)

版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。

由于博客图片量大,篇幅太长,因此需要分上、中、下三篇博客来写,上篇和中篇我们已经一起学习完了,这篇博客我们一起学习下剩余部分。

一、配置反向代理

我们需要在两个跟踪器上安装nginx(也就是192.168.156.5和192.168.156.6)以提供反向代理服务,目的是使用统一的一个IP地址对外提供服务。为了避免一些不必要的错误,我们先把其它四台虚拟机的窗口关掉。

1.解压ngx_cache_purge-2.3.tar.gz,解压命令:tar -zxvf ngx_cache_purge-2.3.tar.gz -C /usr/local/fast/,如下图所示(另一台设备就不粘贴图片了)。

解压完之后我们在/usr/local/fast/目录下可以看到多了一个ngx_cache_purge-2.3文件夹。如下图所示。

2.下载需要的依赖库,在两台设备上依次执行下面四条命令。

  1.  
    yum install pcre
  2.  
    yum install pcre-devel
  3.  
    yum install zlib
  4.  
    yum install zlib-devel

3.为两台设备都安装nginx,我们在XShell的下方的输入框中输入命令:cd /usr/local/software/并敲回车,两个窗口都会进入到/usr/local/software目录下,然后在下面的输入框再输入"ll"来查看/usr/local/software目录下的文件,如下图所示(只有输入框左边的图标是多窗口的情况下才能一次作用所有窗口,如果当前是单窗口图标,就如下图那样选择全部XShell)。

接着,我们在下面的输入框中输入:tar -zxvf nginx-1.6.2.tar.gz -C /usr/local/并按回车,会在两个窗口同时执行解压操作。如下图所示。

接下来我们在下面的输入框中输入:cd /usr/local并按回车,两台设备都进入到/usr/local/nginx-1.6.2目录下。如下图所示。

接着,在下面的输入框中加入模块命令:./configure --add-module=/usr/local/fast/ngx_cache_purge-2.3,回车就会在两台设备上都执行添加cache模块并会检查环境。

接着在下面的输入框中输入命令:make && make install,回车就会在两台设备上都执行编译安装。如下图所示。

下面我们需要修改下两台设备/usr/local/nginx/conf/目录下的nginx.conf文件,大家可以直接把下面代码替换这个目录下的该文件,也可以直接到:http://download.csdn.net/detail/u012453843/9803673这个地址下载nginx.conf文件来替换。不过由于我们搭建环境的虚拟机IP可能不一样,因此,我们需要根据实际情况修改下IP等信息。(注意192.168.156.5和192.168.156.6这两台设备的/usr/local/nginx/conf/目录下的nginx.conf都要修改)

  1.  
    #user nobody;
  2.  
    worker_processes 1;
  3.  
     
  4.  
    #error_log logs/error.log;
  5.  
    #error_log logs/error.log notice;
  6.  
    #error_log logs/error.log info;
  7.  
     
  8.  
    #pid logs/nginx.pid;
  9.  
     
  10.  
     
  11.  
    events {
  12.  
    worker_connections 1024;
  13.  
    use epoll;
  14.  
    }
  15.  
     
  16.  
     
  17.  
    http {
  18.  
    include mime.types;
  19.  
    default_type application/octet-stream;
  20.  
     
  21.  
    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  22.  
    # '$status $body_bytes_sent "$http_referer" '
  23.  
    # '"$http_user_agent" "$http_x_forwarded_for"';
  24.  
     
  25.  
    #access_log logs/access.log main;
  26.  
     
  27.  
    sendfile on;
  28.  
    tcp_nopush on;
  29.  
    #tcp_nopush on;
  30.  
     
  31.  
    #keepalive_timeout 0;
  32.  
    keepalive_timeout 65;
  33.  
     
  34.  
    #gzip on;
  35.  
    #设置缓存
  36.  
    server_names_hash_bucket_size 128;
  37.  
    client_header_buffer_size 32k;
  38.  
    large_client_header_buffers 4 32k;
  39.  
    client_max_body_size 300m;
  40.  
     
  41.  
    proxy_redirect off;
  42.  
    proxy_set_header Host $http_host;
  43.  
    proxy_set_header X-Real-IP $remote_addr;
  44.  
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  45.  
    proxy_connect_timeout 90;
  46.  
    proxy_send_timeout 90;
  47.  
    proxy_read_timeout 90;
  48.  
    proxy_buffer_size 16k;
  49.  
    proxy_buffers 4 64k;
  50.  
    proxy_busy_buffers_size 128k;
  51.  
    proxy_temp_file_write_size 128k;
  52.  
    #设置缓存存储路径,存储方式,分别内存大小,磁盘最大空间,缓存期限
  53.  
    proxy_cache_path /fastdfs/cache/nginx/proxy_cache levels=1:2
  54.  
    keys_zone=http-cache:200m max_size=1g inactive=30d;
  55.  
    proxy_temp_path /fastdfs/cache/nginx/proxy_cache/tmp;
  56.  
    #group1的服务设置
  57.  
    upstream fdfs_group1 {
  58.  
    server 192.168.156.7:8888 weight=1 max_fails=2 fail_timeout=30s;
  59.  
    server 192.168.156.8:8888 weight=1 max_fails=2 fail_timeout=30s;
  60.  
    }
  61.  
    #group2的服务设置
  62.  
    upstream fdfs_group2 {
  63.  
    server 192.168.156.9:8888 weight=1 max_fails=2 fail_timeout=30s;
  64.  
    server 192.168.156.10:8888 weight=1 max_fails=2 fail_timeout=30s;
  65.  
    }
  66.  
     
  67.  
    server {
  68.  
    listen 8000;
  69.  
    server_name localhost;
  70.  
     
  71.  
    #charset koi8-r;
  72.  
     
  73.  
    #access_log logs/host.access.log main;
  74.  
    #group1的负载均衡配置
  75.  
    location /group1/M00 {
  76.  
    proxy_next_upstream http_502 http_504 error timeout invalid_header;
  77.  
    proxy_cache http-cache;
  78.  
    proxy_cache_valid 200 304 12h;
  79.  
    proxy_cache_key $uri$is_args$args;
  80.  
    #对应group1的服务设置
  81.  
    proxy_pass http://fdfs_group1;
  82.  
    expires 30d;
  83.  
    }
  84.  
     
  85.  
    location /group2/M00 {
  86.  
    proxy_next_upstream http_502 http_504 error timeout invalid_header;
  87.  
    proxy_cache http-cache;
  88.  
    proxy_cache_valid 200 304 12h;
  89.  
    proxy_cache_key $uri$is_args$args;
  90.  
    #对应group2的服务设置
  91.  
    proxy_pass http://fdfs_group2;
  92.  
    expires 30d;
  93.  
    }
  94.  
     
  95.  
    location ~/purge(/.*) {
  96.  
    allow 127.0.0.1;
  97.  
    allow 192.168.156.0/24;
  98.  
    deny all;
  99.  
    proxy_cache_purge http-cache $1$is_args$args;
  100.  
    }
  101.  
     
  102.  
    location / {
  103.  
    root html;
  104.  
    index index.html index.htm;
  105.  
    }
  106.  
     
  107.  
    #error_page 404 /404.html;
  108.  
     
  109.  
    # redirect server error pages to the static page /50x.html
  110.  
    #
  111.  
    error_page 500 502 503 504 /50x.html;
  112.  
    location = /50x.html {
  113.  
    root html;
  114.  
    }
  115.  
     
  116.  
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  117.  
    #
  118.  
    #location ~ \.php$ {
  119.  
    # proxy_pass http://127.0.0.1;
  120.  
    #}
  121.  
     
  122.  
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  123.  
    #
  124.  
    #location ~ \.php$ {
  125.  
    # root html;
  126.  
    # fastcgi_pass 127.0.0.1:9000;
  127.  
    # fastcgi_index index.php;
  128.  
    # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  129.  
    # include fastcgi_params;
  130.  
    #}
  131.  
     
  132.  
    # deny access to .htaccess files, if Apache's document root
  133.  
    # concurs with nginx's one
  134.  
    #
  135.  
    #location ~ /\.ht {
  136.  
    # deny all;
  137.  
    #}
  138.  
    }
  139.  
     
  140.  
     
  141.  
    # another virtual host using mix of IP-, name-, and port-based configuration
  142.  
    #
  143.  
    #server {
  144.  
    # listen 8000;
  145.  
    # listen somename:8080;
  146.  
    # server_name somename alias another.alias;
  147.  
     
  148.  
    # location / {
  149.  
    # root html;
  150.  
    # index index.html index.htm;
  151.  
    # }
  152.  
    #}
  153.  
     
  154.  
     
  155.  
    # HTTPS server
  156.  
    #
  157.  
    #server {
  158.  
    # listen 443 ssl;
  159.  
    # server_name localhost;
  160.  
     
  161.  
    # ssl_certificate cert.pem;
  162.  
    # ssl_certificate_key cert.key;
  163.  
     
  164.  
    # ssl_session_cache shared:SSL:1m;
  165.  
    # ssl_session_timeout 5m;
  166.  
     
  167.  
    # ssl_ciphers HIGH:!aNULL:!MD5;
  168.  
    # ssl_prefer_server_ciphers on;
  169.  
     
  170.  
    # location / {
  171.  
    # root html;
  172.  
    # index index.html index.htm;
  173.  
    # }
  174.  
    #}
  175.  
     
  176.  
    }

修改完nginx.conf文件之后,我们下面需要创建/fastdfs/cache/nginx/proxy_cache和/fastdfs/cache/nginx/proxy_cache/tmp目录,这是因为我们在nginx.conf文件中配置缓存路径时指定了该目录,但是这两个目录目前还不存在,因此我们需要在192.168.156.5和192.168.156.6这两台设备上都创建下这两个目录,由于涉及到多级,因此需要递归创建目录,使用命令:mkdir -p /fastdfs/cache/nginx/proxy_cache和mkdir -p /fastdfs/cache/nginx/proxy_cache/tmp,如下图所示。

由于我们配置了两个tracker的访问端口是8000,而我们的防火墙是不允许访问该端口的,因此我们需要修改下防火墙,使其允许访问8000端口,这个操作我在上篇和中篇都介绍过了,这里就不啰嗦了。

下面我们便来启动这两台设备上的nginx。启动所使用的命令是/usr/local/nginx/sbin/nginx。启动完之后,可以使用ps -ef | grep nginx命令来查看nginx是否正常启动,如果看到root       4027      1  0 08:18 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx这条信息,说明正常启动了。

  1.  
    [root@itcast05 conf]# /usr/local/nginx/sbin/nginx
  2.  
    [root@itcast05 conf]# ps -ef | grep nginx
  3.  
    root 4027 1 0 08:18 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
  4.  
    nobody 4028 4027 0 08:18 ? 00:00:00 nginx: worker process
  5.  
    nobody 4029 4027 0 08:18 ? 00:00:00 nginx: cache manager process
  6.  
    nobody 4030 4027 0 08:18 ? 00:00:00 nginx: cache loader process
  7.  
    root 4032 1522 0 08:18 pts/0 00:00:00 grep nginx

两台设备都启动完nginx之后,我们再在192.168.156.5上上传两次次图片,第一次返回的路径是在group1下,第二次返回的路径是在group2下。

  1.  
    [root@itcast05 conf]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/3.jpg
  2.  
    group1/M00/00/00/wKicCFjkOVGAMlQvAAHk-VzqZ6w757.jpg
  3.  
    [root@itcast05 conf]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/3.jpg
  4.  
    group2/M00/00/00/wKicCVjkOeaAVb0dAAHk-VzqZ6w123.jpg
  5.  
    [root@itcast05 conf]#

由于我们在192.168.156.5和192.168.156.6上配置了代理,代理端口是8000,所以我们可以访问这两个IP的8000端口来访问我们刚才上传的图片,如下图所示(我们访问http://192.168.156.5:8000/group1/M00/00/00/wKicCFjkOVGAMlQvAAHk-VzqZ6w757.jpg也能访问到该图片)。这说明我们配置的代理完全没问题。

我们知道,nginx对外提供服务有可能碰到服务挂掉的时候,这时候高可用就显得异常重要了,因此现在我们搭建一个nginx和keepalived结合实现的nginx集群高可用的环境,大家可以参考http://blog.csdn.net/u012453843/article/details/69668663这篇博客进行学习。

我们现在要把keepalived实现的nginx集群高可用应用到我们的FastDFS集群当中,现在用于搭建nginx集群高可用的设备是192.168.156.11和192.168.156.12,我们只需要修改下这两台设备的nginx.conf文件,配置文件如下

  1.  
    #user nobody;
  2.  
    worker_processes 1;
  3.  
     
  4.  
    #error_log logs/error.log;
  5.  
    #error_log logs/error.log notice;
  6.  
    #error_log logs/error.log info;
  7.  
     
  8.  
    #pid logs/nginx.pid;
  9.  
     
  10.  
     
  11.  
    events {
  12.  
    worker_connections 1024;
  13.  
    }
  14.  
     
  15.  
     
  16.  
    http {
  17.  
    include mime.types;
  18.  
    default_type application/octet-stream;
  19.  
     
  20.  
    #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  21.  
    # '$status $body_bytes_sent "$http_referer" '
  22.  
    # '"$http_user_agent" "$http_x_forwarded_for"';
  23.  
     
  24.  
    #access_log logs/access.log main;
  25.  
     
  26.  
    sendfile on;
  27.  
    #tcp_nopush on;
  28.  
     
  29.  
    #keepalive_timeout 0;
  30.  
    keepalive_timeout 65;
  31.  
     
  32.  
    #gzip on;
  33.  
     
  34.  
    upstream fastdfs_tracker {
  35.  
    server 192.168.156.5:8000 weight=1 max_fails=2 fail_timeout=30s;
  36.  
    server 192.168.156.6:8000 weight=1 max_fails=2 fail_timeout=30s;
  37.  
    }
  38.  
     
  39.  
    server {
  40.  
    listen 80;
  41.  
    server_name localhost;
  42.  
     
  43.  
    #charset koi8-r;
  44.  
     
  45.  
    #access_log logs/host.access.log main;
  46.  
     
  47.  
    location /fastdfs {
  48.  
    root html;
  49.  
    index index.html index.htm;
  50.  
    proxy_pass http://fastdfs_tracker/;
  51.  
    proxy_set_header Host $http_host;
  52.  
    proxy_set_header Cookie $http_cookie;
  53.  
    proxy_set_header X-Real-IP $remote_addr;
  54.  
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  55.  
    proxy_set_header X-Forwarded-Proto $scheme;
  56.  
    client_max_body_size 300m;
  57.  
    }
  58.  
     
  59.  
    #error_page 404 /404.html;
  60.  
     
  61.  
    # redirect server error pages to the static page /50x.html
  62.  
    #
  63.  
    error_page 500 502 503 504 /50x.html;
  64.  
    location = /50x.html {
  65.  
    root html;
  66.  
    }
  67.  
    }
  68.  
    }

我们对配置文件做了两处修改,一处是添加了负载均衡upstream fastdfs_tracker,如下所示。我们是把192.168.156.5和192.168.156.6两台设备作为tracker,现在我们加了一层nginx来代理这两个tracker。

  1.  
    upstream fastdfs_tracker {
  2.  
    server 192.168.156.5:8000 weight=1 max_fails=2 fail_timeout=30s;
  3.  
    server 192.168.156.6:8000 weight=1 max_fails=2 fail_timeout=30s;
  4.  
    }

第二处修改是添加了一个location并且匹配规则是路径当中有fastdfs。如下所示。

  1.  
    location /fastdfs {
  2.  
    root html;
  3.  
    index index.html index.htm;
  4.  
    proxy_pass http://fastdfs_tracker/;
  5.  
    proxy_set_header Host $http_host;
  6.  
    proxy_set_header Cookie $http_cookie;
  7.  
    proxy_set_header X-Real-IP $remote_addr;
  8.  
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  9.  
    proxy_set_header X-Forwarded-Proto $scheme;
  10.  
    client_max_body_size 300m;
  11.  
    }

做好了修改之后,我们只需重新启动192.168.156.11和192.168.156.12这两台设备的nginx即可。

  1.  
    [root@nginx1 conf]# /usr/local/nginx/sbin/nginx -s reload
  2.  
    [root@nginx1 conf]#
  1.  
    [root@nginx2 conf]# /usr/local/nginx/sbin/nginx -s reload
  2.  
    [root@nginx2 conf]#

这样我们便配置好了虚拟IP,现在我们从192.168.156.5再上传一张图片,如下所示。

  1.  
    [root@itcast05 conf]# /usr/bin/fdfs_upload_file /etc/fdfs/client.conf /usr/local/3.jpg
  2.  
    group1/M00/00/00/wKicB1jqnPqARiT6AAHk-VzqZ6w956.jpg
  3.  
    [root@itcast05 conf]#

我们现在就用虚拟IP192.168.156.110来访问我们刚才上传的图片,只是注意在地址栏中要记得输入fastdfs(这是我们nginx.conf文件中location /fastdfs{}规则规定的)。如下图所示,发现,我们通过虚拟IP便可以访问我们上传的图片了。这样的好处是,对用户来说,只需要访问这个虚拟IP就可以了,不用关心FastDFS集群内部的转发机制。

这样我们的FastDFS集群便搭建完了,搭建完后的集群图如下图所示。这个集群当中192.168.156.7、192.168.156.8、192.168.156.9、192.168.156.10这四台设备以8888端口对外提供服务,我们使用Tracker跟踪器管理这四台storage设备,两个Tracker的nginx对外提供的端口号是8000,也就是我们可以使用两台Tracker的任何一台设备的IP并且使用端口8000来访问存储在storage上的资源文件。其实我们完全可以在两台Tracker设备上搭建keepalived和nginx相结合的高可用环境并且对外提供虚拟IP192.168.156.110和端口80来访问资源文件。只不过这里为了展示多层nginx负载均衡所以才在192.168.156.11和192.168.156.12上专门搭建了keepalived和nginx相结合的高可用环境,由这两台设备对外提供虚拟IP服务,由于端口使用了默认的80,因此我们在使用虚拟IP192.168.156.110访问图片的时候才不用输入端口号的。

备注:启动集群步骤

1.启动6台设备(192.168.156.5、192.168.156.6、192.168.156.7、192.168.156.8、192.168.156.9、192.168.156.10)的nginx(其中192.168.156.11和192.168.156.12配置了keepalived开机自启动,顺带会启动nginx,因此这两台设备不用启动nginx)

2.启动tracker(192.168.156.5和192.168.156.6,启动命令:/etc/init.d/fdfs_trackerd start)

3.启动storage(192.168.156.7、192.168.156.8、192.168.156.9、192.168.156.10,启动命令:/etc/init.d/fdfs_storaged start)

这样FastDFS集群便都启动完了。

手把手教你搭建FastDFS集群(下)的更多相关文章

  1. 手把手教你搭建FastDFS集群(中)

    手把手教你搭建FastDFS集群(中) 版权声明:本文为博主原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/u0 ...

  2. 手把手教你搭建FastDFS集群(上)

    手把手教你搭建FastDFS集群(上) 本文链接:https://blog.csdn.net/u012453843/article/details/68957209        FastDFS是一个 ...

  3. 搭建FastDFS集群

    先插一张图(学习的时候找的)http://blog.csdn.net/u012453843/article/details/68957209?> 软件下载地址:主要是fastdfs.libfas ...

  4. 手把手教你在 TKE 集群中实现简单的蓝绿发布和灰度发布

    概述 如何在腾讯云 Kubernetes 集群实现蓝绿发布和灰度发布?通常要向集群额外部署其它开源工具来实现,比如 Nginx Ingress,Traefik 等,或者让业务上 Service Mes ...

  5. 手把手教你Linux服务器集群部署.net网站 - Linux系统安装和设置

    在开源软件已成趋势化的今天,微软这‘老古董’也开始向开源方向发力,这对我们.NET开发者是极大的喜讯.而在开源软件中, Linux就是其中一个优秀的代表,几乎各行业和计算机有关的都有它的身影,其中一点 ...

  6. 手把手教你Linux服务器集群部署.net网站 - 让MVC网站运行起来

    一.Linux下面安装需要软件 我们这里需要安装的软件有: 1) Mono 3.2.8 : C#跨平台编译器,能使.Net运行与Linux下,目前.net 4.0可以完美运行在该平台下 2) ngin ...

  7. FastDFS 集群 安装 配置

    这篇文章介绍如何搭建FastDFS 集群 FastDFS是一个开源的轻量级分布式文件系统,它对文件进行管理,功能包括:文件存储.文件同步.文件访问(文件上传.文件下载)等,解决了大容量存储和负载均衡的 ...

  8. Fastdfs集群部署以及基本操作

    FastDFS引言 本地存储与分布式文件系统 本地存储的缺点: 是否有备份? 没有 成本角度? 贵 ​ 服务器 :用于计算 ---- cpu/内存 ​ 用于存储 ---- 硬盘大 存储瓶颈? 容量有限 ...

  9. Linux安装fastdfs集群部署

    过程问题: make: gcc:命令未找到 解决: yum -y install gcc 一.环境和版本: Linux环境:CentOS 7.6 libfastcommon版本:1.0.39 Fast ...

随机推荐

  1. 空指针/0/NULL

    空指针/0/NULL 空指针是一个被赋值为0的指针,在没有被具体初始化之前,其值为0. NULL 是一个标准规定的宏定义,用来表示空指针常量. #define NULL 0   或者 #define ...

  2. 实时更新Excel文档外部数据源的数据

    实时更新Excel文档外部数据源的数据 单元格区域.Excel 表.数据透视表或数据透视图均可以连接到外部数据源(数据源:用于连接数据库的一组存储的"源"信息.数据源包含数据库服务 ...

  3. 【学习笔记】XPath定位总结

    XPath即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某部分位置的语言. 原理:基于html的文档目录结构进行定位元素. 以html代码为例讲解各种定位方法: ...

  4. LeetCode.1185-一周中的星期几(Day of the Week)

    这是小川的第415次更新,第448篇原创 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第266题(顺位题号是1185).给定日期,返回该日期的星期几.输入为三个整数,分别代表日,月和 ...

  5. VMware 虚拟机安装Mac OS X 10.10

    有图有真相,哈哈 一.下载以上文件 1. vm百度软件下载即可,版本都能满足需要,随意好了 2. unlocker 207 3. Mac OS X 10.10镜像 二.基本步骤 1. 虚拟机的安装 下 ...

  6. django中的Form和ModelForm中的问题

    django的Form组件中,如果字段中包含choices参数,请使用两种方式实现数据源实时更新 方法一:重写构造方法,在构造方法中重新去获取值 class UserForm(forms.Form): ...

  7. RestTemplateBuilder类

    Spring Boot使用RestTemplate消费REST服务的几个问题记录 我们可以通过Spring Boot快速开发REST接口,同时也可能需要在实现接口的过程中,通过Spring Boot调 ...

  8. poj2299(归并排序求逆序对)

    题目链接:https://vjudge.net/problem/POJ-2299 题意:给定一个序列,每次只能交换邻近的两个元素,问要交换多少次才能使序列按升序排列. 思路:本质就是求逆序对.我们用归 ...

  9. 2019牛客暑期多校训练营(第九场)-D Knapsack Cryptosystem (折半搜索)

    题目链接:https://ac.nowcoder.com/acm/contest/889/D 题意:题意简单,从大小为36的集合中选若干元素使得他们的和为sum. 思路:第一感觉用搜索,复杂度为2^3 ...

  10. 第一章 Scala基础篇

    目录 一.Scala基础语法 (一) 变量.类型.操作符 1.变量申明 2.字符串 3.数据类型 4.操作符 (二)循环判断 1.块表达式 2.条件表达式 3.循环表达式 (三)方法和函数 1.方法 ...