目录

  • 架构图
  • 部署详情
  • postgresql的安装与配置
  • pgpool的安装与配置

写在安装前

postgresql是一款很强大的数据库,具体有多强大呢,请谷歌。。。
网上的相关资料不是很多,参考了大神们的文档,结合自己趟了的坑,写了pg集群的安装文档。可能有一些参数没有配置好,希望大神们指出,谢谢。参照本文档,基本能实现pg的高可用,稍后会写出测试文档。

架构图

 
 

部署详情

ip host 系统 vip 部署
192.168.123.180 master CentOS 6.8 192.168.123.183 postgresql、pgpool
192.168.123.181 slave1 CentOS 6.8 192.168.123.183 postgresql、pgpool
192.168.123.182 slave2 CentOS 6.8 192.168.123.183 postgresql

postgresql的安装

1、安装

1、Rpm包下载地址:
https://yum.postgresql.org/rpmchart.php
下载下面的包:
postgresql95-libs-9.5.8-1PGDG.rhel6.x86_64.rpm
postgresql95-contrib-9.5.8-1PGDG.rhel6.x86_64.rpm
postgresql95-9.5.8-1PGDG.rhel6.x86_64.rpm
postgresql95-server-9.5.8-1PGDG.rhel6.x86_64.rpm

2、安装:

yum install -y postgresql95-libs-9.5.8-1PGDG.rhel6.x86_64.rpm
yum install -y postgresql95-contrib-9.5.8-1PGDG.rhel6.x86_64.rpm
yum install -y postgresql95-9.5.8-1PGDG.rhel6.x86_64.rpm
yum install -y postgresql95-server-9.5.8-1PGDG.rhel6.x86_64.rpm

3、初始化db:
service postgresql-9.5 initdb
4、设置为开机启动:
chkconfig postgresql-9.5 on
5、安装的目录:
/var/lib/pgsql/9.5

配置白名单与流复制

1、 master的配置

PostgreSQL流复制默认是异步的。在主服务器上提交事务和从服务器上变化可见之间有一个小的延迟,这个延迟远小于基于文件日志传送,通常1秒能完成。如果主服务器突然崩溃,可能会有少量数据丢失。
同步复制必须等主服务器和从服务器都写完WAL后才能提交事务。这样在一定程度上会增加事务的响应时间。
配置同步复制仅需要一个额外的配置步骤: synchronous_standby_names必须设置为一个非空值。synchronous_commit也必须设置为on。
这里部署的是异步的流复制

1.2、配置白名单:
vim /var/lib/pgsql/9.5/data/pg_hba.conf
在配置文件最后加上:


host all all 192.168.123.180/32 trust
host all all 192.168.123.181/32 trust
host all all 192.168.123.182/32 trust
host replication replica 192.168.123.181/32 trust
host replication replica 192.168.123.182/32 trust

保存退出
我这里由于是内网,全部用的trust,如果要用密码,请修改为passwd

1.3、修改配置文件:
vim /var/lib/pgsql/9.5/data/postgresql.conf

data_directory = '/app/pgsql/data'                            #自定义data目录
listen_addresses = '*' #监听所有ip
archive_mode = on #允许归档
archive_command = 'cp %p /app/pgsql/pg_archive/%f' #使用命令归档
wal_level = hot_standby #选择热备
max_wal_senders = 16 #最多多少个流复制链接
wal_keep_segments = 256 #流复制保留最多的xlog数
wal_sender_timeout = 60s #流复制主机发送数据超时时间
max_connections = 99 #从库的max_connections必须大于主库的

1.4、创建data目录,赋权并修改启动文件

mkdir -p /app/pgsql/data && chown postgres:postgres /app/pgsql/data
mkdir -p /app/pgsql/pg_archive && chown postgres:postgres /app/pgsql/pg_archive cd /app/pgsql && chmod 700 data
cd /app/pgsql && chmod 700 pg_archive

1.5、修改启动文件

vim /etc/init.d/postgresql-9.5

PGDATA=/app/pgsql/data

1.6、把原data目录下的文件copy到新的data的目录下,并改变属组:

