docker安装Postgres-XL集群及踩过的N个坑

说明:本文是在一个机器内部用docker创建了三台centos,然后构建的pgxl集群

文章目录

    • 1. 学习docker
    • 2. 创建三台centos
    • 3. 安装SSH
    • 4. 创建新用户postgres
    • 5. 关闭防火墙 关闭selinux
    • 6. 配置免密登录
    • 7. 下载并传输Postgres-XL的源码
    • 8. 配置环境变量
    • 10. 安装
    • 11. 连接数据库

1. 学习docker

推荐B站的黑马程序员的视频
2023.9的哔哩哔哩视频
2019.9的哔哩哔哩视频

2. 创建三台centos

查看本机IP的命令
hostname -I
查看主机名的命令 
hostname
  1. 在docker中创建netWork
sudo docker network create 网络名

在这里插入图片描述

  1. 创建centos的命令
    为什么这么长,因为都是踩过的坑

–network pgxlNet 是为了创建的容器都在一个网段内,这样三个容器可以互相Ping通,而且IP按照创建容器的先后顺序分配,后续不关停容器的话IP地址不变
–privilege=true 是为了用参数赋予容器特权,否则创建出来的centos类似systemctl之类的命令不能使用
–hostname gtm 是为了将创建出来的centos的主机名设置为 gtm。一般情况下后续可以通过命令或者修改配置文件等方式修改主机名,但是通过docker创建出来的容器不可以,所以需要在一开始创建的时候指定
启动命令需要是 /usr/sbin/init

sudo docker run -itd --network 网络名 --hostname 主机名 --privileged=true --name 容器名 镜像名:版本 /usr/sbin/init

在这里插入图片描述
3. 进入容器

sudo docker exec -it 容器名 /bin/bash

在这里插入图片描述

  1. 修改etc/hosts文件
    vim /etc/hosts 或者 vi /etc/hosts
    然后在文件里添加下面的内容,三个容器都要操作
    在这里插入图片描述

  2. 综上所述,创建三个容器和进入三个容器的命令

sudo docker network create pgclNet

sudo docker run -itd --network pgxlNet --hostname gtm --privileged=true --name gtm centos:latest /usr/sbin/init
sudo docker run -itd --network pgxlNet --hostname datanode1 --privileged=true --name datanode1 centos:latest /usr/sbin/init
sudo docker run -itd --network pgxlNet --hostname datanode2 --privileged=true --name datanode2 centos:latest /usr/sbin/init

sudo docker exec -it gtm /bin/bash
sudo docker exec -it datanode1 /bin/bash
sudo docker exec -it datanode2 /bin/bash

3. 安装SSH

  1. 安装ssh之前,我们要先为root用户配置密码,因为后续切换回root用户时需要输入密码
passwd

回车输入密码即可,验证密码有无输入成功用ssh连接一下然后输入密码,看看能不能连接上就知道了

  1. 如果安装ssh时出现报错。No URLs in mirrorlist。则运行下面的代码或者看博客
    别人的博客,如果有侵权马上删除
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
yum makecache
yum update -y
  1. 安装ssh
yum install openssh-server -y
yum install openssh-clients -y
service sshd restart
如果出现bash:service: command not found
yum install initscripts -y

4. 创建新用户postgres

为什么要创建新用户,在root用户下操作行不行? 不行。如果在root用户下安装,那么最后会发现,数据库无法初始化,无法启动,无法使用。因为postgre要求不能再root用户下操作,所以需要创建新的用户。切记切记

useradd 用户名
passwd 用户名
然后输入密码就是这个用户的密码了

在这里插入图片描述
切换用户
注意 - 的前后都有一个空格

su - 用户名

5. 关闭防火墙 关闭selinux

docker创建的centos容器没有这些东西,所以这一步可以省略了。也可以自己验证一下,我这里时没有的。

6. 配置免密登录

