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 pgclNetsudo 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/initsudo 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 makecd /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 ownertmpDir=/tmp					# temporary dir used in XC servers
localTmpDir=$tmpDir			# temporary dir used here locallyconfigBackup=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

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

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【每日一题】1466. 重新规划路线-2023.12.7

题目: 1466. 重新规划路线 n 座城市,从 0 到 n-1 编号,其间共有 n-1 条路线。因此,要想在两座不同城市之间旅行只有唯一一条路线可供选择(路线网形成一颗树)。去年,交通运输部决定重新规划路线,以改变交通拥堵的状况。 路线用 connections 表示,其中 connections[i…

华为鸿蒙技术——应用程序包

文章目录 一、应用程序包二、应用程序包结构1、Stage模型应用程序包结构2、FA模型应用程序包结构 三、HAP四、多HAP机制1、多HAP构建视图&#xff08;1&#xff09;开发者视图目录&#xff08;2&#xff09;编译后视图 一、应用程序包 用户应用程序泛指运行在设备的操作系统之…

mysql 5.7 Unknown column ‘password‘ in ‘field list‘

问题现象&#xff1a; 执行sql : select user&#xff0c;host,password from user&#xff1b;时提示 ERROR 1054(42S22):Unknown column password in field list 现象如下图所示&#xff1a; mysql 5.7开始 密码字段用&#xff1a;authentication_string

智慧物流管理系统 砼行APP,不止于配套手机端

说起搅拌站管理软件的手机端&#xff0c;很多人对它的印象还停留在配套APP上。没事的时候打开看看生产相关数据&#xff0c;用之无味&#xff0c;弃之也不可惜。 这和软件服务商对产品的定位相关&#xff0c;“就是个配套移动端”、“能看数据就行”、“买ERP给你送手机端”渐渐…

【问题思考】泰勒公式证明题如何选展开点?【对称美】

我的证明题水平很烂&#xff0c;这个纯属让自己有一个初步的理解&#xff0c;恳请指正&#xff01; 问题 我们可以看到这里有两种展开方式&#xff08;注意&#xff1a;x0叫展开点&#xff09;&#xff0c;分别是正确的做法&#xff0c;在x0展开&#xff0c;然后将0和a代入fx中…

【PyTorch】模型选择、欠拟合和过拟合

文章目录 1. 理论介绍2. 实例解析2.1. 实例描述2.2. 代码实现2.2.1. 完整代码2.2.2. 输出结果 1. 理论介绍 将模型在训练数据上拟合的比在潜在分布中更接近的现象称为过拟合&#xff0c; 用于对抗过拟合的技术称为正则化。训练误差和验证误差都很严重&#xff0c; 但它们之间差…

activemq启动成功但web管理页面却无法访问

前提&#xff1a; 在linux启动activemq成功&#xff01;本地能ping通linux 处理方案&#xff1a; 确定防火墙是否关闭&#xff0c; 有两种处理方案&#xff1a;第一种-关闭防火墙&#xff1b;第二种-暴漏8161和61616两个端口 netstat -lnpt查看8161和61616端口 注意&#xf…

HarmonyOS开发(十):通知和提醒

1、通知概述 1.1、简介 应用可以通过通知接口发送通知消息&#xff0c;终端用户可以通过通知栏查看通知内容&#xff0c;也可以点击通知来打开应用。 通知使用的的常见场景&#xff1a; 显示接收到的短消息、即使消息...显示应用推送消息显示当前正在进行的事件&#xff0c…

Unity UGUI TextMeshPro实现输入中文和表情包(Emoji)表情

目录 实现中文显示 准备工作 1、打开Window——TextMeshPro——FontAssetCreator 2、把字体文件放入SourceFont中 3、把CharacterSet改为Characters from File 4、把字体库文件放入Characters File 5、设置好参数点击Generate Font Atlas等待完成后保存 6、把生成后保存…

洗鞋机行业分析:2023年市场发展前景及消费现状

随着消费主力的转移&#xff0c;年轻群体在消费中的话语权和影响力越来越大&#xff0c;“精致懒”正在成为潮流。洗鞋机作为消费升级时代的产物&#xff0c;自诞生以来&#xff0c;经过十几年的发展&#xff0c;逐渐被年轻消费者熟知&#xff0c;洗鞋机品牌阵营和产品种类也变…

Redis——某马点评day02——商铺缓存

什么是缓存 添加Redis缓存 添加商铺缓存 Controller层中 /*** 根据id查询商铺信息* param id 商铺id* return 商铺详情数据*/GetMapping("/{id}")public Result queryShopById(PathVariable("id") Long id) {return shopService.queryById(id);} Service…

域名证书(SSL)申请

获取域名证书的步骤如下&#xff1a; 选择认证机构&#xff1a;域名证书必须从受信任的认证机构中申请&#xff0c;如JoySSL、GeoTrust、Thawte等。收集信息&#xff1a;在申请域名证书之前&#xff0c;需要准备一些证明信息&#xff0c;如域名认证、身份证明等。创建CSR&…