我想禁用 Ubuntu 24.04 中的自动屏幕锁定。
对我来说,它既烦人又毫无意义,因为它是一个虚拟机。
我想从 CLI 执行此操作,因为我希望为每个非无头的 Ubuntu VM 执行它。
我想禁用 Ubuntu 24.04 中的自动屏幕锁定。
对我来说,它既烦人又毫无意义,因为它是一个虚拟机。
我想从 CLI 执行此操作,因为我希望为每个非无头的 Ubuntu VM 执行它。
我正在尝试设置 FTP 服务器,并且一直在遵循指南。它们都只显示如何设置一个用户,我需要让多个用户能够访问同一个文件夹并从中提取文件。我是否可以设置一个文件夹并将多个用户限制在该文件夹中?
我使用的是 vsftpd。用户将独立并需要能够从文件夹中下载文件,但不能向该文件夹写入任何内容或离开该文件夹。
我一直遵循这些指南:
https://documentation.ubuntu.com/server/how-to/networking/ftp/index.html
什么是 PDiff 文件以及它们可以做什么?
它们很重要吗?我能做些什么不下载它们吗?
编译我的视频驱动程序会产生以下错误:
xilinx-dma.h:51:返回container_of(e->pipe,struct xvip_pipeline,pipe);
发现在./media/media-entity.h中定义的struct media_entity {}中删除了以下行
int stream_count; struct media_pipeline *pipe; In kernel version 6.1.55 (Build in ARM64 architecture)
视频驱动程序在内核版本 5.15.0-131 下编译成功。(基于 x86_64 架构构建)
我想知道删除*pipe的原因,以及如何解决它?
谢谢你,老虎
在上次 Windows 更新(Windows 11 Home 24H2)后,我无法在 Ubuntu(24.04)上启动。我搜索了一些建议从启动修复磁盘启动(我这样做了)并使用启动修复的答案,但没有用。它没有显示“推荐修复”按钮,只有“创建摘要”按钮。摘要粘贴在下面。
编辑 1:这是我的磁盘信息。第一个是 1TB HD,我在其中保存视频文件、音乐、照片和一些备份。
Disk sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk identifier: 6A5F387D-1D0F-46E2-85A8-7338FF130C00
Start End Sectors Size Type
sda1 2048 1953523711 1953521664 931.5G Microsoft basic data
这是固态硬盘,我把操作系统放在那里。Ubuntu 安装在sdb2
Disk sdb: 447.13 GiB, 480103981056 bytes, 937703088 sectors
Disk identifier: CCBC8B68-06A2-4022-845D-A6D301109D84
Start End Sectors Size Type
sdb1 2048 2203647 2201600 1G EFI System
sdb2 2203648 469952511 467748864 223G Linux filesystem
sdb3 469952512 469985279 32768 16M Microsoft reserved
sdb4 469985280 936294399 466309120 222.4G Microsoft basic data
sdb5 936294400 937699327 1404928 686M Windows recovery environment
以下是摘要。我使用 Acer 网站提供的 zip 文件更新了固件。
============================== Boot Info Summary ===============================
=> No boot loader is installed in the MBR of /dev/sda.
=> No boot loader is installed in the MBR of /dev/sdb.
=> Syslinux MBR (5.00 and higher) is installed in the MBR of /dev/sdc.
sda1: __________________________________________________________________________
File system: ntfs
Boot sector type: NTFS
Boot sector info: No errors found in the Boot Parameter Block.
Operating System:
Boot files:
sdb1: __________________________________________________________________________
File system:
Boot sector type: Unknown
Boot sector info:
sdb2: __________________________________________________________________________
File system:
Boot sector type: Unknown
Boot sector info:
sdb3: __________________________________________________________________________
File system:
Boot sector type: Unknown
Boot sector info:
sdb4: __________________________________________________________________________
File system:
Boot sector type: Unknown
Boot sector info:
sdc1: __________________________________________________________________________
File system: vfat
Boot sector type: SYSLINUX 6.04
Boot sector info: Syslinux looks at sector 32864 of /dev/sdc1 for its
second stage. The integrity check of Syslinux failed.
No errors found in the Boot Parameter Block.
Operating System:
Boot files: /boot/grub/grub.cfg /syslinux.cfg
/efi/boot/bootx64.efi /efi/boot/grubx64.efi
/efi/boot/mmx64.efi /ldlinux.sys
================================ 0 OS detected =================================
================================ Host/Hardware =================================
CPU architecture: 64-bit
Video: WhiskeyLake-U GT2 [UHD Graphics 620] from Intel Corporation
Live-session OS is Linuxmint 64-bit (Linux Mint 21.2, victoria, x86_64)
===================================== UEFI =====================================
BIOS/UEFI firmware: V1.16(1.16) from Insyde Corp.
The firmware is EFI-compatible, and is set in EFI-mode for this live-session.
SecureBoot disabled (confirmed by mokutil).
BootCurrent: 0000
Timeout: 0 seconds
BootOrder: 0001,0000,0002,2001,2002,2003
Boot0000* Linpus lite HD(1,MBR,0x95160,0x800,0x39cb7e0)/File(\EFI\Boot\grubx64.efi)RC
Boot0001* ubuntu HD(1,GPT,6efb32b7-15fc-4e5f-a1f0-f0e5b78fc2f0,0x800,0x219800)/File(\EFI\ubuntu\shimx64.efi)RC
Boot0002* Windows Boot Manager HD(1,GPT,6efb32b7-15fc-4e5f-a1f0-f0e5b78fc2f0,0x800,0x219800)/File(\EFI\Microsoft\Boot\bootmgfw.efi)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...d................
Boot2001* EFI USB Device RC
Boot2002* EFI DVD/CDROM RC
Boot2003* EFI Network RC
============================= Drive/Partition Info =============================
Disks info: ____________________________________________________________________
sda : is-GPT, no-BIOSboot, has-noESP, not-usb, not-mmc, no-os, no-wind, 2048 sectors * 512 bytes
Partitions info (1/3): _________________________________________________________
sda1 : no-os, 64, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, end-after-100GB
sdb : no-os, 64, nopakmgr, no-docgrub, nogrub, nogrubinstall, no-grubenv, noupdategrub, not-far
Partitions info (2/3): _________________________________________________________
sda1 : isnotESP, part-has-no-fstab, no-nt, no-winload, no-recov-nor-hid, no-bmgr, notwinboot, ntfs
sdb : isnotESP, part-has-no-fstab, no-nt, no-winload, no-recov-nor-hid, no-bmgr, notwinboot,
Partitions info (3/3): _________________________________________________________
sda1 : not--sepboot, no---boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, no--grub.d, sda
sdb : maybesepboot, no---boot, part-has-no-fstab, not-sep-usr, no---usr, part-has-no-fstab, no--grub.d, sda
fdisk -l (filtered): ___________________________________________________________
Disk sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk identifier: 6A5F387D-1D0F-46E2-85A8-7338FF130C00
Start End Sectors Size Type
sda1 2048 1953523711 1953521664 931.5G Microsoft basic data
Disk sdb: 447.13 GiB, 480103981056 bytes, 937703088 sectors
Disk identifier: CCBC8B68-06A2-4022-845D-A6D301109D84
Start End Sectors Size Type
sdb1 2048 2203647 2201600 1G EFI System
sdb2 2203648 469952511 467748864 223G Linux filesystem
sdb3 469952512 469985279 32768 16M Microsoft reserved
sdb4 469985280 936294399 466309120 222.4G Microsoft basic data
sdb5 936294400 937699327 1404928 686M Windows recovery environment
Disk sdc: 28.9 GiB, 31029460992 bytes, 60604416 sectors
Disk identifier: 0x00095160
Boot Start End Sectors Size Id Type
sdc1 * 2048 60604383 60602336 28.9G c W95 FAT32 (LBA)
parted -lm (filtered): _________________________________________________________
sda:1000GB:scsi:512:4096:gpt:ATA WDC WD10SPZX-21Z:;
1:1049kB:1000GB:1000GB:ntfs:Basic data partition:msftdata;
sdb:480GB:scsi:512:512:gpt:ATA WD Green M.2 228:;
1:1049kB:1128MB:1127MB:fat32::boot, esp;
2:1128MB:241GB:239GB:ext4::;
3:241GB:241GB:16.8MB::Microsoft reserved partition:msftres;
4:241GB:479GB:239GB:ntfs:Basic data partition:msftdata;
5:479GB:480GB:719MB:ntfs::hidden, diag;
sdc:31.0GB:scsi:512:512:msdos:Kingston DataTraveler 3.0:;
1:1049kB:31.0GB:31.0GB:fat32::boot, lba;
blkid (filtered): ______________________________________________________________
NAME FSTYPE UUID PARTUUID LABEL PARTLABEL
sda
└─sda1 ntfs 76366FE6366FA639 03665a50-932a-488d-8ae1-2195a7185cf3 Data Basic data partition
sdb
sdc
└─sdc1 vfat 56A7-8BFC 00095160-01 BOOT-REPAIR
Mount points (filtered): _______________________________________________________
Avail Use% Mounted on
/dev/sda1 421G 55% /mnt/boot-sav/sda1
/dev/sdc1 26.4G 9% /cdrom
Mount options (filtered): ______________________________________________________
/dev/sda1 fuseblk rw,relatime,user_id=0,group_id=0,allow_other,blksize=4096
/dev/sdc1 vfat ro,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
====================== sdc1/boot/grub/grub.cfg (filtered) ======================
Start Boot-Repair-Disk 64-bit
Start Boot-Repair-Disk 64-bit (compatibility mode)
UEFI Firmware Settings
Test memory
========================= sdc1/syslinux.cfg (filtered) =========================
DEFAULT loadconfig
LABEL loadconfig
CONFIG /isolinux/isolinux.cfg
APPEND /isolinux/
==================== sdc1: Location of files loaded by Grub ====================
GiB - GB File Fragment(s)
?? = ?? boot/grub/grub.cfg 1
================== sdc1: Location of files loaded by Syslinux ==================
GiB - GB File Fragment(s)
?? = ?? syslinux.cfg 1
?? = ?? ldlinux.sys 1
======================== Unknown MBRs/Boot Sectors/etc =========================
/dev/sdb3: unknown GPT attributes
8000000000000000
Unknown BootLoader on sdb1
Unknown BootLoader on sdb2
Unknown BootLoader on sdb3
Unknown BootLoader on sdb4
Suggested repair: ______________________________________________________________
The default repair of the Boot-Repair utility would not act on the boot.
sprunge.us ko ()
我尝试按照有关如何重新安装 grub 的分步指南进行操作,甚至害怕弄乱一切,但它也没有用。当我尝试挂载主分区时,它返回
mount: special device /dev/sdb2 does not exist
编辑 2:我尝试了这里写的前 2 个解决方案:a) 如果我按下 shift + esc,它会将我带到一个 sudo 不起作用的屏幕;b) 启动修复不起作用。正如我之前所说,它没有显示“推荐修复”按钮,只有“创建摘要”按钮。在高级选项中,它也不显示“修复 GRUB”选项;c) Windows 和 Ubuntu 都在 UEFI 上,但我不明白该怎么做;d) 我禁用了休眠和快速启动,但无法重新安装 GRUB。它一直告诉我/dev/sdb2
不存在。我真的需要擦除我的 ssd 并重新安装吗?
编辑 3:我在启动修复磁盘终端上使用以下命令尝试了此解决方案:
sudo apt --fix-broken install
但它什么也没返回。然后我尝试
sudo update-grub
信息是
error: failed to get canonical path of '/cow'.
至少最后一个是有趣的。
我可以正常使用 Windows,甚至可以使用名为 Diskinternals Linux Reader 的软件访问 Ubuntu 上的文件,但我真的很想再次使用 Ubuntu。我只使用 Windows 玩游戏和一些在 Wine 上无法运行的应用程序,但我对 Linux 世界也非常陌生。如果有遗漏,请告诉我。
我使用一个扩展程序来自动静音所有 Firefox 选项卡,直到我手动取消静音,所以大多数时候,几乎所有选项卡都处于静音状态。我还经常打开十几个或更多的选项卡,因此没有空间显示它们的完整标题。
Firefox 过去常常在图标和标题下方用小写字母“静音”来表示标签已静音,因此不会占用额外的屏幕空间,但最近的一次更新将其改为图标旁边的静音扬声器图标,占用了大量空间 - 几乎与图标本身一样多,进一步限制了打开大量标签时可见的标题文本量。我理解为什么要进行这种更改 - 我相信新设计更适合视障用户,但对于我的特定用例来说,这有点不方便。
是否可以恢复与旧行为类似的功能,甚至完全隐藏指示器?设置是理想的,但我也可以安装附加组件或在某处手动编辑 CSS 文件。
我在 Linux Mint 上运行 Firefox 136。
JMB585 是用于从主机到具有 SATA/AHCI 接口的存储设备的 PCIe 桥接控制器。此桥接控制器也是一个端口倍增器。
如果将此桥接控制器设备插入支持 PCIe 3.0 规格的主板上的 m.2 插槽,它将启用所有连接的 SATA 设备,并且功能可与来自 CPU 或芯片组的本机 SATA 端口相媲美。
通过从支持从 USB 到 SATA 协议转换的 USB 设备连接到 m.2 连接器(例如 RTL9210 USB 到 PCIe/SATA 桥接器),JMB585 不再被识别。
所有必要的协议似乎都处于可比/兼容的级别(对于 PCIe,它是 3.x 标准,SATA 能够进行修订 3(6Gb/s),并且 USB 也兼容标准(3.2-3.0)。
所有研究都无法解释 Linux 内核(6.x 版本)系统的差异,并且 Windows 10 系统上的 JMB585 也无法识别连接到 USB-SATA 桥接 IC。
我在 Linux 上使用非标准键盘布局,该布局是我使用 XKB 制作的。这样我就可以通过按下修饰键并按下某个键来插入符号字符。这对大多数应用程序都适用,包括其他 Electron 应用程序(如 Obsidian)。但是,我在使用 VSCode 时遇到了问题。
问题是我在键盘映射中将IsoLevelShift+绑定J到了Enter。但是在 VSCode 中,您必须Enter在定义键绑定后按下。当我按下IsoLevelShift+J按下 时enter,VSCode 会将其添加oem_8到键绑定的末尾,然后它不起作用。
我希望 VSCode 完全忽略oem_8密钥——这可能吗?
注意:我正在keyCode
使用Keyboard: Dispatch
。
我正在尝试使用 Angular 为 Liferay 创建客户端扩展,但在部署扩展后,它显示为空白屏幕。以下是我遵循的步骤:
我采取的步骤:
创建Liferay工作区:
我创建了一个liferay-workspace,并在工作区内添加了一个 client-extensions 文件夹。
创建 Angular 项目:
我对 Angular 项目做了一些更改:
assemble:
- from: build/static
into: static
sample-page:
cssURLs:
- styles.*.css
friendlyURLMapping: sample-page
htmlElementName: sample-page
instanceable: false
name: My Sample Page
portletCategoryName: category.client-extensions
type: customElement
urls:
- main.*.js
- polyfills.*.js
- runtime.*.js
useESM: true
应用程序.组件.ts
@Component({
selector: 'sample-page',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
索引.html
<body>
<sample-page></sample-page>
</body>
建设项目:
从工作区根目录,我运行了./gradlew build
,它创建了 dist 和 build 文件夹,并生成了 Angular 项目的 ZIP 文件。
部署到liferay:
sh startup.sh
。问题:Angular 客户端扩展出现在 Liferay 的小部件部分,可以拖到页面上,但小部件本身在页面上呈现时是空白的。
附加信息:
可能出现什么问题?
如果您能提供任何见解或建议,说明部署后客户端扩展显示为空白屏幕的原因,我将不胜感激。在将 Angular 客户端扩展与 Liferay 集成时,我是否可能错过了其他配置或步骤?
我有一台运行 VirtualBox 的 Windows 11 家庭版 PC。我有一个 VirtualBox Windows 7 (win7),我需要它来运行两个特定设备。我通常运行 win7-box headless 并通过 RDP 或 VNC 访问它。
这个设置很好用。但是每次 Windows 11 主机重新启动时,win7 机器就会关闭。我必须登录 Windows 11 并手动重新启动机器。我希望 win7 机器始终自动运行。
我做了什么:
创建了一个新用户“vbox”。本地帐户,没有 Microsoft 帐户的用户。
使 vbox 成为管理员组的成员
使用以下 PowerShell 命令创建动作、触发器并注册它们:
$action = New-ScheduledTaskAction -Execute "d:\VirtualBox\VirtualBoxVM.exe" -Argument "startvm `"`"win7`"`" --type headless"
$trigger = New-ScheduledTaskTrigger -AtStartup
Register-ScheduledTask -Action $action -Trigger $trigger -TaskName "StartWin7VM" -User "Win11\vbox" -Password "password_that_i_set_for_vbox"
重新启动
然后:没有 win7 盒子正在运行。
我错过了什么?
我有一个脚本,当我运行它时,它会返回
Directory not found: ~/Pictures/Wallpaper
脚本如下:
#!/bin/bash
# Check if the wallpaper directory exists
if [ ! -d "$WALLPAPER_DIR" ]; then
echo "Directory not found: $WALLPAPER_DIR"
exit 1
fi
# Get currently loaded wallpaper
CURRENT_WALL=$(hyprctl hyprpaper listloaded)
# Get a random wallpaper that is not the current one
IMAGE=$(find "$WALLPAPER_DIR" -type f ! -name "$(basename "$CURRENT_WALL")" | -iname "*.jpg" -o -iname "*.png" -o -iname "*.jpeg" | shuf -n 1)
# Verify that an image was found
if [ -z "$IMAGE" ]; then
echo "No images found in $WALLPAPER_DIR"
exit 1
fi
环境$WALLPAPER_DIR
变量在我的 hyprland.conf 文件中配置,其值为我已验证的 ~/Pictures/Wallpaper。
我相当困惑为什么当变量和文件夹确实存在时它会返回 if 语句的否定结果。
我目前正在 Debian 12.X 上使用以下 bash 运行各种脚本:
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
我有以下方法/选项来执行脚本。
每种方法都有以下影响或选项:
Method | New Process | Shell Ends with exit | Variables Persist |
------------------------------------------------------------------------
./script | YES | NO | NO |
------------------------------------------------------------------------
bash script | YES | NO | NO |
------------------------------------------------------------------------
. ./script | NO | YES | YES |
------------------------------------------------------------------------
source script | NO | YES | YES |
------------------------------------------------------------------------
@terdon
请注意,. ./script 和 source script 完全相同。标准命令是 .,bash 也提供同义词 source,但两者除了名称之外没有区别。
根据我用来启动和结束脚本的方法,我可以在当前 shell 或终端会话中重用不同的变量和选项,如果它们没有被终止/关闭/注销,则可以不重用它们。
./script
如果我使用或 bash运行脚本script
,则会启动一个新的 shell 实例,并且其中设置的环境变量仅在该实例中有效。
脚本结束后,这些变量就会丢失。
但是,如果我使用 运行脚本. ./script
,变量将保留在父 shell 会话中,因为它们直接影响当前 shell。
在这种情况下,如果我希望这些变量在会话的剩余时间内可用而无需手动重置它们,那么了解这些变量是否会在父会话中持续存在是至关重要的。
例如,我还可以决定脚本是以 exit 还是 return 结束,并且根据该决定是否发生注销或关闭 shell。
所以,它会影响后续的其他步骤。
我是否可以在脚本中检测它是如何简单易行地启动的,即使用了哪种方法,以便将值存储在变量中,然后在启动时不传递参数的情况下进一步处理它?
这是一个测试文件test.applescript
:
display dialog "foo" buttons {"OK"} cancel button 1 default button 1
下午 4:05 我将其编译为test.app
:
osacompile -o test.app test.applescript
下午 4:07,我test.applescript
通过将 替换foo
为进行编辑bar
,然后再次编译它,覆盖现有test.app
文件。(它已成功覆盖。如果我运行它,对话框会显示“bar”,而不是“foo”。)
display dialog "bar" buttons {"OK"} cancel button 1 default button 1
osacompile -o test.app test.applescript
但尽管如此,date modified
的值test.app
仍然是下午 4:05。这是为什么?这怎么可能呢?
输出stat -x
:
File: "test.app"
Size: 96 FileType: Directory
Mode: (0755/drwxr-xr-x) Uid: ( 501/ john) Gid: ( 20/ staff)
Device: 1,17 Inode: 79429067 Links: 3
Access: Sun Mar 23 16:05:52 2025
Modify: Sun Mar 23 16:05:52 2025
Change: Sun Mar 23 17:20:48 2025
Birth: Sun Mar 23 16:05:52 2025
我正在尝试在 Linux 系统上编写一个 bash 脚本(顺便说一下,这是很新的编写方法),我基本上希望它每 5 秒执行一个命令,而另一个命令没有输出值。
因此,到目前为止,xev | grep -A2 --line-buffered -E 'ButtonRelease' | grep -o 'button 1'
当我单击 xev 窗口时,它基本上会输出“按钮 1”。我想每 5 秒运行一次单独的命令 ( xdotool mousemove 1401 1139 click 1
),直到我单击 xev 窗口,此时脚本停止。
我刚刚安装了 Fedora 41,软件更新程序建议我更新 Thinkpad 的固件(我想是与 UEFI 安全启动有关)。我点击了下载并安装,然后重新启动,系统重新启动了,现在我已经有将近一个小时的黑屏了
fwupd-efi version 1.6
Reset System
用微小的白色字母写在我的屏幕的左上角。
“fwupd-efi version 1.6 Reset System”是什么意思?我觉得它卡在那里了?我该怎么做才能摆脱这种情况?我应该按回车键吗?我应该关闭系统吗?它是试图告诉我它正在重置系统还是试图告诉我我应该重置系统?
select * from tblA a
left join tblB b on b.id = a.bId
group by a.bId
如果我根据列进行分组,则只会获得具有相同bID
值的记录中的第一个记录。有没有办法也可以获取每行具有相同值的记录总数bId
?无需进行单独的查询...
id | bId
--------
1 | 1
2 | 1
3 | 1
4 | 2
5 | 3
so in the above query I would expect
id | bId. | counts
-------------------
1 | 1 | 3 <- 3 records with bId = 1
4 | 2 | 1
5 | 3 | 1
尝试将 PostgreSQL 13 实例升级到版本 16 时,我遇到了麻烦。在此之前,我顺利地从 11 升级到 13,但现在安装 16 时出现了问题。
我愿意:
sudo apt install postgresql-16
并期望随后在 中找到配置文件/etc/postgresql/16
,但没有这样的文件夹。此外,pg_lsclusters
仅返回版本 13。我可以执行sudo -u postgres /lib/postgresql/16/bin/initdb -D /var/lib/postgresql/16/main
,这将起作用,但随后不会出现任何服务(如),并且集群仍未出现在列表中。systemctl status [email protected]
我找不到任何线索来判断原因,或者如何继续。我apt purge
多次尝试安装,然后重新安装,但都无济于事。此外,我在安装 PG 15 时也有同样的经历。欢迎提出任何想法,谢谢!
作为参考,这是安装的输出:
user@server:/etc/postgresql$ sudo apt install postgresql-16
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
postgresql-client-16
Suggested packages:
postgresql-doc-16
The following NEW packages will be installed:
postgresql-16 postgresql-client-16
0 upgraded, 2 newly installed, 0 to remove and 304 not upgraded.
Need to get 20.1 MB of archives.
After this operation, 69.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 https://apt.postgresql.org/pub/repos/apt jammy-pgdg/main amd64 postgresql-client-16 amd64 16.8-1.pgdg22.04+1 [1913 kB]
Get:2 https://apt.postgresql.org/pub/repos/apt jammy-pgdg/main amd64 postgresql-16 amd64 16.8-1.pgdg22.04+1 [18.1 MB]
Fetched 20.1 MB in 2s (9535 kB/s)
Preconfiguring packages ...
Selecting previously unselected package postgresql-client-16.
(Reading database ... 202138 files and directories currently installed.)
Preparing to unpack .../postgresql-client-16_16.8-1.pgdg22.04+1_amd64.deb ...
Unpacking postgresql-client-16 (16.8-1.pgdg22.04+1) ...
Selecting previously unselected package postgresql-16.
Preparing to unpack .../postgresql-16_16.8-1.pgdg22.04+1_amd64.deb ...
Unpacking postgresql-16 (16.8-1.pgdg22.04+1) ...
Setting up postgresql-client-16 (16.8-1.pgdg22.04+1) ...
update-alternatives: using /usr/share/postgresql/16/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-16 (16.8-1.pgdg22.04+1) ...
Processing triggers for postgresql-common (274.pgdg22.04+1) ...
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
user@server:/etc/postgresql$ ls
13
user@server:/etc/postgresql$
编辑:我希望这是提出这个问题/问题的正确地方。如果不是,请发表评论。我将其放在 stackexchange 中,几分钟后就关闭了,没有任何评论。很高兴收到任何意见,包括对我的帖子的意见!
查询持有的锁的数量,我得到一个几百的数字:
SELECT count(*) from
SYS.dm_tran_locks
但是查询性能计数器‘锁定块’给我一个大约 45,000 的数字。
SELECT object_name, counter_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE [counter_name] in ('Lock Blocks', 'Lock Blocks Allocated', 'Lock Memory (KB)', 'Lock Owner Blocks')
Microsoft 对锁块的定义如下:
指定服务器上当前正在使用的锁块数(定期刷新)。锁块代表单个锁定的资源,例如表、页面或行。
所以我希望数字相同,或者至少大致相同。我的理解显然有些欠缺,所以我正在努力更好地理解这一点。任何帮助都将不胜感激。
假设我有一个企业版数据库,它具有完全默认设置,只有普通的行存储表。没有 RCSI,没有快照隔离,也没有触发器。假设不需要行版本控制。
显然,这些假设意味着我不会为行版本控制支付额外的 14 字节/行成本。但是,可读 AG 次要副本在 SNAPSHOT 隔离下运行,而 SNAPSHOT 隔离需要行版本控制。因此,如果我将数据库放入可用性组并添加可读次要副本,我的数据库的哪些副本(如果有)将开始支付 14 字节/行的行版本控制成本?如果除了可读次要副本之外,我还有一个不可读次要副本,这种情况会改变吗?如果我进行故障转移并故障恢复会怎样?
之前链接的相关文档对此没有评论。我打算自己进行实验,但众所周知,AG 很容易出错,我不想得出错误的结论。
如果我在 Stack Overflow2010 数据库中有以下查询
UPDATE dbo.Posts
SET Title =
CASE
WHEN CreationDate <= '2008-01-01T00:00:00'
THEN 'A'
ELSE 'B'
END
FROM dbo.Posts
简要的STATISTICS IO
输出如下
Table 'Posts'. Scan count 1, logical reads 445699, physical reads 375822, page server reads 0, read-ahead reads 445521, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
(1878895 rows affected)
执行计划如下
如果我创建一个表来存储我想要在比较中使用的值:
CREATE TABLE dbo.Canary
(
TheDate DATETIME
)
INSERT INTO dbo.Canary VALUES ('2008-01-01T00:00:00')
然后如果我将查询更改如下:
UPDATE dbo.Posts
SET Title =
CASE
WHEN CreationDate <= Canary.TheDate
THEN 'A'
ELSE 'B'
END
FROM dbo.Posts
CROSS JOIN dbo.Canary
STATISTICS IO 输出是
Table 'Canary'. Scan count 1, logical reads 1, physical reads 1, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, page server reads 0, read-ahead reads 0, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'Posts'. Scan count 1, logical reads 16787757, physical reads 3127, page server reads 0, read-ahead reads 784795, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, page server reads 0, read-ahead reads 6291, page server read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob page server reads 0, lob read-ahead reads 0, lob page server read-ahead reads 0.
(1878895 rows affected)
执行计划如下
我们可以看到逻辑读取的数量大幅增加,从 445k 增加到 16m。我花了一些时间才在执行计划中找到这个问题的根源,但我使用实际 I/O 统计信息/实际逻辑读取属性对其进行了跟踪,并可以看到额外的读取是在聚集索引更新运算符上,我还可以看到此运算符现在在所有执行中都有一个实际行数值,而第一个查询的计划没有。
这里发生了什么?聚集索引更新中发生了什么,导致读取次数增加?
如果要使用这种“配置表中的值”模式,我知道查询应该使用一个变量,但是,这是一个来自供应商应用程序的查询,所以我想反馈查询以这种方式编写后发生的情况。