注意,不仅要配置gtm到datanode1和datanode2的免密登录,还需要配置,gtm到gtm本身的免密登录
注意,要在postgres用户下配置。我现在root用户下配置了免密登录,发现不行。postgres用户下也要配置免密登录才行

  1. postgres用户不能使用sudo的解决办法
    报错:postgres is not in the sudoers file. This incident will be reported
    解决办法:
su - root 切换回root用户
vi /etc/sudoers
然后在 root ALL=(ALL) ALL 这一行下面加上一行
postgres ALL=(ALL) ALL
注意:退出时用 wq!

在这里插入图片描述
2. 配置免密登录的两个大坑,文件夹权限和属主问题。分别对应的命令时 chmod 和 chown 。查看的命令时 ls -al 文件/文件夹/啥也不带

切换到postgres用户
su - postgres
mkdir /home/postgres/.ssh 出现报错权限不足。
回到上级目录
sudo chmod -R 777 /home
mkdir /home/postgres/.ssh

修改权限和属主

修改权限和属主
sudo chmod 755 /home/postgres
chmod 700 /home/postgres/.ssh/
chmod 600 /home/postgres/.ssh/authorized_keys
chown postgres:postgres .. (把文件 .. 的owner从root改为postgres)

注意:修改属主这里不是一定的,要根据自己的情况看。命令就是 ls -al
属主,就是文件所属的用户,可以从图中看到 … 这里的属主是root不对劲,所以我将其改成了postgres。后来我为了方便,直接改了父文件将文件都改成了postgres用户的

chown -R postgres:postgres 文件夹名字

在这里插入图片描述
3. 配置免密登录
本文中的操作没有特别注明,基本都是在三个容器都需要操作的,只有下面的者四行命令命令只在gtm节点操作就可以了

ssh-keygen -t rsa  有三处需要输入的地方,全部enter键即可
ssh-copy-id 用户名@datanode1的IP
ssh-copy-id 用户名@datanode2的IP
ssh-copy-id 用户名@gtm的IP

下面这个是在root用户下配置免密登录的截图,postgres用户下的配置和这个一样。(在postgres用户下配置就可以)
在这里插入图片描述
在这里插入图片描述

7. 下载并传输Postgres-XL的源码

下载地址
https://www.postgres-xl.org/download/
下载地址
在这里插入图片描述

传输命令

scp 文件 服务器的用户名@IP:服务器上文件地址

也可以搜索专门的docker和宿主机之间传输文件的命令

8. 配置环境变量

  1. 解压缩
在home路径下 mkdir postgres
tar xf postgre........tar.gz -C /home/postgres
  1. 创建目录
#创建配置文件目录(所有节点,本文中的操作,大部分都是需要在三个节点都完成的)
mkdir -p /home/pg/pgxl
mkdir -p /home/pg/pgxc/nodes
mkdir -p /home/postgres/pgxc/conf
  1. 配置环境变量
vim /home/postgres/.bashrc 
export PGHOME=/home/pg/pgxl
export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
export PATH=$PGHOME/bin:$PATH
export PGUSER=postgres
export PGXC_CTL_HOME=/home/pg/pgxl/bin 
source /home/postgres/.bashrc 

如果修改后不能保存,就修改文件所属的权限。
chown -R postgres:postgres 文件夹名字
ls -al 查看文件属主等信息 

图片中的root应该为postgres
在这里插入图片描述

10. 安装

yum install -y gcc zlib zlib-devel readline readline-devel flex
yum -y install gcc automake autoconf libtool make

cd /home/postgres/postgres-xl-10r1.1
./configure --prefix=/home/pg/pgxl
make -j4
make install 
cd /home/postgres/postgres-xl-10r1.1/contrib
make -j4
make install

生成文件pxc_ctl.conf文件
pgxc
根据提示找到pxc_ctl.conf文件的位置,然后复制文件
cp 源文件 目的文件地址
修改pgxc_ctl.conf文件
我将pgxc_ctl.conf文件放到了 /home/postgres/pgxc/conf下面,注意要记住这个地址,因为后续开启数据库的时候要用到这个地址