cp -r /var/lib/pgsql/9.5/data/* /app/pgsql/data/
cd /app/pgsql && chown -R postgres:postgres data

1.7、启动
service postgresql-9.5 start
以后修改配置文件就在/app/pgsql/data下面修改

1.8、创建一个数据库用户进行主从同步。创建用户replica,并赋予登录和复制的权限
登陆到数据库里:

su postgres
psql
CREATE ROLE replica login replication encrypted password 'replica';
 
 

防火墙开放5432端口
在从库上:
psql -h 192.168.123.180 -U postgres

 
 

登陆主库成功

2、从库的配置
2.1、自定义data目录:

mkdir -p /app/pgsql/data/&&chmod 700 /app/pgsql/data/
chown -R postgres:postgres pgsql mkdir /app/pgsql/pg_archive
cd /app/pgsql
chmod 700 pg_archive && chown postgres:postgres pg_archive/

2.2、切换用户:
su – postgres
2.3、备份数据:
pg_basebackup -h 192.168.123.180 -U replica -D /app/pgsql/data -X stream –P
2.4、修改启动文件:

vim /etc/init.d/postgresql-9.5

PGDATA=/app/pgsql/data

2.5、配置recovery.conf

su postgres
cp /usr/pgsql-9.5/share/recovery.conf.sample /app/pgsql/data/recovery.conf

vim /app/pgsql/data/recovery.conf

standby_mode = on        \#该节点为从
primary_conninfo = 'host=192.168.123.180 port=5432 user=replica password=replica'
\#主服务器的ip、user
recovery_target_timeline = 'latest'
trigger_file = '/tmp/trigger_file0'

2.6、配置postgresql.conf
vim /app/pgsql/data/postgresql.conf

max_connections = 999     #大于主的连接数
max_standby_streaming_delay = 30s
wal_receiver_status_interval = 10s
hot_standby_feedback = on

2.7、重启服务:
service postgresql-9.5 restart

验证流复制

3.1、在master上登陆psql
查看状态:
select client_addr,sync_state from pg_stat_replication;

 
 

3.2、创建test库
Create database test;

3.3、slave上登陆psql
查看库
playboy => \l

 
 

发现已同步。

pgpool的安装

pgpool-II是PostgreSQL服务器之间一种有效的中间件和PostgreSQL数据库客户端。它提供了以下功能。
连接池
pgpool-II保存到PostgreSQL服务器的连接,当一个相同新连接(如用户名、数据库、协议版本)进来时,重用他们。它减少了连接开销,提高了系统的整体吞吐量。
复制
pgpool-II可以管理多个PostgreSQL服务器。使用复制功能可以使2个或更多的物理磁盘上创建一个实时备份,这样服务不会因服务器的磁盘故障而中断。
负载平衡
如果数据库是复制的,在任何服务器上执行一个SELECT查询会返回相同的结果。pgpool-II复制特性的优势在于减少每个PostgreSQL服务器上的负载,因为它可以使用分布在多个服务器之间进行SELECT查询,从而提高系统的整体吞吐量。最好是查询和PostgreSQL服务器数量成一定比例,多用户同时执行多查询达到负载均衡最好的效果。
限制连接数
PostgreSQL的最大并发连接数有一定限制的,当超过限制的连接数后,连接会被拒绝。然而,设置增加最大连接数又会增加资源消耗,影响系统性能。pgpool-II也有最大连接数限制,但超过的连接进来时是进行立即排队,而不是返回一个错误。
pgpool-II交互PostgreSQL的后端和前端协议时,起着继电器的作用。因此,数据库应用程序(前端)认为pgpool-II是真实的PostgreSQL服务器,服务器(后端)认为pgpool-II是它的客户端之一。因为pgpool-II在服务器和客户端是透明的,所以pgpool-II可以使用现有的数据库应用程序而做到几乎不修改它们。

版本:3.6
机器:192.168.123.180
192.168.123.181
4.1、免密码登陆
安装之前先配置密钥使master和slave1这两台虚拟机的postgres用户能免密连接

先修改postgres的密码,在root用户下
passwd postgres
新密码123456

Master到slave1的免密码登陆:
在master上切换至postgres用户,生成密钥
su postgres ssh-keygen -t rsa
然后全输入回车

切换到postgres用户:
su postgres ssh-copy-id -i /var/lib/pgsql/.ssh/id_rsa 192.168.123.181
然后ssh 192.168.123.181 成功,实现master到slave1的免密码登陆

Slave1到master的免密码登陆:
流程同上
4.2、安装
Rpm包下载地址:
http://www.pgpool.net/yum/rpms/3.6/redhat/rhel-6-x86_64/pgpool-II-pg95-3.6.0-1pgdg.rhel6.x86_64.rpm

安装:
yum install pgpool-II-pg95-3.6.0-1pgdg.rhel6.x86_64.rpm

4.3、配置
Master的配置:

配置白名单:
要和pg_hba.conf登陆权限一致,这里由于是私有云,都用trust
vim /etc/pgpool-II/pool_hba.conf
在最后改成:

 
 

配置pcp管理工具密码:
pg_md5 pwd
密码加密

 
 

vim /etc/pgpool-II/pcp.conf
把刚才加密的密码粘贴到文件里

 
 

配置系统命令权限:
Root用户下:
chmod u+s /sbin/ifconfig &&chmod u+s /usr/sbin

配置中间件配置文件:
vim /etc/pgpool-II/pgpool.conf

# CONNECTIONS
listen_addresses = '*'
port = 9999
pcp_listen_addresses = '*'
pcp_port = 9898 # - Backend Connection Settings - backend_hostname0 = 'master'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = ' /app/pgsql/data'
backend_flag0 = 'ALLOW_TO_FAILOVER' backend_hostname1 = 'slave'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = ' /app/pgsql/data''
backend_flag1 = 'ALLOW_TO_FAILOVER' # - Authentication -
enable_pool_hba = off
pool_passwd = 'pool_passwd' # FILE LOCATIONS
pid_file_name = '/opt/pgpool/pgpool.pid' replication_mode = off
load_balance_mode = on
master_slave_mode = on
master_slave_sub_mode = 'stream' sr_check_period = 5
sr_check_user = 'repuser'
sr_check_password = 'repuser'
sr_check_database = 'postgres' #------------------------------------------------------------------------------
# HEALTH CHECK 健康检查
#------------------------------------------------------------------------------ health_check_period = 10 # Health check period
# Disabled (0) by default
health_check_timeout = 20
# Health check timeout
# 0 means no timeout
health_check_user = ' repuser '
# Health check user
health_check_password = ' repuser ' #数据库密码
# Password for health check user
health_check_database = 'postgres'
#必须设置,否则primary数据库down了,pgpool不知道,不能及时切换。从库流复制还在连接数据,报连接失败。
#只有下次使用pgpool登录时,发现连接不上,然后报错,这时候,才知道挂了,pgpool进行切换。 #主备切换的命令行配置
#------------------------------------------------------------------------------
# FAILOVER AND FAILBACK
#------------------------------------------------------------------------------ failover_command = ' /opt/pgpool/failover_stream.sh %d %H /tmp/trigger_file0 ' #------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------ # - Enabling -
use_watchdog = on
# - Watchdog communication Settings - wd_hostname = 'master'
# Host name or IP address of this watchdog
# (change requires restart)
wd_port = 9000
# port number for watchdog service
# (change requires restart)
# - Virtual IP control Setting - delegate_IP = ' 192.168.123.183 '
# delegate IP address
# If this is empty, virtual IP never bring up.
# (change requires restart)
if_cmd_path = '/sbin'
# path to the directory where if_up/down_cmd
# (change requires restart)
if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0'
# startup delegate IP command
# (change requires restart)
if_down_cmd = 'ifconfig eth0:0 down'
# shutdown delegate IP command
# (change requires restart)
# -- heartbeat mode -- wd_heartbeat_port = 9694
# Port number for receiving heartbeat signal
# (change requires restart)
wd_heartbeat_keepalive = 2
# Interval time of sending heartbeat signal (sec)
# (change requires restart)
wd_heartbeat_deadtime = 30
# Deadtime interval for heartbeat signal (sec)
# (change requires restart)
heartbeat_destination0 = 'slave1'
# Host name or IP address of destination 0
# for sending heartbeat signal.
# (change requires restart)
heartbeat_destination_port0 = 9694
# Port number of destination 0 for sending
# heartbeat signal. Usually this is the
# same as wd_heartbeat_port.
# (change requires restart)
heartbeat_device0 = 'eth0'
# Name of NIC device (such like 'eth0')
# used for sending/receiving heartbeat
# signal to/from destination 0.
# This works only when this is not empty
# and pgpool has root privilege.
# (change requires restart)
# - Other pgpool Connection Settings - other_pgpool_hostname0 = 'slave' #对端
# Host name or IP address to connect to for
# (change requires restart)
other_pgpool_port0 = 9999
# Port number for othet pgpool 0
# (change requires restart)
other_wd_port0 = 9000
# Port number for othet watchdog 0
# (change requires restart)

4.4、Slave1的配置:

配置白名单:
要和pg_hba.conf登陆权限一致,这里由于是私有云,都用trust
vim /etc/pgpool-II/pool_hba.conf
在最后改成:

配置pcp管理工具密码:
pg_md5 pwd
密码加密

vim /etc/pgpool-II/pcp.conf
把刚才加密的密码粘贴到文件里

配置系统命令权限:
Root用户下:
chmod u+s /sbin/ifconfig &&chmod u+s /usr/sbin

配置中间件配置文件:
vim /etc/pgpool-II/pgpool.conf

# CONNECTIONS
listen_addresses = '*'
port = 9999
pcp_listen_addresses = '*'
pcp_port = 9898 # - Backend Connection Settings - backend_hostname0 = 'master'
backend_port0 = 5432
backend_weight0 = 1
backend_data_directory0 = ' /app/pgsql/data'
backend_flag0 = 'ALLOW_TO_FAILOVER' backend_hostname1 = 'slave1'
backend_port1 = 5432
backend_weight1 = 1
backend_data_directory1 = '/app/pgsql/data '
backend_flag1 = 'ALLOW_TO_FAILOVER' # - Authentication -
enable_pool_hba = off
pool_passwd = 'pool_passwd' # FILE LOCATIONS
pid_file_name = '/opt/pgpool/pgpool.pid' replication_mode = off
load_balance_mode = on
master_slave_mode = on
master_slave_sub_mode = 'stream' sr_check_period = 5
sr_check_user = 'repuser'
sr_check_password = 'repuser'
sr_check_database = 'postgres' #------------------------------------------------------------------------------
# HEALTH CHECK 健康检查
#------------------------------------------------------------------------------ health_check_period = 10 # Health check period
# Disabled (0) by default
health_check_timeout = 20
# Health check timeout
# 0 means no timeout
health_check_user = ' repuser '
# Health check user
health_check_password = ' repuser ' #数据库密码
# Password for health check user
health_check_database = 'postgres'
#必须设置,否则primary数据库down了,pgpool不知道,不能及时切换。从库流复制还在连接数据,报连接失败。
#只有下次使用pgpool登录时,发现连接不上,然后报错,这时候,才知道挂了,pgpool进行切换。 #主备切换的命令行配置
#------------------------------------------------------------------------------
# FAILOVER AND FAILBACK
#------------------------------------------------------------------------------ failover_command = '/opt/pgpool/failover_stream.sh %d %H /tmp/trigger_file0 ' #------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------ # - Enabling -
use_watchdog = on
# - Watchdog communication Settings - wd_hostname = 'slave1' #本端
# Host name or IP address of this watchdog
# (change requires restart)
wd_port = 9000
# port number for watchdog service
# (change requires restart)
# - Virtual IP control Setting - delegate_IP = '192.168.123.183'
# delegate IP address
# If this is empty, virtual IP never bring up.
# (change requires restart)
if_cmd_path = '/sbin'
# path to the directory where if_up/down_cmd exists
# (change requires restart)
if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0'
# startup delegate IP command
# (change requires restart)
if_down_cmd = 'ifconfig eth0:0 down'
# shutdown delegate IP command
# (change requires restart)
# -- heartbeat mode -- wd_heartbeat_port = 9694
# Port number for receiving heartbeat signal
# (change requires restart)
wd_heartbeat_keepalive = 2
# Interval time of sending heartbeat signal (sec)
# (change requires restart)
wd_heartbeat_deadtime = 30
# Deadtime interval for heartbeat signal (sec)
# (change requires restart)
heartbeat_destination0 = 'master' #对端
# Host name or IP address of destination 0
# for sending heartbeat signal.
# (change requires restart)
heartbeat_destination_port0 = 9694
# Port number of destination 0 for sending
# heartbeat signal. Usually this is the
# same as wd_heartbeat_port.
# (change requires restart)
heartbeat_device0 = 'eth0'
# Name of NIC device (such like 'eth0')
# used for sending/receiving heartbeat
# signal to/from destination 0.
# This works only when this is not empty
# and pgpool has root privilege.
# (change requires restart)
# - Other pgpool Connection Settings - other_pgpool_hostname0 = 'master' #对端
# Host name or IP address to connect to for
# (change requires restart)
other_pgpool_port0 = 9999
# Port number for othet pgpool 0
# (change requires restart)
other_wd_port0 = 9000
# Port number for othet watchdog 0
# (change requires restart)

下面在master和slave1这两台机器上
mkdir /opt/pgpool &&chown postgres:postgres /opt/pgpool

master上:

cd /opt/pgpool
vim failover_stream.sh
# Failover command for streaming replication.
# This script assumes that DB node 0 is primary, and 1 is standby.
#
# If standby goes down, do nothing. If primary goes down, create a
# trigger file so that standby takes over primary node.
#
# Arguments: $1: failed node id. $2: new master hostname. $3: path to
# trigger file.
failed_node=192.168.123.180
new_master=192.168.123.181
trigger_file=$3
# Do nothing if standby goes down.
if [ $failed_node = 1 ]; then
exit 0;
fi
# Create the trigger file.
/usr/bin/ssh -T $new_master /bin/touch $trigger_file
exit 0;

保存退出,并赋权
chown postgres:postgres failover_stream.sh &&chmod 777 failover_stream.sh

slave1上:

cd /opt/pgpool
vim failover_stream.sh
#! /bin/sh

# Failover command for streaming replication.
# This script assumes that DB node 0 is primary, and 1 is standby.
#
# If standby goes down, do nothing. If primary goes down, create a
# trigger file so that standby takes over primary node.
#
# Arguments: $1: failed node id. $2: new master hostname. $3: path to
# trigger file.
failed_node=192.168.123.181
new_master=192.168.123.180
trigger_file=$3
# Do nothing if standby goes down.
if [ $failed_node = 1 ]; then
exit 0;
fi
# Create the trigger file.
/usr/bin/ssh -T $new_master /bin/touch $trigger_file
exit 0;

保存退出并赋权:
chown postgres:postgres failover_stream.sh &&chmod 777 failover_stream.sh

在master和salve1上创建日志文件:

mkdir /var/log/pgpool
chown -R postgres.postgres /var/log/pgpool
mkdir /var/run/pgpool
chown -R postgres.postgres /var/run/pgpool

配置host:
在master、slave1、slave2的/etc/hosts配置ip映射

192.168.123.180 master
192.168.123.181 slave1
192.168.123.182 slave2

在master上创建repusr账号:

su postgres
psql
create user repuser with password 'repuser';

防火墙开放:5432 9999 9898 9000 9694
4.5、启动pgpool
先在master上启动pgpool:
pgpool -n -d -D > /var/log/pgpool/pgpool.log 2>&1 &

再在slave1上启动pgpool:
pgpool -n -d -D > /var/log/pgpool/pgpool.log 2>&1 &
Master上的ifconfig会多一个虚拟ip出来

快速停止pgpool的指令:
pgpool -m fast stop
连接虚拟ip进入数据库:

Su postgres
psql -h 192.168.123.183 -p 9999

查看集群节点状态:
show pool_nodes;

写在安装后

写文档才发现,边安装边趟坑边记录,还要注意格式是多么愉(xin)快(ku)的事,本着开源精神,贴出来给要用到pg集群的小伙伴们参考,本文侵删

postgresql集群的搭建的更多相关文章

  1. 基于pgpool搭建postgresql集群

    postgresql集群搭建 基于pgpool中间件实现postgresql一主多从集群部署,这里用两台服务器作一主一从示例 虚拟机名 IP 主从划分 THApps 192.168.1.31 主节点 ...

  2. zookeeper集群的搭建以及hadoop ha的相关配置

    1.环境 centos7 hadoop2.6.5 zookeeper3.4.9 jdk1.8 master作为active主机,data1作为standby备用机,三台机器均作为数据节点,yarn资源 ...

  3. 朝花夕拾之--大数据平台CDH集群离线搭建

    body { border: 1px solid #ddd; outline: 1300px solid #fff; margin: 16px auto; } body .markdown-body ...

  4. postgresql集群方案参考答案

    PostgreSQL配置Streaming Replication集群 http://www.cnblogs.com/marsprj/archive/2013/03/04/2943373.html p ...

  5. Hadoop+Spark:集群环境搭建

    环境准备: 在虚拟机下,大家三台Linux ubuntu 14.04 server x64 系统(下载地址:http://releases.ubuntu.com/14.04.2/ubuntu-14.0 ...

  6. linux环境(CentOS-6.7)下redis集群的搭建全过程

    linux环境下redis集群的搭建全过程: 使用mount命令将光盘挂载到/mnt/cdrom目录下: [root@hadoop03 ~]# mount -t iso9660 -o ro /dev/ ...

  7. 【redis】 linux 下redis 集群环境搭建

    Redis集群 (要让集群正常工作至少需要3个主节点,在这里我们要创建6个redis节点,其中三个为主节点,三个为从节点,对应的redis节点的ip和端口对应关系如下) 127.0.0.1:63791 ...

  8. 项目进阶 之 集群环境搭建(三)多管理节点MySQL集群

    上次的博文项目进阶 之 集群环境搭建(二)MySQL集群中,我们搭建了一个基础的MySQL集群,这篇博客咱们继续讲解MySQL集群的相关内容,同时针对上一篇遗留的问题提出一个解决方案. 1.单管理节点 ...

  9. [原]项目进阶 之 集群环境搭建(二)MySQL集群

    上次的博文中我们介绍了一下集群的相关概念,今天的博文我们介绍一下MySQL集群的相关内容. 1.MySQL集群简介 MySQL群集技术在分布式系统中为MySQL数据提供了冗余特性,增强了安全性,使得单 ...

随机推荐

  1. 流畅的Python (Fluent Python) —— 前言

    本书重点: 这本书并不是一本完备的 Python 使用手册,而是会强调 Python 作为编程语言独有的特性,这些特性或者是只有 Python 才具备的,或者是在其他大众语言里很少见的. Python ...

  2. Beta冲刺-(3/3)

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass1/ 这个作业要求在哪里 https://edu.cnbl ...

  3. 05java基础

    1.BigInteger和BigDecimal类 package cn.jxufe.java.chapter5.demo01; import java.math.BigInteger; public ...

  4. Educational Codeforces Round 32 Almost Identity Permutations CodeForces - 888D (组合数学)

    A permutation p of size n is an array such that every integer from 1 to n occurs exactly once in thi ...

  5. 对15号夏壹队的TD信息通使用体验

    对夏壹队的APP的用户使用体验:首先下载的时候看到这个APP的大小是6M多点不算很大感觉还不错,但是占内存不大也说明了一个问题,它不会有很多的功能. 图标是一个蜜蜂,打开后会有一个登陆界面,一开始没有 ...

  6. ESP8266-01

    我的模块购买地址  https://buyertrade.taobao.com/trade/detail/tradeSnap.htm?tradeID=460212770243341548&sn ...

  7. layui js动态添加的面板不能折叠

    layui 动态添加dom后一般调用 layer.form.render()更新dom就可以了,但是我动态添加一个面板后form.render()就没有效果,要用layui.element.rende ...

  8. 安卓手机通过有线连接PC上网

    因手机wifi坏了,速度上限为2.5m/s.无法发挥出100m带宽的威力. 这里探索各大神的指导,记录下其中一种方式. :链接       主题:使用openvpn和手机的USB共享网络 通过mico ...

  9. linux运维、架构之路-python2.6升级3.6

    一.环境 1.系统 [root@m01 ~]# cat /etc/redhat-release CentOS release 6.9 (Final) [root@m01 ~]# uname -r -. ...

  10. for-in语句和with语句、break和continue语句

    for-in语句 for-in语句是一种精准迭代语句,可以用来枚举对象的属性,用以遍历一个对象的全部属性. for…in声明用于对数组或者对象的属性进行循环操作: for…in循环中的代码每执行一次, ...