前端技术
HTML
CSS
Javascript
前端框架和UI库
VUE
ReactJS
AngularJS
JQuery
NodeJS
JSON
Element-UI
Bootstrap
Material UI
服务端和客户端
Java
Python
PHP
Golang
Scala
Kotlin
Groovy
Ruby
Lua
.net
c#
c++
后端WEB和工程框架
SpringBoot
SpringCloud
Struts2
MyBatis
Hibernate
Tornado
Beego
Go-Spring
Go Gin
Go Iris
Dubbo
HessianRPC
Maven
Gradle
数据库
MySQL
Oracle
Mongo
中间件与web容器
Redis
MemCache
Etcd
Cassandra
Kafka
RabbitMQ
RocketMQ
ActiveMQ
Nacos
Consul
Tomcat
Nginx
Netty
大数据技术
Hive
Impala
ClickHouse
DorisDB
Greenplum
PostgreSQL
HBase
Kylin
Hadoop
Apache Pig
ZooKeeper
SeaTunnel
Sqoop
Datax
Flink
Spark
Mahout
数据搜索与日志
ElasticSearch
Apache Lucene
Apache Solr
Kibana
Logstash
数据可视化与OLAP
Apache Atlas
Superset
Saiku
Tesseract
系统与容器
Linux
Shell
Docker
Kubernetes
[PostgreSQL分页查询示例]的搜索结果
这里是文章列表。热门标签的颜色随机变换,标签颜色没有特殊含义。
点击某个标签可搜索标签相关的文章。
点击某个标签可搜索标签相关的文章。
转载文章
...句类型,比如:关联子查询 支持绝大部分PostgreSQL的SQL语句 分布式多版本并发控制(MVCC:Multi-version Concurrency Control) 支持JSON和XML格式 Postgres-XL缺少的功能 内建的高可用机制 使用外部机制实现高可能,如:Corosync/Pacemaker 有未来功能提升的空间 增加节点/重新分片数据(re-shard)的简便性 数据重分布(redistribution)期间会锁表 可采用预分片(pre-shard)方式解决,在同台物理服务器上建立多个数据节点,每个节点存储一个数据分片。数据重分布时,将一些数据节点迁出即可 某些外键、唯一性约束功能 Postgres-XL架构 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M9lFuEIP-1640133702200)(./assets/postgre-xl.jpg)] 基于开源项目Postgres-XC XL增加了MPP,允许数据节点间直接通讯,交换复杂跨节点关联查询相关数据信息,减少协调器负载。 多个协调器(Coordinator) 应用程序的数据库连入点 分析查询语句,生成执行计划 多个数据节点(DataNode) 实际的数据存储 数据自动打散分布到集群中各数据节点 本地执行查询 一个查询在所有相关节点上并行查询 全局事务管理器(GTM:Global Transaction Manager) 提供事务间一致性视图 部署GTM Proxy实例,以提高性能 Postgre-XL主要组件 GTM (Global Transaction Manager) - 全局事务管理器 GTM是Postgres-XL的一个关键组件,用于提供一致的事务管理和元组可见性控制。 GTM Standby GTM的备节点,在pgxc,pgxl中,GTM控制所有的全局事务分配,如果出现问题,就会导致整个集群不可用,为了增加可用性,增加该备用节点。当GTM出现问题时,GTM Standby可以升级为GTM,保证集群正常工作。 GTM-Proxy GTM需要与所有的Coordinators通信,为了降低压力,可以在每个Coordinator机器上部署一个GTM-Proxy。 Coordinator --协调器 协调器是应用程序到数据库的接口。它的作用类似于传统的PostgreSQL后台进程,但是协调器不存储任何实际数据。实际数据由数据节点存储。协调器接收SQL语句,根据需要获取全局事务Id和全局快照,确定涉及哪些数据节点,并要求它们执行(部分)语句。当向数据节点发出语句时,它与GXID和全局快照相关联,以便多版本并发控制(MVCC)属性扩展到集群范围。 Datanode --数据节点 用于实际存储数据。表可以分布在各个数据节点之间,也可以复制到所有数据节点。数据节点没有整个数据库的全局视图,它只负责本地存储的数据。接下来,协调器将检查传入语句,并制定子计划。然后,根据需要将这些数据连同GXID和全局快照一起传输到涉及的每个数据节点。数据节点可以在不同的会话中接收来自各个协调器的请求。但是,由于每个事务都是惟一标识的,并且与一致的(全局)快照相关联,所以每个数据节点都可以在其事务和快照上下文中正确执行。 Postgres-XL继承了PostgreSQL Postgres-XL是PostgreSQL的扩展并继承了其很多特性: 复杂查询 外键 触发器 视图 事务 MVCC(多版本控制) 此外,类似于PostgreSQL,用户可以通过多种方式扩展Postgres-XL,例如添加新的 数据类型 函数 操作 聚合函数 索引类型 过程语言 安装 环境说明 由于资源有限,gtm一台、另外两台身兼数职。 主机名 IP 角色 端口 nodename 数据目录 gtm 192.168.20.132 GTM 6666 gtm /nodes/gtm 协调器 5432 coord1 /nodes/coordinator xl1 192.168.20.133 数据节点 5433 node1 /nodes/pgdata gtm代理 6666 gtmpoxy01 /nodes/gtm_pxy1 协调器 5432 coord2 /nodes/coordinator xl2 192.168.20.134 数据节点 5433 node2 /nodes/pgdata gtm代理 6666 gtmpoxy02 /nodes/gtm_pxy2 要求 GNU make版本 3.8及以上版本 [root@pg ~] make --versionGNU Make 3.82Built for x86_64-redhat-linux-gnuCopyright (C) 2010 Free Software Foundation, Inc.License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>This is free software: you are free to change and redistribute it.There is NO WARRANTY, to the extent permitted by law. 需安装GCC包 需安装tar包 用于解压缩文件 默认需要GNU Readline library 其作用是可以让psql命令行记住执行过的命令,并且可以通过键盘上下键切换命令。但是可以通过--without-readline禁用这个特性,或者可以指定--withlibedit-preferred选项来使用libedit 默认使用zlib压缩库 可通过--without-zlib选项来禁用 配置hosts 所有主机上都配置 [root@xl2 11] cat /etc/hosts127.0.0.1 localhost192.168.20.132 gtm192.168.20.133 xl1192.168.20.134 xl2 关闭防火墙、Selinux 所有主机都执行 关闭防火墙: [root@gtm ~] systemctl stop firewalld.service[root@gtm ~] systemctl disable firewalld.service selinux设置: [root@gtm ~]vim /etc/selinux/config 设置SELINUX=disabled,保存退出。 This file controls the state of SELinux on the system. SELINUX= can take one of these three values: enforcing - SELinux security policy is enforced. permissive - SELinux prints warnings instead of enforcing. disabled - No SELinux policy is loaded.SELINUX=disabled SELINUXTYPE= can take one of three two values: targeted - Targeted processes are protected, minimum - Modification of targeted policy. Only selected processes are protected. mls - Multi Level Security protection. 安装依赖包 所有主机上都执行 yum install -y flex bison readline-devel zlib-devel openjade docbook-style-dsssl gcc 创建用户 所有主机上都执行 [root@gtm ~] useradd postgres[root@gtm ~] passwd postgres[root@gtm ~] su - postgres[root@gtm ~] mkdir ~/.ssh[root@gtm ~] chmod 700 ~/.ssh 配置SSH免密登录 仅仅在gtm节点配置如下操作: [root@gtm ~] su - postgres[postgres@gtm ~] ssh-keygen -t rsa[postgres@gtm ~] cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys[postgres@gtm ~] chmod 600 ~/.ssh/authorized_keys 将刚生成的认证文件拷贝到xl1到xl2中,使得gtm节点可以免密码登录xl1~xl2的任意一个节点: [postgres@gtm ~] scp ~/.ssh/authorized_keys postgres@xl1:~/.ssh/[postgres@gtm ~] scp ~/.ssh/authorized_keys postgres@xl2:~/.ssh/ 对所有提示都不要输入,直接enter下一步。直到最后,因为第一次要求输入目标机器的用户密码,输入即可。 下载源码 下载地址:https://www.postgres-xl.org/download/ [root@slave ~] ll postgres-xl-10r1.1.tar.gz-rw-r--r-- 1 root root 28121666 May 30 05:21 postgres-xl-10r1.1.tar.gz 编译、安装Postgres-XL 所有节点都安装,编译需要一点时间,最好同时进行编译。 [root@slave ~] tar xvf postgres-xl-10r1.1.tar.gz[root@slave ~] ./configure --prefix=/home/postgres/pgxl/[root@slave ~] make[root@slave ~] make install[root@slave ~] cd contrib/ --安装必要的工具,在gtm节点上安装即可[root@slave ~] make[root@slave ~] make install 配置环境变量 所有节点都要配置 进入postgres用户,修改其环境变量,开始编辑 [root@gtm ~]su - postgres[postgres@gtm ~]vi .bashrc --不是.bash_profile 在打开的文件末尾,新增如下变量配置: export PGHOME=/home/postgres/pgxlexport LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATHexport PATH=$PGHOME/bin:$PATH 按住esc,然后输入:wq!保存退出。输入以下命令对更改重启生效。 [postgres@gtm ~] source .bashrc --不是.bash_profile 输入以下语句,如果输出变量结果,代表生效 [postgres@gtm ~] echo $PGHOME 应该输出/home/postgres/pgxl代表生效 配置集群 生成pgxc_ctl.conf配置文件 [postgres@gtm ~] pgxc_ctl prepare/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxl/pgxc_ctl/pgxc_ctl_bash.ERROR: File "/home/postgres/pgxl/pgxc_ctl/pgxc_ctl.conf" not found or not a regular file. No such file or directoryInstalling pgxc_ctl_bash script as /home/postgres/pgxl/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxl/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxl/pgxc_ctl --configuration /home/postgres/pgxl/pgxc_ctl/pgxc_ctl.confFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxl/pgxc_ctl 配置pgxc_ctl.conf 新建/home/postgres/pgxc_ctl/pgxc_ctl.conf文件,编辑如下: 对着模板文件一个一个修改,否则会造成初始化过程出现各种神奇问题。 pgxcInstallDir=$PGHOMEpgxlDATA=$PGHOME/data pgxcOwner=postgres---- GTM Master -----------------------------------------gtmName=gtmgtmMasterServer=gtmgtmMasterPort=6666gtmMasterDir=$pgxlDATA/nodes/gtmgtmSlave=y Specify y if you configure GTM Slave. Otherwise, GTM slave will not be configured and all the following variables will be reset.gtmSlaveName=gtmSlavegtmSlaveServer=gtm value none means GTM slave is not available. Give none if you don't configure GTM Slave.gtmSlavePort=20001 Not used if you don't configure GTM slave.gtmSlaveDir=$pgxlDATA/nodes/gtmSlave Not used if you don't configure GTM slave.---- GTM-Proxy Master -------gtmProxyDir=$pgxlDATA/nodes/gtm_proxygtmProxy=y gtmProxyNames=(gtm_pxy1 gtm_pxy2) gtmProxyServers=(xl1 xl2) gtmProxyPorts=(6666 6666) gtmProxyDirs=($gtmProxyDir $gtmProxyDir) ---- Coordinators ---------coordMasterDir=$pgxlDATA/nodes/coordcoordNames=(coord1 coord2) coordPorts=(5432 5432) poolerPorts=(6667 6667) coordPgHbaEntries=(0.0.0.0/0)coordMasterServers=(xl1 xl2) coordMasterDirs=($coordMasterDir $coordMasterDir)coordMaxWALsernder=0 没设置备份节点,设置为0coordMaxWALSenders=($coordMaxWALsernder $coordMaxWALsernder) 数量保持和coordMasterServers一致coordSlave=n---- Datanodes ----------datanodeMasterDir=$pgxlDATA/nodes/dn_masterprimaryDatanode=xl1 主数据节点datanodeNames=(node1 node2)datanodePorts=(5433 5433) datanodePoolerPorts=(6668 6668) datanodePgHbaEntries=(0.0.0.0/0)datanodeMasterServers=(xl1 xl2)datanodeMasterDirs=($datanodeMasterDir $datanodeMasterDir)datanodeMaxWalSender=4datanodeMaxWALSenders=($datanodeMaxWalSender $datanodeMaxWalSender) 集群初始化,启动,停止 初始化 pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf init all 输出结果: /bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlStopping all the coordinator masters.Stopping coordinator master coord1.Stopping coordinator master coord2.pg_ctl: directory "/home/postgres/pgxc/nodes/coord/coord1" does not existpg_ctl: directory "/home/postgres/pgxc/nodes/coord/coord2" does not existDone.Stopping all the datanode masters.Stopping datanode master datanode1.Stopping datanode master datanode2.pg_ctl: PID file "/home/postgres/pgxc/nodes/datanode/datanode1/postmaster.pid" does not existIs server running?Done.Stop GTM masterwaiting for server to shut down.... doneserver stopped[postgres@gtm ~]$ echo $PGHOME/home/postgres/pgxl[postgres@gtm ~]$ ll /home/postgres/pgxl/pgxc/nodes/gtm/gtm.^C[postgres@gtm ~]$ pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf init all/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlInitialize GTM masterERROR: target directory (/home/postgres/pgxc/nodes/gtm) exists and not empty. Skip GTM initilializationDone.Start GTM masterserver startingInitialize all the coordinator masters.Initialize coordinator master coord1.ERROR: target coordinator master coord1 is running now. Skip initilialization.Initialize coordinator master coord2.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/coord/coord2 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.Done.Starting coordinator master.Starting coordinator master coord1ERROR: target coordinator master coord1 is already running now. Skip initialization.Starting coordinator master coord22019-05-30 21:09:25.562 EDT [2148] LOG: listening on IPv4 address "0.0.0.0", port 54322019-05-30 21:09:25.562 EDT [2148] LOG: listening on IPv6 address "::", port 54322019-05-30 21:09:25.563 EDT [2148] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"2019-05-30 21:09:25.601 EDT [2149] LOG: database system was shut down at 2019-05-30 21:09:22 EDT2019-05-30 21:09:25.605 EDT [2148] LOG: database system is ready to accept connections2019-05-30 21:09:25.612 EDT [2156] LOG: cluster monitor startedDone.Initialize all the datanode masters.Initialize the datanode master datanode1.Initialize the datanode master datanode2.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/datanode/datanode1 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/datanode/datanode2 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.Done.Starting all the datanode masters.Starting datanode master datanode1.WARNING: datanode master datanode1 is running now. Skipping.Starting datanode master datanode2.2019-05-30 21:09:33.352 EDT [2404] LOG: listening on IPv4 address "0.0.0.0", port 154322019-05-30 21:09:33.352 EDT [2404] LOG: listening on IPv6 address "::", port 154322019-05-30 21:09:33.355 EDT [2404] LOG: listening on Unix socket "/tmp/.s.PGSQL.15432"2019-05-30 21:09:33.392 EDT [2404] LOG: redirecting log output to logging collector process2019-05-30 21:09:33.392 EDT [2404] HINT: Future log output will appear in directory "pg_log".Done.psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"Done.psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"Done.[postgres@gtm ~]$ pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf stop all/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlStopping all the coordinator masters.Stopping coordinator master coord1.Stopping coordinator master coord2.pg_ctl: directory "/home/postgres/pgxc/nodes/coord/coord1" does not existDone.Stopping all the datanode masters.Stopping datanode master datanode1.Stopping datanode master datanode2.pg_ctl: PID file "/home/postgres/pgxc/nodes/datanode/datanode1/postmaster.pid" does not existIs server running?Done.Stop GTM masterwaiting for server to shut down.... doneserver stopped[postgres@gtm ~]$ pgxc_ctl/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlPGXC monitor allNot running: gtm masterRunning: coordinator master coord1Not running: coordinator master coord2Running: datanode master datanode1Not running: datanode master datanode2PGXC stop coordinator master coord1Stopping coordinator master coord1.pg_ctl: directory "/home/postgres/pgxc/nodes/coord/coord1" does not existDone.PGXC stop datanode master datanode1Stopping datanode master datanode1.pg_ctl: PID file "/home/postgres/pgxc/nodes/datanode/datanode1/postmaster.pid" does not existIs server running?Done.PGXC monitor allNot running: gtm masterRunning: coordinator master coord1Not running: coordinator master coord2Running: datanode master datanode1Not running: datanode master datanode2PGXC monitor allNot running: gtm masterNot running: coordinator master coord1Not running: coordinator master coord2Not running: datanode master datanode1Not running: datanode master datanode2PGXC exit[postgres@gtm ~]$ pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf init all/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlInitialize GTM masterERROR: target directory (/home/postgres/pgxc/nodes/gtm) exists and not empty. Skip GTM initilializationDone.Start GTM masterserver startingInitialize all the coordinator masters.Initialize coordinator master coord1.Initialize coordinator master coord2.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/coord/coord1 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/coord/coord2 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.Done.Starting coordinator master.Starting coordinator master coord1Starting coordinator master coord22019-05-30 21:13:03.998 EDT [25137] LOG: listening on IPv4 address "0.0.0.0", port 54322019-05-30 21:13:03.998 EDT [25137] LOG: listening on IPv6 address "::", port 54322019-05-30 21:13:04.000 EDT [25137] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"2019-05-30 21:13:04.038 EDT [25138] LOG: database system was shut down at 2019-05-30 21:13:00 EDT2019-05-30 21:13:04.042 EDT [25137] LOG: database system is ready to accept connections2019-05-30 21:13:04.049 EDT [25145] LOG: cluster monitor started2019-05-30 21:13:04.020 EDT [2730] LOG: listening on IPv4 address "0.0.0.0", port 54322019-05-30 21:13:04.020 EDT [2730] LOG: listening on IPv6 address "::", port 54322019-05-30 21:13:04.021 EDT [2730] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"2019-05-30 21:13:04.057 EDT [2731] LOG: database system was shut down at 2019-05-30 21:13:00 EDT2019-05-30 21:13:04.061 EDT [2730] LOG: database system is ready to accept connections2019-05-30 21:13:04.062 EDT [2738] LOG: cluster monitor startedDone.Initialize all the datanode masters.Initialize the datanode master datanode1.Initialize the datanode master datanode2.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/datanode/datanode1 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.UTF-8".The default database encoding has accordingly been set to "UTF8".The default text search configuration will be set to "english".Data page checksums are disabled.fixing permissions on existing directory /home/postgres/pgxc/nodes/datanode/datanode2 ... okcreating subdirectories ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okrunning bootstrap script ... okperforming post-bootstrap initialization ... creating cluster information ... oksyncing data to disk ... okfreezing database template0 ... okfreezing database template1 ... okfreezing database postgres ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A, or--auth-local and --auth-host, the next time you run initdb.Success.Done.Starting all the datanode masters.Starting datanode master datanode1.Starting datanode master datanode2.2019-05-30 21:13:12.077 EDT [25392] LOG: listening on IPv4 address "0.0.0.0", port 154322019-05-30 21:13:12.077 EDT [25392] LOG: listening on IPv6 address "::", port 154322019-05-30 21:13:12.079 EDT [25392] LOG: listening on Unix socket "/tmp/.s.PGSQL.15432"2019-05-30 21:13:12.114 EDT [25392] LOG: redirecting log output to logging collector process2019-05-30 21:13:12.114 EDT [25392] HINT: Future log output will appear in directory "pg_log".2019-05-30 21:13:12.079 EDT [2985] LOG: listening on IPv4 address "0.0.0.0", port 154322019-05-30 21:13:12.079 EDT [2985] LOG: listening on IPv6 address "::", port 154322019-05-30 21:13:12.081 EDT [2985] LOG: listening on Unix socket "/tmp/.s.PGSQL.15432"2019-05-30 21:13:12.117 EDT [2985] LOG: redirecting log output to logging collector process2019-05-30 21:13:12.117 EDT [2985] HINT: Future log output will appear in directory "pg_log".Done.psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"Done.psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"psql: FATAL: no pg_hba.conf entry for host "192.168.20.132", user "postgres", database "postgres"Done. 启动 pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf start all 关闭 pgxc_ctl -c /home/postgres/pgxc_ctl/pgxc_ctl.conf stop all 查看集群状态 [postgres@gtm ~]$ pgxc_ctl monitor all/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.conf/home/postgres/pgxc_ctl/pgxc_ctl.conf: line 189: $coordExtraConfig: ambiguous redirectFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlRunning: gtm masterRunning: coordinator master coord1Running: coordinator master coord2Running: datanode master datanode1Running: datanode master datanode2 配置集群信息 分别在数据节点、协调器节点上分别执行以下命令: 注:本节点只执行修改操作即可(alert node),其他节点执行创建命令(create node)。因为本节点已经包含本节点的信息。 create node coord1 with (type=coordinator,host=xl1, port=5432);create node coord2 with (type=coordinator,host=xl2, port=5432);alter node coord1 with (type=coordinator,host=xl1, port=5432);alter node coord2 with (type=coordinator,host=xl2, port=5432);create node datanode1 with (type=datanode, host=xl1,port=15432,primary=true,PREFERRED);create node datanode2 with (type=datanode, host=xl2,port=15432);alter node datanode1 with (type=datanode, host=xl1,port=15432,primary=true,PREFERRED);alter node datanode2 with (type=datanode, host=xl2,port=15432);select pgxc_pool_reload(); 分别登陆数据节点、协调器节点验证 postgres= select from pgxc_node;node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id-----------+-----------+-----------+-----------+----------------+------------------+-------------coord1 | C | 5432 | xl1 | f | f | 1885696643coord2 | C | 5432 | xl2 | f | f | -1197102633datanode2 | D | 15432 | xl2 | f | f | -905831925datanode1 | D | 15432 | xl1 | t | f | 888802358(4 rows) 测试 插入数据 在数据节点1,执行相关操作。 通过协调器端口登录PG [postgres@xl1 ~]$ psql -p 5432psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= create database lei;CREATE DATABASEpostgres= \c lei;You are now connected to database "lei" as user "postgres".lei= create table test1(id int,name text);CREATE TABLElei= insert into test1(id,name) select generate_series(1,8),'测试';INSERT 0 8lei= select from test1;id | name----+------1 | 测试2 | 测试5 | 测试6 | 测试8 | 测试3 | 测试4 | 测试7 | 测试(8 rows) 注:默认创建的表为分布式表,也就是每个数据节点值存储表的部分数据。关于表类型具体说明,下面有说明。 通过15432端口登录数据节点,查看数据 有5条数据 [postgres@xl1 ~]$ psql -p 15432psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= \c lei;You are now connected to database "lei" as user "postgres".lei= select from test1;id | name----+------1 | 测试2 | 测试5 | 测试6 | 测试8 | 测试(5 rows) 登录到节点2,查看数据 有3条数据 [postgres@xl2 ~]$ psql -p15432psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= \c lei;You are now connected to database "lei" as user "postgres".lei= select from test1;id | name----+------3 | 测试4 | 测试7 | 测试(3 rows) 两个节点的数据加起来整个8条,没有问题。 至此Postgre-XL集群搭建完成。 创建数据库、表时可能会出现以下错误: ERROR: Failed to get pooled connections 是因为pg_hba.conf配置不对,所有节点加上host all all 192.168.20.0/0 trust并重启集群即可。 ERROR: No Datanode defined in cluster 首先确认是否创建了数据节点,也就是create node相关的命令。如果创建了则执行select pgxc_pool_reload();使其生效即可。 集群管理与应用 表类型说明 REPLICATION表:各个datanode节点中,表的数据完全相同,也就是说,插入数据时,会分别在每个datanode节点插入相同数据。读数据时,只需要读任意一个datanode节点上的数据。 建表语法: CREATE TABLE repltab (col1 int, col2 int) DISTRIBUTE BY REPLICATION; DISTRIBUTE :会将插入的数据,按照拆分规则,分配到不同的datanode节点中存储,也就是sharding技术。每个datanode节点只保存了部分数据,通过coordinate节点可以查询完整的数据视图。 CREATE TABLE disttab(col1 int, col2 int, col3 text) DISTRIBUTE BY HASH(col1); 模拟数据插入 任意登录一个coordinate节点进行建表操作 [postgres@gtm ~]$ psql -h xl1 -p 5432 -U postgrespostgres= INSERT INTO disttab SELECT generate_series(1,100), generate_series(101, 200), 'foo';INSERT 0 100postgres= INSERT INTO repltab SELECT generate_series(1,100), generate_series(101, 200);INSERT 0 100 查看数据分布结果: DISTRIBUTE表分布结果 postgres= SELECT xc_node_id, count() FROM disttab GROUP BY xc_node_id;xc_node_id | count ------------+-------1148549230 | 42-927910690 | 58(2 rows) REPLICATION表分布结果 postgres= SELECT count() FROM repltab;count -------100(1 row) 查看另一个datanode2中repltab表结果 [postgres@datanode2 pgxl9.5]$ psql -p 15432psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= SELECT count() FROM repltab;count -------100(1 row) 结论:REPLICATION表中,datanode1,datanode2中表是全部数据,一模一样。而DISTRIBUTE表,数据散落近乎平均分配到了datanode1,datanode2节点中。 新增数据节点与数据重分布 在线新增节点、并重新分布数据。 新增datanode节点 在gtm集群管理节点上执行pgxc_ctl命令 [postgres@gtm ~]$ pgxc_ctl/bin/bashInstalling pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Installing pgxc_ctl_bash script as /home/postgres/pgxc_ctl/pgxc_ctl_bash.Reading configuration using /home/postgres/pgxc_ctl/pgxc_ctl_bash --home /home/postgres/pgxc_ctl --configuration /home/postgres/pgxc_ctl/pgxc_ctl.confFinished reading configuration. PGXC_CTL START Current directory: /home/postgres/pgxc_ctlPGXC 在服务器xl3上,新增一个master角色的datanode节点,名称是datanode3 端口号暂定5430,pool master暂定6669 ,指定好数据目录位置,从两个节点升级到3个节点,之后要写3个none none应该是datanodeSpecificExtraConfig或者datanodeSpecificExtraPgHba配置PGXC add datanode master datanode3 xl3 15432 6671 /home/postgres/pgxc/nodes/datanode/datanode3 none none none 等待新增完成后,查询集群节点状态: postgres= select from pgxc_node;node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id-----------+-----------+-----------+-----------+----------------+------------------+-------------datanode1 | D | 15432 | xl1 | t | f | 888802358datanode2 | D | 15432 | xl2 | f | f | -905831925datanode3 | D | 15432 | xl3 | f | f | -705831925coord1 | C | 5432 | xl1 | f | f | 1885696643coord2 | C | 5432 | xl2 | f | f | -1197102633(4 rows) 节点新增完毕 数据重新分布 由于新增节点后无法自动完成数据重新分布,需要手动操作。 DISTRIBUTE表分布在了node1,node2节点上,如下: postgres= SELECT xc_node_id, count() FROM disttab GROUP BY xc_node_id;xc_node_id | count ------------+-------1148549230 | 42-927910690 | 58(2 rows) 新增一个节点后,将sharding表数据重新分配到三个节点上,将repl表复制到新节点 重分布sharding表postgres= ALTER TABLE disttab ADD NODE (datanode3);ALTER TABLE 复制数据到新节点postgres= ALTER TABLE repltab ADD NODE (datanode3);ALTER TABLE 查看新的数据分布: postgres= SELECT xc_node_id, count() FROM disttab GROUP BY xc_node_id;xc_node_id | count ------------+--------700122826 | 36-927910690 | 321148549230 | 32(3 rows) 登录datanode3(新增的时候,放在了xl3服务器上,端口15432)节点查看数据: [postgres@gtm ~]$ psql -h xl3 -p 15432 -U postgrespsql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= select count() from repltab;count -------100(1 row) 很明显,通过 ALTER TABLE tt ADD NODE (dn)命令,可以将DISTRIBUTE表数据重新分布到新节点,重分布过程中会中断所有事务。可以将REPLICATION表数据复制到新节点。 从datanode节点中回收数据 postgres= ALTER TABLE disttab DELETE NODE (datanode3);ALTER TABLEpostgres= ALTER TABLE repltab DELETE NODE (datanode3);ALTER TABLE 删除数据节点 Postgresql-XL并没有检查将被删除的datanode节点是否有replicated/distributed表的数据,为了数据安全,在删除之前需要检查下被删除节点上的数据,有数据的话,要回收掉分配到其他节点,然后才能安全删除。删除数据节点分为四步骤: 1.查询要删除节点dn3的oid postgres= SELECT oid, FROM pgxc_node;oid | node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id -------+-----------+-----------+-----------+-----------+----------------+------------------+-------------11819 | coord1 | C | 5432 | datanode1 | f | f | 188569664316384 | coord2 | C | 5432 | datanode2 | f | f | -119710263316385 | node1 | D | 5433 | datanode1 | f | t | 114854923016386 | node2 | D | 5433 | datanode2 | f | f | -92791069016397 | dn3 | D | 5430 | datanode1 | f | f | -700122826(5 rows) 2.查询dn3对应的oid中是否有数据 testdb= SELECT FROM pgxc_class WHERE nodeoids::integer[] @> ARRAY[16397];pcrelid | pclocatortype | pcattnum | pchashalgorithm | pchashbuckets | nodeoids ---------+---------------+----------+-----------------+---------------+-------------------16388 | H | 1 | 1 | 4096 | 16397 16385 1638616394 | R | 0 | 0 | 0 | 16397 16385 16386(2 rows) 3.有数据的先回收数据 postgres= ALTER TABLE disttab DELETE NODE (dn3);ALTER TABLEpostgres= ALTER TABLE repltab DELETE NODE (dn3);ALTER TABLEpostgres= SELECT FROM pgxc_class WHERE nodeoids::integer[] @> ARRAY[16397];pcrelid | pclocatortype | pcattnum | pchashalgorithm | pchashbuckets | nodeoids ---------+---------------+----------+-----------------+---------------+----------(0 rows) 4.安全删除dn3 PGXC$ remove datanode master dn3 clean 故障节点FAILOVER 1.查看当前集群状态 [postgres@gtm ~]$ psql -h xl1 -p 5432psql (PGXL 10r1.1, based on PG 10.6 (Postgres-XL 10r1.1))Type "help" for help.postgres= SELECT oid, FROM pgxc_node;oid | node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id-------+-----------+-----------+-----------+-----------+----------------+------------------+-------------11739 | coord1 | C | 5432 | xl1 | f | f | 188569664316384 | coord2 | C | 5432 | xl2 | f | f | -119710263316387 | datanode2 | D | 15432 | xl2 | f | f | -90583192516388 | datanode1 | D | 15432 | xl1 | t | t | 888802358(4 rows) 2.模拟datanode1节点故障 直接关闭即可 PGXC stop -m immediate datanode master datanode1Stopping datanode master datanode1.Done. 3.测试查询 只要查询涉及到datanode1上的数据,那么该查询就会报错 postgres= SELECT xc_node_id, count() FROM disttab GROUP BY xc_node_id;WARNING: failed to receive file descriptors for connectionsERROR: Failed to get pooled connectionsHINT: This may happen because one or more nodes are currently unreachable, either because of node or network failure.Its also possible that the target node may have hit the connection limit or the pooler is configured with low connections.Please check if all nodes are running fine and also review max_connections and max_pool_size configuration parameterspostgres= SELECT xc_node_id, FROM disttab WHERE col1 = 3;xc_node_id | col1 | col2 | col3------------+------+------+-------905831925 | 3 | 103 | foo(1 row) 测试发现,查询范围如果涉及到故障的node1节点,会报错,而查询的数据范围不在node1上的话,仍然可以查询。 4.手动切换 要想切换,必须要提前配置slave节点。 PGXC$ failover datanode node1 切换完成后,查询集群 postgres= SELECT oid, FROM pgxc_node;oid | node_name | node_type | node_port | node_host | nodeis_primary | nodeis_preferred | node_id -------+-----------+-----------+-----------+-----------+----------------+------------------+-------------11819 | coord1 | C | 5432 | datanode1 | f | f | 188569664316384 | coord2 | C | 5432 | datanode2 | f | f | -119710263316386 | node2 | D | 15432 | datanode2 | f | f | -92791069016385 | node1 | D | 15433 | datanode2 | f | t | 1148549230(4 rows) 发现datanode1节点的ip和端口都已经替换为配置的slave了。 本篇文章为转载内容。原文链接:https://blog.csdn.net/qianglei6077/article/details/94379331。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-01-30 11:09:03
94
转载
JQuery插件下载
...otstrap框架的分页插件,它能够将一组同级元素轻松转换为分页或者标签页,从而让网站内容更加有序且易于浏览。无论您正在处理的是大量的文章列表、商品展示还是其他需要分页显示的内容,jquery.tabulation.js都能为您提供完美的解决方案。此插件的一大亮点在于其高度的自定义性和灵活性。开发人员可以通过简单的配置选项来调整分页的外观,以匹配不同网站的设计风格。同时,插件内置的回调函数允许用户在页面切换时执行特定的操作,比如更新数据或加载新的内容,极大地提升了用户体验。jquery.tabulation.js不仅代码轻量,而且运行流畅,可以显著提升网站性能。此外,其简洁明了的文档和丰富的示例代码使得即使是初学者也能快速上手,轻松集成到现有项目中。总之,jquery.tabulation.js是任何希望为其网站添加美观且实用分页功能的开发者不可或缺的工具。无论是为了提高用户体验,还是优化网站结构,这款插件都是您的理想选择。 点我下载 文件大小:46.31 KB 您将下载一个JQuery插件资源包,该资源包内部文件的目录结构如下: 本网站提供JQuery插件下载功能,旨在帮助广大用户在工作学习中提升效率、节约时间。 本网站的下载内容来自于互联网。如您发现任何侵犯您权益的内容,请立即告知我们,我们将迅速响应并删除相关内容。 免责声明:站内所有资源仅供个人学习研究及参考之用,严禁将这些资源应用于商业场景。 若擅自商用导致的一切后果,由使用者承担责任。
2025-01-12 21:13:23
101
本站
JQuery插件下载
...化,无需额外编写媒体查询或JavaScript代码,大大简化了开发过程。对于追求高性能的项目,JGallery同样表现出色。它采用延迟加载技术减少初始页面加载时间,并优化了资源使用效率,从而提升整体网站性能。同时,清晰的文档和示例代码使得学习和集成变得简单快捷,即使是前端新手也能快速上手。总之,JGallery凭借其强大的功能集、高度的可定制性和良好的兼容性,成为了构建响应式图片画廊的理想选择。无论是个人博客、电子商务平台还是企业官网,JGallery都是提升用户体验、增强品牌形象的有力工具。 点我下载 文件大小:621.38 KB 您将下载一个JQuery插件资源包,该资源包内部文件的目录结构如下: 本网站提供JQuery插件下载功能,旨在帮助广大用户在工作学习中提升效率、节约时间。 本网站的下载内容来自于互联网。如您发现任何侵犯您权益的内容,请立即告知我们,我们将迅速响应并删除相关内容。 免责声明:站内所有资源仅供个人学习研究及参考之用,严禁将这些资源应用于商业场景。 若擅自商用导致的一切后果,由使用者承担责任。
2024-11-15 11:07:33
57
本站
CSS
...播效果。例如上述代码示例中利用scroll-snap-type和scroll-snap-align属性,实现了滚动时元素自动吸附对齐,有效避免了滚动过程中的抖动和错位问题。 近期,各大主流浏览器如Chrome、Firefox和Safari均对CSS Scroll Snap功能提供了良好支持,这意味着更多用户将能够体验到这一流畅而高效的轮播效果。在实际应用中,设计师和开发者可以根据项目需求,结合JavaScript进行更复杂的交互控制,比如自定义动画过渡、触摸滑动切换等。 值得注意的是,为了保证不同设备和屏幕尺寸下的兼容性和显示效果,开发人员在实现横向铺满轮播图时还需关注响应式设计原则,运用媒体查询(Media Queries)调整轮播图在移动端或其他小屏设备上的布局和行为。 此外,随着Web性能优化理念的普及,如何在保证视觉效果的同时减少资源加载和渲染负担,也成为衡量一个优秀轮播图组件的重要指标。通过懒加载、预加载等技术手段,以及对图片大小、格式的合理选择,可以使CSS横向铺满轮播图在提升用户体验的同时,也能兼顾页面性能表现。
2023-01-15 14:17:14
469
算法侠
MySQL
...如命例如令例如提例如示例如符例如或例如者例如可例如视例如化例如工例如具例如来例如完例如成例如。例如这例如里例如以例如命例如令例如提例如示例如符例如为例如例例如:例如<例如/例如p例如>例如 例如<例如p例如r例如e例如>例如$例如 例如m例如y例如s例如q例如l例如 例如-例如u例如 例如r例如o例如o例如t例如 例如-例如p例如<例如/例如p例如r例如e例如>例如 例如<例如p例如>例如接例如着例如输例如入例如M例如y例如S例如Q例如L例如服例如务例如器例如的例如管例如理例如员例如密例如码例如,例如进例如入例如M例如y例如S例如Q例如L例如的例如命例如令例如提例如示例如符例如交例如互例如界例如面例如。例如<例如/例如p例如>例如 例如<例如p例如>例如然例如后例如,例如我例如们例如就例如可例如以例如创例如建例如一例如个例如新例如的例如数例如据例如库例如了例如。例如通例如过例如以例如下例如命例如令例如可例如以例如创例如建例如一例如个例如名例如为例如“例如m例如y例如d例如a例如t例如a例如b例如a例如s例如e例如”例如的例如数例如据例如库例如:例如<例如/例如p例如>例如 例如<例如p例如r例如e例如>例如m例如y例如s例如q例如l例如&例如g例如t例如;例如C例如R例如E例如A例如T例如E例如 例如D例如A例如T例如A例如B例如A例如S例如E例如 例如m例如y例如d例如a例如t例如a例如b例如a例如s例如e例如;例如<例如/例如p例如r例如e例如>例如 例如<例如p例如>例如在例如M例如y例如S例如Q例如L例如中例如,例如每例如个例如数例如据例如库例如都例如有例如自例如己例如的例如名例如称例如,例如用例如于例如唯例如一例如标例如识例如该例如数例如据例如库例如。例如在例如上例如面例如的例如命例如令例如中例如,例如我例如们例如使例如用例如了例如“例如C例如R例如E例如A例如T例如E例如 例如D例如A例如T例如A例如B例如A例如S例如E例如”例如语例如句例如来例如创例如建例如一例如个例如新例如的例如数例如据例如库例如,例如并例如指例如定例如了例如其例如名例如称例如为例如“例如m例如y例如d例如a例如t例如a例如b例如a例如s例如e例如”例如。例如<例如/例如p例如>例如 例如<例如p例如>例如现例如在例如,例如数例如据例如库例如已例如经例如被例如创例如建例如出例如来例如。例如我例如们例如可例如以例如使例如用例如以例如下例如命例如令例如来例如查例如看例如所例如有例如已例如经例如存例如在例如的例如数例如据例如库例如:例如<例如/例如p例如>例如 例如<例如p例如r例如e例如>例如m例如y例如s例如q例如l例如&例如g例如t例如;例如S例如H例如O例如W例如 例如D例如A例如T例如A例如B例如A例如S例如E例如S例如;例如<例如/例如p例如r例如e例如>例如 例如<例如p例如>例如这例如样例如就例如可例如以例如看例如到例如“例如m例如y例如d例如a例如t例如a例如b例如a例如s例如e例如”例如这例如个例如数例如据例如库例如出例如现例如在例如列例如表例如里例如了例如。例如<例如/例如p例如>例如 例如<例如p例如>例如至例如此例如,例如我例如们例如已例如经例如成例如功例如新例如建例如了例如一例如个例如M例如y例如S例如Q例如L例如数例如据例如库例如。例如希例如望例如能例如对例如学例如习例如和例如使例如用例如M例如y例如S例如Q例如L例如的例如朋例如友例如们例如有例如所例如帮例如助例如。例如<例如/例如p例如>例如
2023-08-12 18:53:34
138
码农
JQuery
...明,对于简单的DOM查询与操作,原生JavaScript在速度上已经不逊于甚至超越了许多流行的库(如jQuery),这鼓励更多开发者回归原生API以优化性能。同时,诸如Sizzle等独立的选择器引擎项目,不仅为jQuery提供支持,也能被其他库或框架集成,提高了跨平台和跨项目的兼容性及效率。 此外,考虑到现代浏览器对ES6及以上版本特性的广泛支持,如箭头函数、let/const声明以及模板字符串等,使得直接使用JavaScript进行DOM操作更为简洁高效。例如,利用“Node.matches()”方法配合CSS选择器,可以实现与jQuery类似的元素筛选功能,且具备良好的浏览器兼容性。 综上所述,尽管jQuery在简化DOM操作方面曾发挥巨大作用,但随着JavaScript生态的发展,理解和掌握原生API及其最佳实践已成为现代前端开发者的重要技能之一。了解和对比不同选择器方案的优缺点,并结合实际应用场景灵活运用,有助于我们构建更为快速、轻量级的Web应用。
2023-06-13 17:39:52
322
软件工程师
Java
...境。 3. java示例 这里用IKAnalyzer举例,IKAnalyzer的示例网上有很多,这里简要描述。 3.1 依赖下载 这里提供一个阿里云的仓库,你可以搜索并下载得到对应dependency的坐标并引入到你的pom.xml里面: 阿里云仓库:https://developer.aliyun.com/mvn/search <dependency> <groupId>com.janeluo</groupId> <artifactId>ikanalyzer</artifactId> <version>2012_u6</version> </dependency> 初次以外,你还要引入一个lucene的依赖: <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> <version>3.6.0</version> </dependency> 3.2 java代码 public static void cut(String text) throws IOException { List terms = new ArrayList(); try (StringReader sr = new StringReader(text)) { IKSegmenter ik = new IKSegmenter(sr, false); Lexeme lex = null; while ((lex = ik.next()) != null) { terms.add(lex.getLexemeText()); } } System.out.println(JSON.toJSONString(terms)); } 用main函数或你代码中的上游逻辑调用上述cut代码,即可输出分词结果。 3.3 加入新的词典 你需要在classpath下面引入IKAnalyzer的配置文件:IKAnalyzer.cfg.xml 并把上边下载好的词典引入进去,如下图: 3.4 切换分词模式 熟悉IKAnalyzer的朋友都知道它有两个分词模式:ik_max_word和ik_smart 在3.2的代码中可以用“new IKSegmenter(sr, false)”的第二个参数做切换,为true则是ik_smart,为false则是ik_max_word。 4. 效果对比测试 这里对下面两个字符串做分词效果测试: String text1 = "阿姆斯里克数据处理查询解析引擎"; String text2 = "基于java语言开发的轻量级的中文分词工具包"; 4.1 未引入新词典的分词效果 4.2 引入新词典的分词效果 上图可以看到,比如“查询解析引擎”、“中文分词工具包”这类的词已经被分词器切割出来了,这在没有新词典的情况下是无法完成的。 5. 补充说明 尽管该文章以IKAnalyzer为例,但是这个词典是通用的,它的格式是“词汇1\n词汇2\n词汇3\n”,即用回车符分隔的一个个词汇。很多分词器都是通用的。 文章是原创的,词典是站长整理的,如有转载,请注明出处,表示感谢!
2024-01-26 17:33:58
408
admin-tim
MySQL
...此处为一个添加记录的示例: $sql = "INSERT INTO students (name, age, gender, class) VALUES ('张三', 18, '男', '一班')"; if (mysqli_query($conn, $sql)) { echo "新条目成功添加"; } else { echo "错误信息: " . $sql . " " . mysqli_error($conn); } 其中,students指要添加记录的表格名称,name、age、gender、class分别指要添加记录的字段名称,后面的数据项分别为'张三'、18、'男'、'一班'。 最后,我们需要关闭接入: mysqli_close($conn); 通过上面的步骤,我们可以在MySQL中往明确字段里写入数据。
2023-06-05 22:29:31
72
算法侠
CSS
...SS3的@media查询功能,可以根据不同屏幕大小应用不同的CSS样式规则,确保网站在任何设备上都能提供最佳的视觉体验和交互性。 @media查询 , @media查询是CSS3中的一种条件语句,用于定义不同媒体类型和条件下的样式规则。在文章示例代码中,它被用来检测视口宽度,并据此应用相应的样式。例如,当屏幕宽度小于或等于480px时,将会应用一套特定的样式规则;而当屏幕宽度大于或等于768px时,则会切换到另一套样式规则,从而实现响应式设计的目的。 设备适应性 , 设备适应性是指网站或应用程序能够自动适应并优化在不同设备(如台式机、笔记本、平板电脑、手机等)上的显示效果和操作方式的能力。在本文所讨论的CSS响应式设计背景下,设备适应性意味着无论用户使用何种尺寸或类型的设备访问网站,都能获得良好的用户体验,包括清晰易读的文字、合理的布局结构以及符合设备特性的交互方式。通过运用CSS响应式设计技术,尤其是@media查询,可以实现对多种设备的良好适应性和兼容性。
2023-06-07 11:37:32
489
电脑达人
MySQL
...MySQL的替代品如PostgreSQL、MariaDB等数据库管理系统也在不断迭代发展,它们在特定场景下可能具备更优的性能或特性。因此,作为开发人员或IT管理员,在决定是否跟随MySQL最新版本更新,或者转向其他数据库系统时,应全面权衡技术选型、成本效益、团队技能储备等因素,并进行详尽的测试和评估。 总之,MySQL版本管理是持续的运维工作之一,理解不同版本的特点与变化趋势,结合实际应用场景制定合理的升级策略,将有助于提高系统的稳定性和应用的竞争力。
2023-10-03 21:22:15
106
软件工程师
MySQL
...登陆 MySQL 的示例脚本: mysql -h host -u user -p 其中, host 表示 MySQL 数据库服务器 IP 地址或服务器名称, user 是接入 MySQL 数据库所使用的账户名, -p 是要求输入口令,用于校验登陆。 接着,我们可以查看 MySQL 中当前所有的数据库,使用 的命令为: SHOW DATABASES; 然后,我们需要选择一个数据库进行操作,使用的命令为: USE database; 其中, database 表示需要操作的数据库名称。 现在,我们已经成功进入到了 MySQL 数据库中,可以看到库中的表格基本信息,使用命令如下: SHOW TABLES; 执行该命令后,MySQL 将会显示该库中所有的表名称。 最后,我们可以查看特定表中的所有信息,使用的命令如下: DESCRIBE table; 其中, table 表示需要查看的表名称。 通过上述基础操作,我们可以轻松地了解 MySQL 数据库中的基础表信息。
2023-08-18 09:15:20
62
算法侠
MySQL
... 上面的配置文件中的示例路径/var/run/mysqld/mysqld.sock就是 MySQL 的安装路径。除此之外,还可以通过以下命令来查看 MySQL 的安装路径: 切换到 MySQL 目录下 cd /usr/bin 查看当前目录下包含 mysqld 的文件,然后找到 mysqld 程序的绝对路径 find ./ -name mysqld 执行上述命令会返回 MySQL 的安装路径,如/usr/bin/mysqld。 总之,通过配置文件或 find 命令,可以很容易地找到 MySQL 在 Linux 上的安装路径。
2023-12-31 14:25:35
112
软件工程师
Element-UI
...件,支持排序、过滤、分页等功能,同时可以通过row-click事件监听行的点击事件。 然后,我们需要明白,要实现行的展开/收起效果,需要两个关键点:一是获取当前被点击的行数据;二是修改该行的状态,使其可以展示子内容。 三、解决方案 1. 获取当前被点击的行数据 通过el-table提供的row-click事件,我们可以轻松地获取到当前被点击的行数据。以下是一个简单的示例: html 2. 修改该行的状态,使其可以展示子内容 对于这个问题,我们需要自己添加一个状态变量,并且在row-click事件触发时更新这个状态变量。下面是一个简单的示例: html 四、总结 通过上述方法,我们成功实现了在Vue.js项目中使用Element-UI的el-table组件时,点击行任意位置都能实现展开/收起的效果。要特别留意的是,这里的“展开/收起”可不只是简单的藏起来露出来那么简单,关键得保证表头、表体这些部分都整整齐齐的,不能让人瞅见有啥突兀的蹦跶情况发生哈。如果对这个问题感兴趣,欢迎留言讨论,一起学习进步!
2023-10-23 16:53:41
404
青山绿水_t
VUE
...。下面是Vue实例的示例代码: new Vue({ el: 'app', data: { products: [ { name: '商品A', price: 100 }, { name: '商品B', price: 200 }, { name: '商品C', price: 300 } ] } }) 在这个示例中,我们构建了Vue实例,并将其关联到id为“app”的HTML元素上。我们还定义了一个名为“products”的数据字段,它是一个数组,用于保存商城列表中的商品信息。现在我们需要将这些数据渲染到页面。下面是HTML代码: <div id="app"> <ul> <li v-for="product in products"> { {product.name} } - { {product.price} } </li> </ul> </div> 在这个示例中,我们使用Vue.js的v-for指令,遍历products数组,并将每个元素渲染为li元素。我们还使用双大括号语法来展示商品名称和价格。现在我们已经构建了一个简单的商城列表,可以根据需要进行修改和定制。
2023-05-09 19:21:01
125
编程狂人
MySQL
...QL中插入记录命令的示例,将新的客户记录插入到名为“customers”的数据库表格内: INSERT 进入 customers (customer_name, contact_name, country)VALUES ('John Doe', 'Jane Smith', 'USA'); 使用这个语句,可以将客户姓名为“John Doe”,联系人为“Jane Smith”,国家为“USA”的数据插入到名为“customers”的数据表格内。 总结 MySQL中插入记录命令是一个非常有用的工具,在构建网络应用时经常需要使用到。熟练掌握它的格式和使用方法,可以帮助构建人员更高效地管理和使用MySQL数据库。
2023-09-26 10:25:10
67
编程狂人
MySQL
...提供SQL接口供用户查询、更新和管理数据。在本文语境下,MySQL是开发者需要导出其数据库结构及注释信息的主要操作对象。 mysqldump , mysqldump是MySQL自带的一个用于备份数据库的实用程序,它可以生成一个包含创建数据库表结构以及插入数据的SQL脚本文件。在文章中,mysqldump工具被用来执行导出MySQL数据库结构(包括注释)的操作,通过指定不同的参数可以控制是否包含数据或注释内容。 SQL结构 , SQL结构指的是使用SQL语言定义的数据库结构,它包括但不限于数据库、表、列、索引、视图等元素的定义以及它们之间的关系。在本文上下文中,SQL结构是指MySQL数据库中的表结构,包括表名、列名、数据类型、约束条件以及相关的注释信息,这些信息会被mysqldump命令以SQL语句的形式导出到一个文件中以便于迁移、备份或版本控制。 表结构注释 , 在MySQL数据库中,表结构注释是对表本身的一种描述性文本信息,可以通过特定的SQL语法添加至表定义中,为数据库使用者提供更多关于该表用途、字段含义等背景信息。在文章所讨论的场景中,表结构注释是希望在导出数据库结构时一并保留的重要内容,以方便其他开发者理解数据库设计意图和业务逻辑。 --skip-comments , 这是mysqldump工具的一个命令行选项,但在本文实际应用中应避免使用此选项,因为它的作用是跳过(忽略)在导出过程中遇到的所有注释信息。在文章给出的错误示例中,若要包含注释,则不应使用--skip-comments。
2023-03-21 16:29:33
108
电脑达人
HTML
分页功能 , 在网站开发中,分页功能是一种用户界面设计技术,用于将大量连续或相关的内容划分为多个独立的页面展示给用户。当数据量超过单个页面可以承载时,通过设置分页,用户可以点击不同的页码或者导航按钮来查看不同部分的数据,避免了加载时间过长和滚动浏览的不便,提高了用户体验与内容定位效率。 前端HTML分页组件 , 前端HTML分页组件是网页开发中的一种UI元素,它由HTML、CSS和JavaScript等前端技术构建而成,负责实现用户在网页上切换不同数据页面的功能。该组件通常包括一系列可点击的页码或导航按钮,以及可能的状态指示(如当前页数、总页数),在用户触发分页操作后,会通过AJAX请求后台服务器获取对应页面的数据,并在前端进行动态更新。 后台数据分页逻辑处理 , 在Web应用开发中,后台数据分页逻辑处理是指服务器端根据客户端(前端)传来的页码及每页显示记录数量等参数,从数据库中筛选并返回相应数据的过程。例如,当用户点击第3页的分页链接时,前端会发送一个包含页码信息的请求到后台,后台接收到请求后执行SQL查询语句,只取出第3页需要展示的数据,然后将这些数据以JSON或其他格式返回给前端,从而实现用户对海量数据的逐页浏览。这一过程涉及到了前后端数据交互、数据库查询优化等方面的技术细节。
2023-07-10 13:52:04
610
数据库专家
Apache Solr
...服务器进行交互,包括查询、索引、更新文档等操作。在本文示例代码中,HttpSolrClient被用来创建与Solr服务器的连接,并通过调用相应的方法来执行对Solr集群的操作,如创建集群等。
2023-05-23 17:55:59
497
落叶归根-t
MySQL
...ava读取MySQL示例中,开发者正是通过导入java.sql.包并利用JDBC API来建立到MySQL数据库的连接,执行SQL语句,并获取查询结果。 缓存技术 , 缓存技术是一种提升数据读取速度的方法,通常用于减少数据库负载并提高应用程序性能。例如,Memcached和Redis就是两种常用的内存键值存储系统,可作为数据库前级缓存使用。当应用程序需要频繁读取的数据时,可以从高速缓存而非数据库直接获取,从而避免了每次请求都直接访问数据库带来的延迟。在本文中,为了提高MySQL读取效率,作者建议可以引入缓存技术以加速数据访问过程。
2024-02-28 15:31:14
130
逻辑鬼才
VUE
...e应用程序中应用同步查询资料。 在Vue中,可以应用Axios库运行同步查询。Axios是一个基于Promise解决方案的HTTP客户端,具有易于应用的API和对诸如浏览器和Node.js等环境的兼容。 在Vue应用程序中,我们可以部署Axios库,然后应用它来取得资料。 npm install axios 部署成功后,我们需要在Vue实例化对象中引入Axios并应用它来运行同步查询。 在以下示例中,我们应用Axios从服务器取得JSON资料,并将其保存在Vue组件的data属性中。 import axios from 'axios' export default { name: 'MyComponent', data: function () { return { myData: null } }, created: function () { const self = this axios.get('/api/mydata') .then(function (response) { self.myData = response.data }) .catch(function (error) { console.log(error) }) } } 在上面的示例中,我们首先引入Axios库并将其保存在属性axios中。 我们然后建立了一个Vue组件,并在其data属性中定义了一个myData属性。 在Vue组件的created生命周期中,我们应用axios.get方法运行查询,并在响应返回时将资料保存在myData属性中。 在发生错误时,我们应用console.log方法记录错误日志。 现在,我们已经了解了如何在Vue应用程序中应用同步查询取得资料。 虽然同步查询对于简单的低资料量查询非常有用,但对于大型查询或需要更高性能的应用程序,请考虑应用异步查询。
2023-02-20 14:35:44
101
编程狂人
Java
...执行SQL语句、处理查询结果集以及进行事务管理等操作。在本文中,JDBC被用来连接MySQL数据库,并通过PreparedStatement对象执行SQL查询语句实现数据的升序或降序排列。 PreparedStatement , PreparedStatement是Java.sql包中的一个接口,它是JDBC API的一部分,用于预编译SQL语句并在其中填充参数。相比于简单的Statement对象,PreparedStatement能够提高SQL执行效率并增强安全性,因为它允许重复使用同一SQL模板,并且可以防止SQL注入攻击。在文章示例代码中,通过conn.prepareStatement(sql)创建PreparedStatement对象,并将包含排序条件的SQL语句传入,然后执行该预编译的查询语句以获取按指定字段排序的数据。 ResultSet , ResultSet是Java.sql包中的接口,表示数据库查询结果集。当通过PreparedStatement或Statement执行查询后,会返回一个ResultSet对象,它可以看作是一个指向数据库结果集的游标。通过调用其next()方法移动到下一行记录,并通过getXXX()系列方法获取当前行的各种类型数据。在给出的示例代码中,使用while循环遍历ResultSet中的每一行数据,并对每条记录进行相应的业务逻辑处理。
2023-08-17 09:50:12
327
数据库专家
JQuery
...名、端口号以及路径和查询字符串。 jQuery $.get() 方法 , jQuery库提供的一个简化 AJAX GET 请求的方法。$.get()允许开发者通过HTTP GET方式从服务器异步请求数据,并提供一个回调函数来处理服务器返回的数据。然而,在文章的上下文中,虽然示例使用了$.get()方法,但其实该方法并不适用于获取当前页面URL,因为这个信息可以直接通过window.location.href获取,无需发起HTTP请求。 Single Page Application (SPA) , 单页应用程序是一种Web应用模型,用户在浏览过程中只需加载一次网页(初始页面),后续的操作和内容更新都在同一页面内完成,而不会触发完整的页面刷新。History API中的history.pushState()等方法对于SPA应用尤其重要,因为它使得开发者能够动态改变浏览器地址栏中的URL,同时保持页面状态的连续性和导航历史记录的完整性,从而模拟多页面应用的用户体验。
2023-01-20 12:04:33
353
海阔天空_t
站内搜索
用于搜索本网站内部文章,支持栏目切换。
知识学习
实践的时候请根据实际情况谨慎操作。
随机学习一条linux命令:
head -n 10 file.txt
- 查看文件前10行。
推荐内容
推荐本栏目内的其它文章,看看还有哪些文章让你感兴趣。
2023-04-28
2023-08-09
2023-06-18
2023-04-14
2023-02-18
2023-04-17
2024-01-11
2023-10-03
2023-09-09
2023-06-13
2023-08-07
2023-03-11
历史内容
快速导航到对应月份的历史文章列表。
随便看看
拉到页底了吧,随便看看还有哪些文章你可能感兴趣。
时光飞逝
"流光容易把人抛,红了樱桃,绿了芭蕉。"