修改配置文件,只需要修改里面的IP地址和节点数目就可以了
我是参考下面两篇博客修改的,需要注意的是其中cidr表示的地址哪里需要填自己的网段,剩下的就是把IP换成自己的IP即可
博客1 如有侵权请联系马上删除
博客2 如有侵权请联系马上删除


pgxcInstallDir=$HOME/pgxc
#---- OVERALL -----------------------------------------------------------------------------
#
pgxcOwner=$USER			# owner of the Postgres-XC databaseo cluster.  Here, we use this
						# both as linus user and database user.  This must be
						# the super user of each coordinator and datanode.
pgxcUser=$pgxcOwner		# OS user of Postgres-XC owner

tmpDir=/tmp					# temporary dir used in XC servers
localTmpDir=$tmpDir			# temporary dir used here locally

configBackup=n					# If you want config file backup, specify y to this value.
configBackupHost=pgxc-linker	# host to backup config file
configBackupDir=$HOME/pgxc		# Backup directory
configBackupFile=pgxc_ctl.bak	# Backup file name --> Need to synchronize when original changed.

#---- GTM ------------------------------------------------------------------------------------

# GTM is mandatory.  You must have at least (and only) one GTM master in your Postgres-XC cluster.
# If GTM crashes and you need to reconfigure it, you can do it by pgxc_update_gtm command to update
# GTM master with others.   Of course, we provide pgxc_remove_gtm command to remove it.  This command
# will not stop the current GTM.  It is up to the operator.


#---- GTM Master -----------------------------------------------

#---- Overall ----
gtmName=gtm
gtmMasterServer=172.18.0.2
gtmMasterPort=20001
gtmMasterDir=$HOME/pgxc/nodes/gtm

#---- Configuration ---
gtmExtraConfig=none			# Will be added gtm.conf for both Master and Slave (done at initilization only)
gtmMasterSpecificExtraConfig=none	# Will be added to Master's gtm.conf (done at initialization only)

#---- GTM Slave -----------------------------------------------

# Because GTM is a key component to maintain database consistency, you may want to configure GTM slave
# for backup.

#---- Overall ------
gtmSlave=n					# Specify y if you configure GTM Slave.   Otherwise, GTM slave will not be configured and
							# all the following variables will be reset.
gtmSlaveName=gtmSlave
gtmSlaveServer=node12		# 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=$HOME/pgxc/nodes/gtm	# Not used if you don't configure GTM slave.
# Please note that when you have GTM failover, then there will be no slave available until you configure the slave
# again. (pgxc_add_gtm_slave function will handle it)

#---- Configuration ----
gtmSlaveSpecificExtraConfig=none # Will be added to Slave's gtm.conf (done at initialization only)

#---- GTM Proxy -------------------------------------------------------------------------------------------------------
# GTM proxy will be selected based upon which server each component runs on.
# When fails over to the slave, the slave inherits its master's gtm proxy.  It should be
# reconfigured based upon the new location.
#
# To do so, slave should be restarted.   So pg_ctl promote -> (edit postgresql.conf and recovery.conf) -> pg_ctl restart
#
# You don't have to configure GTM Proxy if you dont' configure GTM slave or you are happy if every component connects
# to GTM Master directly.  If you configure GTL slave, you must configure GTM proxy too.

#---- Shortcuts ------
gtmProxyDir=$HOME/pgxc/nodes/gtm_pxy

#---- Overall -------
gtmProxy=y				# Specify y if you conifugre at least one GTM proxy.   You may not configure gtm proxies
						# only when you dont' configure GTM slaves.
						# If you specify this value not to y, the following parameters will be set to default empty values.
						# If we find there're no valid Proxy server names (means, every servers are specified
						# as none), then gtmProxy value will be set to "n" and all the entries will be set to
						# empty values.
gtmProxyNames=(gtm_pxy1 gtm_pxy2)	# No used if it is not configured
gtmProxyServers=(172.18.0.3 172.18.0.4)			# Specify none if you dont' configure it.
gtmProxyPorts=(20001 20001)				# Not used if it is not configured.
gtmProxyDirs=($gtmProxyDir $gtmProxyDir)	# Not used if it is not configured.

#---- Configuration ----
gtmPxyExtraConfig=none		# Extra configuration parameter for gtm_proxy.  Coordinator section has an example.
gtmPxySpecificExtraConfig=(none none)

#---- Coordinators ----------------------------------------------------------------------------------------------------

#---- shortcuts ----------
coordMasterDir=$HOME/pgxc/nodes/coord
coordSlaveDir=$HOME/pgxc/nodes/coord_slave
coordArchLogDir=$HOME/pgxc/nodes/coord_archlog

#---- Overall ------------
coordNames=(coord1 coord2)		# Master and slave use the same name
coordPorts=(20004 20005)			# Master ports
poolerPorts=(20010 20011)			# Master pooler ports
coordPgHbaEntries=(172.18.0.0/24)				# Assumes that all the coordinator (master/slave) accepts
												# the same connection
												# This entry allows only $pgxcOwner to connect.
												# If you'd like to setup another connection, you should
												# supply these entries through files specified below.
# Note: The above parameter is extracted as "host all all 0.0.0.0/0 trust".   If you don't want
# such setups, specify the value () to this variable and suplly what you want using coordExtraPgHba
# and/or coordSpecificExtraPgHba variables.
#coordPgHbaEntries=(::1/128)	# Same as above but for IPv6 addresses

#---- Master -------------
coordMasterServers=(172.18.0.3 172.18.0.4)		# none means this master is not available
coordMasterDirs=($coordMasterDir $coordMasterDir )
coordMaxWALsernder=5	# max_wal_senders: needed to configure slave. If zero value is specified,
						# it is expected to supply this parameter explicitly by external files
						# specified in the following.	If you don't configure slaves, leave this value to zero.
coordMaxWALSenders=($coordMaxWALsernder $coordMaxWALsernder)
						# max_wal_senders configuration for each coordinator.

#---- Slave -------------
coordSlave=n			# Specify y if you configure at least one coordiantor slave.  Otherwise, the following
						# configuration parameters will be set to empty values.
						# If no effective server names are found (that is, every servers are specified as none),
						# then coordSlave value will be set to n and all the following values will be set to
						# empty values.

coordUserDefinedBackupSettings=n	# Specify whether to update backup/recovery
									# settings during standby addition/removal.

coordSlaveSync=y		# Specify to connect with synchronized mode.
coordSlaveServers=(172.18.0.3 172.18.0.4)			# none means this slave is not available
coordSlavePorts=(20004 20005)			# Master ports
coordSlavePoolerPorts=(20010 20011)			# Master pooler ports
coordSlaveDirs=($coordSlaveDir $coordSlaveDir)
coordArchLogDirs=($coordArchLogDir $coordArchLogDir)

#---- Configuration files---
# Need these when you'd like setup specific non-default configuration 
# These files will go to corresponding files for the master.
# You may supply your bash script to setup extra config lines and extra pg_hba.conf entries 
# Or you may supply these files manually.
coordExtraConfig=coordExtraConfig	# Extra configuration file for coordinators.  
						# This file will be added to all the coordinators'
						# postgresql.conf
# Pleae note that the following sets up minimum parameters which you may want to change.
# You can put your postgresql.conf lines here.
cat > $coordExtraConfig <<EOF
#================================================
# Added to all the coordinator postgresql.conf
# Original: $coordExtraConfig
log_destination = 'stderr'
logging_collector = on
log_directory = 'pg_log'
listen_addresses = '*'
max_connections = 100
EOF

# Additional Configuration file for specific coordinator master.
# You can define each setting by similar means as above.
coordSpecificExtraConfig=(none none)
coordExtraPgHba=none	# Extra entry for pg_hba.conf.  This file will be added to all the coordinators' pg_hba.conf
coordSpecificExtraPgHba=(none none none none)

#----- Additional Slaves -----
#
# Please note that this section is just a suggestion how we extend the configuration for
# multiple and cascaded replication.   They're not used in the current version.
#
coordAdditionalSlaves=n		# Additional slave can be specified as follows: where you
coordAdditionalSlaveSet=(cad1)		# Each specifies set of slaves.   This case, two set of slaves are
											# configured
cad1_Sync=n		  		# All the slaves at "cad1" are connected with asynchronous mode.
							# If not, specify "y"
							# The following lines specifies detailed configuration for each
							# slave tag, cad1.  You can define cad2 similarly.
cad1_Servers=(node08 node09 node06 node07)	# Hosts
cad1_dir=$HOME/pgxc/nodes/coord_slave_cad1
cad1_Dirs=($cad1_dir $cad1_dir $cad1_dir $cad1_dir)
cad1_ArchLogDir=$HOME/pgxc/nodes/coord_archlog_cad1
cad1_ArchLogDirs=($cad1_ArchLogDir $cad1_ArchLogDir $cad1_ArchLogDir $cad1_ArchLogDir)


#---- Datanodes -------------------------------------------------------------------------------------------------------

#---- Shortcuts --------------
datanodeMasterDir=$HOME/pgxc/nodes/dn_master
datanodeSlaveDir=$HOME/pgxc/nodes/dn_slave
datanodeArchLogDir=$HOME/pgxc/nodes/datanode_archlog

#---- Overall ---------------
#primaryDatanode=datanode1				# Primary Node.
# At present, xc has a priblem to issue ALTER NODE against the primay node.  Until it is fixed, the test will be done
# without this feature.
primaryDatanode=datanode1				# Primary Node.
datanodeNames=(datanode1 datanode2)
datanodePorts=(20008 20009)	# Master ports
datanodePoolerPorts=(20012 20013)	# Master pooler ports
datanodePgHbaEntries=(172.18.0.0/24)	# Assumes that all the coordinator (master/slave) accepts
										# the same connection
										# This list sets up pg_hba.conf for $pgxcOwner user.
										# If you'd like to setup other entries, supply them
										# through extra configuration files specified below.
# Note: The above parameter is extracted as "host all all 0.0.0.0/0 trust".   If you don't want
# such setups, specify the value () to this variable and suplly what you want using datanodeExtraPgHba
# and/or datanodeSpecificExtraPgHba variables.
#datanodePgHbaEntries=(::1/128)	# Same as above but for IPv6 addresses

#---- Master ----------------
datanodeMasterServers=(172.18.0.3 172.18.0.4)	# none means this master is not available.
													# This means that there should be the master but is down.
													# The cluster is not operational until the master is
													# recovered and ready to run.	
datanodeMasterDirs=($datanodeMasterDir $datanodeMasterDir)
datanodeMaxWalSender=5								# max_wal_senders: needed to configure slave. If zero value is 
													# specified, it is expected this parameter is explicitly supplied
													# by external configuration files.
													# If you don't configure slaves, leave this value zero.
datanodeMaxWALSenders=($datanodeMaxWalSender $datanodeMaxWalSender)
						# max_wal_senders configuration for each datanode

#---- Slave -----------------
datanodeSlave=n			# Specify y if you configure at least one coordiantor slave.  Otherwise, the following
						# configuration parameters will be set to empty values.
						# If no effective server names are found (that is, every servers are specified as none),
						# then datanodeSlave value will be set to n and all the following values will be set to
						# empty values.

datanodeUserDefinedBackupSettings=n	# Specify whether to update backup/recovery
									# settings during standby addition/removal.

datanodeSlaveServers=(172.18.0.3 172.18.0.4)	# value none means this slave is not available
datanodeSlavePorts=(20008 20009)	# value none means this slave is not available
datanodeSlavePoolerPorts=(20012 2001)	# value none means this slave is not available
datanodeSlaveSync=y		# If datanode slave is connected in synchronized mode
datanodeSlaveDirs=($datanodeSlaveDir $datanodeSlaveDir)
datanodeArchLogDirs=( $datanodeArchLogDir $datanodeArchLogDir )

# ---- Configuration files ---
# You may supply your bash script to setup extra config lines and extra pg_hba.conf entries here.
# These files will go to corresponding files for the master.
# Or you may supply these files manually.
datanodeExtraConfig=none	# Extra configuration file for datanodes.  This file will be added to all the 
							# datanodes' postgresql.conf
datanodeSpecificExtraConfig=(none none)
datanodeExtraPgHba=none		# Extra entry for pg_hba.conf.  This file will be added to all the datanodes' postgresql.conf
datanodeSpecificExtraPgHba=(none none)

#----- Additional Slaves -----
datanodeAdditionalSlaves=n	# Additional slave can be specified as follows: where you
# datanodeAdditionalSlaveSet=(dad1 dad2)		# Each specifies set of slaves.   This case, two set of slaves are
											# configured
# dad1_Sync=n		  		# All the slaves at "cad1" are connected with asynchronous mode.
							# If not, specify "y"
							# The following lines specifies detailed configuration for each
							# slave tag, cad1.  You can define cad2 similarly.
# dad1_Servers=(node08 node09 node06 node07)	# Hosts
# dad1_dir=$HOME/pgxc/nodes/coord_slave_cad1
# dad1_Dirs=($cad1_dir $cad1_dir $cad1_dir $cad1_dir)
# dad1_ArchLogDir=$HOME/pgxc/nodes/coord_archlog_cad1
# dad1_ArchLogDirs=($cad1_ArchLogDir $cad1_ArchLogDir $cad1_ArchLogDir $cad1_ArchLogDir)

#---- WAL archives -------------------------------------------------------------------------------------------------
walArchive=n	# If you'd like to configure WAL archive, edit this section.
				# Pgxc_ctl assumes that if you configure WAL archive, you configure it
				# for all the coordinators and datanodes.
				# Default is "no".   Please specify "y" here to turn it on.
#
#		End of Configuration Section
#
#==========================================================================================================================

#========================================================================================================================
# The following is for extension.  Just demonstrate how to write such extension.  There's no code
# which takes care of them so please ignore the following lines.  They are simply ignored by pgxc_ctl.
# No side effects.
#=============<< Beginning of future extension demonistration >> ========================================================
# You can setup more than one backup set for various purposes, such as disaster recovery.
walArchiveSet=(war1 war2)
war1_source=(master)	# you can specify master, slave or ano other additional slaves as a source of WAL archive.
					# Default is the master
wal1_source=(slave)
wal1_source=(additiona_coordinator_slave_set additional_datanode_slave_set)
war1_host=node10	# All the nodes are backed up at the same host for a given archive set
war1_backupdir=$HOME/pgxc/backup_war1
wal2_source=(master)
war2_host=node11
war2_backupdir=$HOME/pgxc/backup_war2
#=============<< End of future extension demonistration >> ========================================================

11. 连接数据库

其中文件路径那里是方式刚才的pgxc_ctl.conf文件的路径
在连接数据库时,IP是协调节点的IP,端口也是,你可以对照刚才的conf文件看一下

始化数据库
pgxc_ctl -c /home/postgres/pgxc/conf/pgxc_ctl init all
启动数据库
pgxc_ctl -c /home/postgres/pgxc/conf/pgxc_ctl start all
连接数据库
psql -h 172.18.0.3 --port=20004 -U postgres -d postgres
退出数据
\q

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/226196.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

动态规划学习——最长回文子序列,让字符串变成回文串的最小插入次数

一&#xff0c;最长回文串 1.题目 给你一个字符串 s &#xff0c;找出其中最长的回文子序列&#xff0c;并返回该序列的长度。 子序列定义为&#xff1a;不改变剩余字符顺序的情况下&#xff0c;删除某些字符或者不删除任何字符形成的一个序列。 示例 1&#xff1a; 输入&…

视频剪辑实战:如何制作具有吸引力的画中画视频,批量剪辑技巧

随着社交媒体的兴起&#xff0c;视频制作已经成为一项重要的技能。在众多视频制作软件中&#xff0c;画中画视频备受瞩目。这种视频格式允许在同一个画面中展示两个或多个视频&#xff0c;使视频更具吸引力和创新性。这篇文章中&#xff0c;将讲解云炫AI智剪如何制作具有吸引力…

微三云胡佳东谈消费增值:重塑经济模式的未来趋势

消费增值&#xff1a;重塑经济模式的未来趋势 在当前的全球经济环境下&#xff0c;消费增值的概念正逐渐受到广泛的关注。这一模式的崛起&#xff0c;不仅仅是一种商业模式的创新&#xff0c;更代表着我们对经济运行的理解和探索在不断深化。本文将探讨消费增值模式的内涵&…

激光炸弹(二维前缀和)-Java版

import java.io.*;/** 题目分析:一个最大5000 * 5000 的矩阵, 爆炸范围在 [0,10e9]* 地图上的目标是随机分布,如果要暴力计算每一个区间R的权值,会很麻烦* 可以用二维前缀和先将权值存起来* for(int i 1;i < n;i ) {for(int j 1;j < m;j ) {g[i][j] g[i][j-1] g[i-1]…

Ubuntu宝塔面板本地部署Emlog个人博客网站并远程访问【内网穿透】

文章目录 前言1. 网站搭建1.1 Emolog网页下载和安装1.2 网页测试1.3 cpolar的安装和注册 2. 本地网页发布2.1 Cpolar临时数据隧道2.2.Cpolar稳定隧道&#xff08;云端设置&#xff09;2.3.Cpolar稳定隧道&#xff08;本地设置&#xff09; 3. 公网访问测试总结 前言 博客作为使…

PostgreSQL 技术内幕(十二) CloudberryDB 并行化查询之路

随着数据驱动的应用日益增多&#xff0c;数据查询和分析的量级和时效性要求也在不断提升&#xff0c;对数据库的查询性能提出了更高的要求。为了满足这一需求&#xff0c;数据库引擎不断经历创新&#xff0c;其中并行执行引擎是性能提升的重要手段之一&#xff0c;逐渐成为数据…

openGauss学习笔记-147 openGauss 数据库运维-备份与恢复-逻辑备份与恢复之gs_dump

文章目录 openGauss学习笔记-147 openGauss 数据库运维-备份与恢复-逻辑备份与恢复之gs_dump147.1 背景信息147.2 注意事项147.3 语法147.4 参数说明147.4.1 通用参数&#xff1a;147.4.2 转储参数&#xff1a;147.4.3 连接参数&#xff1a; 147.5 说明147.6 示例 openGauss学习…

List的元素覆盖问题

问题场景 在备课底层JDBC链接链接数据库时&#xff0c;将读取的数据封装到对象中并添加到list集合中出现了问题。 错误逻辑 代码编写的考量为减少对象占用内存。想通过一个对象完成数据的传递和保存。 核心问题 List集合存储的是每一个对象的引用地址&#xff0c;如果引用的…

如何选择合适水下应用的集成电缆传感器?

来源&#xff1a;宏集科技 工业物联网丨宏集干货 | 如何选择合适水下应用的集成电缆传感器&#xff1f; 原文链接&#xff1a;https://mp.weixin.qq.com/s/wbN40niOgpUHy1iSH9Ad3Q 欢迎关注虹科&#xff0c;为您提供最新资讯&#xff01; 前言 许多工业过程都要求将传感器浸…

如何使用技术 SEO 优化 Pinterest 富图钉

Pinterest 可以影响搜索引擎排名&#xff0c;尤其是谷歌。不过&#xff0c;它的作用方式与其他搜索引擎优化因素不同。这就是 Google 将图钉放在 nofollow 列表中。但是&#xff0c;它们仍然可以作为搜索引擎优化的一个重要因素。 高质量的图钉具有高分辨率的图片、吸引人的内…

mybatis入门

Java的三大框架&#xff1a;Spring&#xff0c;SpringMVC,MyBatis 框架其实就是对通用代码的封装&#xff0c;提前写好了一堆接口和类&#xff0c;我们可以在做项目的时候直接引入这些接口和类&#xff0c;基于这些现有的接口和类进行开发&#xff0c;可以大大提高开发效率 J…

【网络编程】-- 01 概述、IP

网络编程 1 概述 1.1 计算机网络 (连接分散计算机设备以实现信息传递的系统) 计算机网络是指将地理位置不同的具有独立功能的多台计算机及其外部设备&#xff0c;通过通信线路连接起来&#xff0c;在网络操作系统&#xff0c;网络管理软件及网络通信协议的管理和协调下&…

SmartChart:一站式数据可视化解决方案

在当今的数据驱动的世界中&#xff0c;数据可视化已经成为了一个重要的工具&#xff0c;它可以帮助我们理解复杂的数据集&#xff0c;并从中提取有价值的信息。SmartChart就是这样一个强大的数据可视化工具&#xff0c;它提供了一站式的数据可视化解决方案&#xff0c;无论你是…

(十五)Flask覆写wsgi_app函数实现自定义中间件

中间件 一、剖析&#xff1a; 在前面讲session部分提到过&#xff1a;请求一进来&#xff0c;Flask会自动调用应用程序对象【Flask(__name__)】的__call__方法&#xff0c;这个方法负责处理请求并返回响应&#xff08;其实如下图&#xff1a;其内部就是wsgi_app方法&#xff…

【重磅来袭!!!工程师必备初始化建工程软件】

重磅来袭&#xff01;&#xff01;&#xff01;工程师必备初始化软件 每个工程建立前&#xff0c;你是否为了要建立各种文件夹而烦恼&#xff1f;你是否为了因为工程每次文件夹不统一找不到文件而烦扰&#xff1f;来咯&#xff0c;Project Initial V1_0软件只需输入工程名称&am…

安装you-get(mac)

1、首先要有python环境 2、更新pip python -m pip install --upgrade pip 3、安装you-get pip install you-get;

keep-alive 是 Vue 的一个内置组件,用于缓存其他组件的实例,以避免重复渲染和销毁,它可以在需要频繁切换的组件之间提供性能优化

目录 keep-alive 使用 keep-alive 的示例代码&#xff1a; 手动清除组件缓存的示例代码&#xff1a; keep-alive 组件有以下几个优点&#xff1a; keep-alive 的原理&#xff1a; 使用 keep-alive 组件&#xff0c;你可以包裹需要缓存的组件&#xff0c;然后这些组件在切…

基于ssm安徽新华学院实验中心管理系统论文

摘 要 本安徽新华学院实验中心管理系统的设计目标是实现安徽新华学院实验中心的信息化管理&#xff0c;提高管理效率&#xff0c;使得安徽新华学院实验中心管理工作规范化、科学化、高效化。 本文重点阐述了安徽新华学院实验中心管理系统的开发过程&#xff0c;以实际运用为开…

Pytest+Allure生成自动化测试报告!

前言 在自动化测试中&#xff0c;有unittestHTMLTestRunner自动化测试报告&#xff0c;但是生成的测试报告不够美观详细&#xff0c;今天我们来学习一下PytestAllure生成自动化测试报告。 一&#xff1a;安装python中的allure依赖库 在dos窗口中&#xff0c;输入下面三个命令…

AntDesignBlazor示例——创建查询条件

本示例是AntDesign Blazor的入门示例&#xff0c;在学习的同时分享出来&#xff0c;以供新手参考。 示例代码仓库&#xff1a;https://gitee.com/known/AntDesignDemo 1. 学习目标 重构项目文件结构添加日期查询条件实现查询业务逻辑 2. 重构项目结构 在实现列表查询条件功…