【01】openEuler 源碼安裝 PostgreSQL

openEuler 源碼安裝 PostgreSQL

  • 部署環境說明
  • Shell 前端軟件包管理器基礎概念
    • YUM 簡介
    • DNF 簡介
  • 源碼安裝 PostgreSQL
    • 環境變量(env)設置
      • 臨時環境變量設置
      • 永久環境變量設置
    • 初始化數據庫(initdb)
  • 數據庫基本操作
    • 數據庫基本配置(postgresql.conf)
    • 啟動、停止、查看數據庫
    • 使用 psql 登錄數據庫
    • 查看數據庫版本信息
    • 更多(postgres/pg_ctl)命令說明

部署環境說明

  • Linux 系統:openEuler 22.03 LTS SP3 x86_64(下載地址:openEuler下載 | 歐拉系統ISO鏡像 | openEuler社區官網)

  • 數據庫:postgresql-15.6(下載地址:https://ftp.postgresql.org/pub/source/v15.6/postgresql-15.6.tar.gz)

pgsql

Shell 前端軟件包管理器基礎概念

YUM 簡介


YUM(全稱為 Yellow dog Updater, Modified)是一個在 FedoraRHEL、CentOS、OEL 中的 Shell 前端軟件包管理器。

YUM 本身基于 RPM 包管理,能夠從指定的 YUM 源服務器(一個或多個)自動下載 RPM 包并且進行安裝和更新,可以自動處理依賴性關系,并且一次安裝所有依賴的軟件包,無須繁瑣地一次次下載、安裝。

要成功的使用 YUM 工具安裝更新軟件或系統,就需要有一個包含各種 RPM 軟件包的 repository(軟件倉庫),這個軟件倉庫我們習慣稱為 YUM 源 (可以是本地源、網絡源)。

DNF 簡介


DNF(全稱為 Dandified yum)是新一代的 rpm 軟件包管理器,他首先出現在 Fedora 18 這個發行版中。而最近,它取代了 yum,正式成為 Fedora 22 的包管理器。

DNFRHEL、CentOS、OEL 等系統中,從版本 8 開始出現,目前和 YUM 共存。

DNF 克服了 YUM 包管理器的一些瓶頸,提升了包括用戶體驗,內存占用,依賴分析,運行速度等多方面的內容。

DNF 使用 Hawkey 庫,該庫解析 RPM 依賴性以在客戶端計算機上運行查詢。 它們基于 libsolv 構建,libsolv 是一種使用可滿足性算法的程序包相關性求解器。 您可以在 libsolvGitHub 存儲庫中找到有關該算法的更多詳細信息。


openEuler 22.03 系統中默認使用 dnf 作為 rpm 軟件包管理器,接下來我們也會使用該命令進行一些相關的操作。

源碼安裝 PostgreSQL

  1. 查看 linux 軟件源。
vi /etc/dnf/dnf.conf
[repo-id 名稱]
name=取個名字隨意(通常和 repo-id 名稱相同)
baseurl=軟件源地址# 或者vi /etc/yum.repos.d/openEuler.repo[OS]
name=OS
baseurl=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/
metalink=https://mirrors.openeuler.org/metalink?repo=$releasever/OS&arch=$basearch
metadata_expire=1h
enabled=1
gpgcheck=1
gpgkey=http://repo.openeuler.org/openEuler-22.03-LTS-SP3/OS/$basearch/RPM-GPG-KEY-openEuler

參考:設置 openEuler(歐拉系統)安裝源

  1. 安裝編譯環境依賴包(推薦使用 dnf )。
# yum 安裝
sudo yum install -y systemtap-sdt-devel.x86_64 perl-ExtUtils-Embed bzip2 readline readline-devel lz4 lz4-devel openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel tcl tcl-devel openldap openldap-devel python3 python3-devel kernel-headers autoconf proj.x86_64 vim nc wget psmisc gcc-c++ gcc lrzsz make cmake telnet net-tools bind-utils tree cifs-utils ntpdate bash-completion sysstat iotop iftop htop unzip nmap bc bind-utils nethogs# dnf 安裝
sudo dnf install -y perl-ExtUtils-Embed readline-devel python3-devel pam-devel libxml2-devel libxslt-devel openldap-devel lz4-devel llvm-devel systemd-devel container-selinux selinux-policy-devel openssl-devel gcc-c++ gcc cmake lsof net-tools

說明:openEuler 使用 dnf 作為默認包管理工具。

  1. 下載 postgresql 源碼。
// 1. 切換到 /opt/postgresql 目錄下
cd /opt/postgresql
// 2. 使用命令下載 postgresql
wget https://ftp.postgresql.org/pub/source/v15.6/postgresql-15.6.tar.gz
// 3. 解壓文件
sudo tar -zxvf postgresql-15.6.tar.gz
// 4. 創建文件夾目錄(用來存放安裝 postgresql 的相關文件)
sudo mkdir -p /pgccc/pgdata/data
  1. 編譯和安裝 postgresql
// 1. 檢測系統環境并生成 Makefile 文件,prefix 默認安裝路徑 /opt/postgresql/pgsql
./configure --prefix=/pgccc/pgdata --with-perl --with-python --with-pam --with-libxml --with-libxslt --with-ldap --with-lz4 --with-llvm --with-systemd --with-selinux --with-openssl // 2. 編譯 & 安裝
gmake world && gmake install-world

gmakegmake install 是兩個命令,參數說明:

  • gmake,編譯,依據 Makefile 文件把源碼包編譯成二進制可執行文件。

  • gmake install 安裝的意思。

gmake && gmake install 的意思就是執行 gmake 如果沒有發生錯誤就執行 gmake install

  1. 查看 postgresql 安裝目錄。
ls -al /pgccc/pgdata/

輸出信息:

[root@euler /]# ls -al /pgccc/pgdata/
總用量 28
drwxr-xr-x. 7 root root 4096  229 20:28 .
drwxr-xr-x. 3 root root 4096  229 20:11 ..
drwxr-xr-x. 2 root root 4096  229 20:17 bin
drwxr-xr-x. 2 root root 4096  229 20:28 data
drwxr-xr-x. 4 root root 4096  229 20:17 include
drwxr-xr-x. 4 root root 4096  229 20:17 lib
drwxr-xr-x. 5 root root 4096  229 20:

文件目錄說明:

  • bin 存放二進制文件;
  • include 存放 .h 頭文件;
  • lib 存放安裝所需的各種依賴庫,動態庫;
  • share 存放所需的插件(extension),組件;

環境變量(env)設置

臨時環境變量設置

  1. 編寫 shell 腳本:
vi pgsql-15.6-env.sh
# 寫入環境變量配置信息
export PGHOME=/pgccc/pgdata
export PGHOST=localhost
export PATH=$PGHOME/bin:$PATH:$HOME/bin
#export PATH=/pgccc/pgdata/bin:$PATH 
export LD_LIBRARY_PATH=/pgccc/pgdata/lib:$LD_LIBRARY_PATH 
export PGDATA=/pgccc/pgdata/data
export PGPORT=5432 
export PGUSER=postgres
  1. 執行命令,運行該文件(臨時生成一下):
source pgsql-15.6-env.sh
  1. 查看初始化 db 版本信息,目的驗證環境變量是否生效:
initdb --version
  1. 查看當前系統使用編碼集:
echo $LANG

永久環境變量設置

環境變量配置文件 profile (不推薦全局修改)。可以使用命令輸出當下用戶環境變量信息:

env 或 peintenv

參考:Linux系統中.bash_profile文件詳解_Linux_腳本之家 (jb51.net)

初始化數據庫(initdb)

注意:源碼安裝PostgreSQL 數據庫,沒有默認的 postgres 用戶,需自行手動創建用戶組和用戶,并設置密碼。

原因:root 不能執行 PostgreSQL 的一些命令,因此要創建 postgres 這個用戶。

  • 初始化數據庫
initdb -D /pgccc/pgdata/data

注意:使用非 root 授權用戶執行初始化數據庫命令。

若出現如下錯誤信息:

initdb: error: cannot be run as root
initdb: hint: Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process.

解決辦法:

# 添加非 root 用戶 postgres
sudo useradd postgres
# 給 postgres 用戶設置密碼
sudo passwd postgres
# 在相對應目錄創建文件夾
sudo mkdir /pgccc/pgdata/data
# 給 postgres 用戶授權 data 目錄可執行權限
sudo chown -R postgres:postgres /pgccc/pgdata/data
# 初始化數據庫實例
initdb -D /pgccc/pgdata/data -U postgres
# 啟動數據庫實例
pg_ctl start -D /pgccc/pgdata/data -l logfile 
# 查看啟動日志文件信息
cat ./logfile
  • 查看更多 initdb 命令幫助信息:
initdb --help

數據庫基本操作

數據庫基本配置(postgresql.conf)

  1. 配置數據庫監聽 IP 和端口(port):
vi /pgccc/pgdata/data/postgresql.conf

修改 listen_addressesport

#------------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#------------------------------------------------------------------------------# - Connection Settings -listen_addresses = '*'                  # what IP address(es) to listen on;# comma-separated list of addresses;# defaults to 'localhost'; use '*' for all# (change requires restart)
port = 5432                             # (change requires restart)
max_connections = 100                   # (change requires restart)
#superuser_reserved_connections = 3     # (change requires restart)
#unix_socket_directories = '/tmp'       # comma-separated list of directories# (change requires restart)
#unix_socket_group = ''                 # (change requires restart)
#unix_socket_permissions = 0777         # begin with 0 to use octal notation# (change requires restart)
#bonjour = off                          # advertise server via Bonjour# (change requires restart)
#bonjour_name = ''                      # defaults to the computer name# (change requires restart)

修改說明:

  • listen_addresses 默認值 localhost (只允許本地登錄),配置為 “*” 代表在本機的所有地址上監聽。

  • port 默認值 5432,如果安裝了多個數據庫實例,則需要為每個實例指定不同的監聽端口。

  1. 配置數據庫錯誤日志
#------------------------------------------------------------------------------
# REPORTING AND LOGGING
#------------------------------------------------------------------------------# - Where to Log -#log_destination = 'stderr'             # Valid values are combinations of# stderr, csvlog, jsonlog, syslog, and# eventlog, depending on platform.# csvlog and jsonlog require# logging_collector to be on.# This is used when logging to stderr:
logging_collector = on                  # Enable capturing of stderr, jsonlog,# and csvlog into log files. Required# to be on for csvlogs and jsonlogs.# (change requires restart)# These are only used if logging_collector is on:
log_directory = 'pg_log'                # directory where log files are written,# can be absolute or relative to PGDATA
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,# can include strftime() escapes
#log_file_mode = 0600                   # creation mode for log files,# begin with 0 to use octal notation
#log_rotation_age = 1d                  # Automatic rotation of logfiles will# happen after that time.  0 disables.
#log_rotation_size = 10MB               # Automatic rotation of logfiles will# happen after that much log output.# 0 disables.

修改說明:

  • logging_collector = on ,默認為 off

  • log_directory = 'pg_log' ,默認為 log(相對路徑,即 ${PGDATA}/pg_log)。也可以改為絕對路徑,還可以定義在其他目錄或者分區,但是必須先創建此目錄,并且該目錄有修改權限。

  • log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'

參考:PostgreSQL 日志參數解釋 常用環境日志參數配置_log_min_duration_statement-CSDN博客

啟動、停止、查看數據庫

可能出現類似的異常信息

  • 異常一:
pg_ctl: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

解決方案,改用非 root 賬號執行 pt_ctl 相關命令即可。

su postgres
  • 異常二:
[jeff@euler ~]$ pg_ctl --help
-bash: pg_ctl:未找到命令

解決方案,由于上面 postgresql 環境變量配置過程中使用的臨時方式,切換用戶后請重新執行下該命令。

source pgsql-15.6-env.sh
  1. 啟動數據庫
pg_ctl start -D /pgccc/pgdata/data

輸出信息:

waiting for server to start....2024-02-29 22:15:38.584 CST [125692] LOG:  redirecting log output to logging collector process
2024-02-29 22:15:38.584 CST [125692] HINT:  Future log output will appear in directory "pg_log".done
server started
  1. 停止數據庫
pg_ctl stop -D /pgccc/pgdata/data
  • pg_ctl stop 命令語法說明:
pg_ctl stop [-D DATADIR] [-m SHUTDOWN-MODE]

參數說明:-m 是指數據庫的停止方式,可選 3 種方式:

  • smart,待所有連接終止后關閉數據庫。

  • fast,快速斷開連接并關閉數據庫。

  • immediate,立刻關閉數據庫,下次啟動數據庫需要進行恢復。

如果不指定 -m,則默認使用 fast 方式關閉數據庫。

  1. 重啟數據庫
pg_ctl restart -D /pgccc/pgdata/data
  1. 查看數據庫運行狀態
  • 方法一:pg_ctl status 命令查看
pg_ctl status -D /pgccc/pgdata/data

輸出信息:

pg_ctl: server is running (PID: 125692)
/pgccc/pgdata/bin/postgres "-D" "/pgccc/pgdata/data"
  • 方法二:查看 postgres 進程信息
ps -ef | grep postgres
# (推薦)使用下面方式可以清晰看出層級結構
ps -axjf | grep postgres # 查看指定進程相關信息
lsof -p pid

輸出 pid=1814 (此處為 postgres 實例)的進程信息:

[root@euler ~]# lsof -p 1814
COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF    NODE NAME
postgres 1814 postgres  cwd    DIR              253,0     4096 1447087 /pgccc/pgdata/data2
postgres 1814 postgres  rtd    DIR              253,0     4096       2 /
postgres 1814 postgres  txt    REG              253,0  9363776 1444452 /pgccc/pgdata/bin/postgres
postgres 1814 postgres  DEL    REG                0,1             1025 /dev/zero
postgres 1814 postgres  mem    REG              253,0 19037712 3016591 /usr/lib/locale/locale-archive
postgres 1814 postgres  mem    REG              253,0   157976 3019397 /usr/lib64/libgpg-error.so.0.33.1
postgres 1814 postgres  mem    REG              253,0   223368 3018526 /usr/lib64/libcrypt.so.1.1.0
postgres 1814 postgres  mem    REG              253,0    63984 3018081 /usr/lib64/libresolv.so.2
postgres 1814 postgres  mem    REG              253,0    30840 3019511 /usr/lib64/libcap-ng.so.0.0.0
postgres 1814 postgres  mem    REG              253,0  1333016 3019544 /usr/lib64/libgcrypt.so.20.4.2
postgres 1814 postgres  mem    REG              253,0    43240 3030139 /usr/lib64/libcap.so.2.61
postgres 1814 postgres  mem    REG              253,0   117616 3020069 /usr/lib64/libsasl2.so.3.0.0
postgres 1814 postgres  mem    REG              253,0    68040 3027871 /usr/lib64/liblber.so.2.0.200
postgres 1814 postgres  mem    REG              253,0   133256 3019522 /usr/lib64/libaudit.so.1.0.0
postgres 1814 postgres  mem    REG              253,0   161992 3018465 /usr/lib64/liblzma.so.5.2.5
postgres 1814 postgres  mem    REG              253,0  2055336 3018072 /usr/lib64/libc.so.6
postgres 1814 postgres  mem    REG              253,0   812088 3030154 /usr/lib64/libsystemd.so.0.32.0
postgres 1814 postgres  mem    REG              253,0   397056 3027873 /usr/lib64/libldap.so.2.0.200
postgres 1814 postgres  mem    REG              253,0   891176 3018075 /usr/lib64/libm.so.6
postgres 1814 postgres  mem    REG              253,0   100552 3018407 /usr/lib64/libz.so.1.2.11
postgres 1814 postgres  mem    REG              253,0  3047192 3035664 /usr/lib64/libcrypto.so.1.1.1wa
postgres 1814 postgres  mem    REG              253,0   628816 3035666 /usr/lib64/libssl.so.1.1.1wa
postgres 1814 postgres  mem    REG              253,0    67784 3031855 /usr/lib64/libpam.so.0.85.1
postgres 1814 postgres  mem    REG              253,0  1492264 3015964 /usr/lib64/libxml2.so.2.9.14
postgres 1814 postgres  mem    REG              253,0   133240 3019814 /usr/lib64/liblz4.so.1.9.3
postgres 1814 postgres  mem    REG               0,23    26976       2 /dev/shm/PostgreSQL.2062550190
postgres 1814 postgres  mem    REG              253,0   199960 3018068 /usr/lib64/ld-linux-x86-64.so.2
postgres 1814 postgres  DEL    REG                0,1                0 /SYSV001614af
postgres 1814 postgres    0r   CHR                1,3      0t0       4 /dev/null
postgres 1814 postgres    1w  FIFO               0,12      0t0   20345 pipe
postgres 1814 postgres    2w  FIFO               0,12      0t0   20345 pipe
postgres 1814 postgres    3r  FIFO               0,12      0t0   20344 pipe
postgres 1814 postgres    4w  FIFO               0,12      0t0   20344 pipe
postgres 1814 postgres    5r  FIFO               0,12      0t0   20345 pipe
postgres 1814 postgres    6u  IPv4              20349      0t0     TCP *:personal-agent (LISTEN)
postgres 1814 postgres    7u  IPv6              20350      0t0     TCP *:personal-agent (LISTEN)
postgres 1814 postgres    8u  unix 0x0000000009ef7753      0t0   20351 /tmp/.s.PGSQL.5555 type=STREAM (LISTEN)

說明:linux 系統中 lsof 命令加 -p 是指定進程,不加 -p 的是線程。

  • 方法三:查看數據庫狀態
pg_isready -p 5432
  • 方法四:判斷監聽端口
# 安裝 net-tools
dnf install -y net-tools
# 監聽端口
netstat -nutlp | grep 5432

輸出信息:

tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN      1814/postgres       
tcp6       0      0 :::5432                 :::*                    LISTEN      1814/postgres 

使用 psql 登錄數據庫

psql 是一個客戶端命令工具,可以對數據庫實例執行相關操作。

說明:psql 連接數據庫,不指定的情況下,默認連接 5452 端口,且使用當前用戶查找同名 DB 實例。

  1. 登錄方式一:
psql postgresql://postgres:pg123@172.17.0.3:5432/postgres

參數說明:

  • postgresql,協議名稱。

  • postgres,數據庫用戶名。

  • pg123,用戶密碼。

  • 172.17.0.3,數據庫 IP 地址。

  • 5432,數據庫實例監聽端口。

  • postgres,需要訪問的數據庫名稱。

  1. 登錄方式二:
psql -U postgres -h 172.17.0.3 -p 5432 -d postgres

參數說明:

  • -Upostgresql 用戶名。

  • -h,數據庫 IP 地址。

  • -p,數據庫實例監聽端口。

  • -d,需要訪問的數據庫名稱。

  1. 登錄方式三:使用 psql 直接連接數據庫,需要通過設置 postgres 用戶的環境變量(env)來實現。
psql

參考:PostgreSQL psql兩種登錄方式_postgresql登錄-CSDN博客

  • 查看 pgsql 更多幫助信息:
psql --help

查看數據庫版本信息

  • 登錄數據庫后,查看數據庫(服務端)版本信息:
[postgres@euler /]$ psql -U postgres -p 5432 -d postgres
psql (15.6)
Type "help" for help.postgres=# select version();version                                    
------------------------------------------------------------------------------PostgreSQL 15.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.3.1, 64-bit
(1 row)postgres=# SHOW server_version;server_version 
----------------15.6
(1 row)postgres=# SHOW server_version_num;server_version_num 
--------------------150006
(1 row)
  • 推出 psql 查看數據庫(服務端)版本信息:
postgres-# \q
[postgres@euler /]$ postgres --version
postgres (PostgreSQL) 15.6
  • 查看數據庫客戶端工具版本信息
psql --version

注意:psql --version 返回的是 psql 工具的版本,而不是服務器版本。

更多(postgres/pg_ctl)命令說明

說明:pg_ctl 命令本質上是包裝了 postgres 的命令操作,推薦使用 pg_ctl 命令。

  • pg_ctl --help
[postgres@euler /]$ pg_ctl --help
pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.Usage:pg_ctl init[db]   [-D DATADIR] [-s] [-o OPTIONS]pg_ctl start      [-D DATADIR] [-l FILENAME] [-W] [-t SECS] [-s][-o OPTIONS] [-p PATH] [-c]pg_ctl stop       [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s]pg_ctl restart    [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s][-o OPTIONS] [-c]pg_ctl reload     [-D DATADIR] [-s]pg_ctl status     [-D DATADIR]pg_ctl promote    [-D DATADIR] [-W] [-t SECS] [-s]pg_ctl logrotate  [-D DATADIR] [-s]pg_ctl kill       SIGNALNAME PIDCommon options:-D, --pgdata=DATADIR   location of the database storage area-s, --silent           only print errors, no informational messages-t, --timeout=SECS     seconds to wait when using -w option-V, --version          output version information, then exit-w, --wait             wait until operation completes (default)-W, --no-wait          do not wait until operation completes-?, --help             show this help, then exit
If the -D option is omitted, the environment variable PGDATA is used.Options for start or restart:-c, --core-files       allow postgres to produce core files-l, --log=FILENAME     write (or append) server log to FILENAME-o, --options=OPTIONS  command line options to pass to postgres(PostgreSQL server executable) or initdb-p PATH-TO-POSTGRES    normally not necessaryOptions for stop or restart:-m, --mode=MODE        MODE can be "smart", "fast", or "immediate"Shutdown modes are:smart       quit after all clients have disconnectedfast        quit directly, with proper shutdown (default)immediate   quit without complete shutdown; will lead to recovery on restartAllowed signal names for kill:ABRT HUP INT KILL QUIT TERM USR1 USR2Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>
  • postgres --help
[postgres@euler /]$ postgres --help
postgres is the PostgreSQL server.Usage:postgres [OPTION]...Options:-B NBUFFERS        number of shared buffers-c NAME=VALUE      set run-time parameter-C NAME            print value of run-time parameter, then exit-d 1-5             debugging level-D DATADIR         database directory-e                 use European date input format (DMY)-F                 turn fsync off-h HOSTNAME        host name or IP address to listen on-i                 enable TCP/IP connections-k DIRECTORY       Unix-domain socket location-l                 enable SSL connections-N MAX-CONNECT     maximum number of allowed connections-p PORT            port number to listen on-s                 show statistics after each query-S WORK-MEM        set amount of memory for sorts (in kB)-V, --version      output version information, then exit--NAME=VALUE       set run-time parameter--describe-config  describe configuration parameters, then exit-?, --help         show this help, then exitDeveloper options:-f s|i|o|b|t|n|m|h forbid use of some plan types-n                 do not reinitialize shared memory after abnormal exit-O                 allow system table structure changes-P                 disable system indexes-t pa|pl|ex        show timings after each query-T                 send SIGSTOP to all backend processes if one dies-W NUM             wait NUM seconds to allow attach from a debuggerOptions for single-user mode:--single           selects single-user mode (must be first argument)DBNAME             database name (defaults to user name)-d 0-5             override debugging level-E                 echo statement before execution-j                 do not use newline as interactive query delimiter-r FILENAME        send stdout and stderr to given fileOptions for bootstrapping mode:--boot             selects bootstrapping mode (must be first argument)--check            selects check mode (must be first argument)DBNAME             database name (mandatory argument in bootstrapping mode)-r FILENAME        send stdout and stderr to given filePlease read the documentation for the complete list of run-time
configuration settings and how to set them on the command line or in
the configuration file.Report bugs to <pgsql-bugs@lists.postgresql.org>.
PostgreSQL home page: <https://www.postgresql.org/>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/714363.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/714363.shtml
英文地址,請注明出處:http://en.pswp.cn/news/714363.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

WiFi協議的調制技術介紹

調制技術是WiFi協議的核心部分&#xff0c;它負責將數據轉換成可以在無線信道中傳輸的信號。WiFi協議采用正交頻分復用&#xff08;OFDM&#xff09;調制技術&#xff0c;該技術通過將數據分成多個子載波進行傳輸&#xff0c;提高了信道利用率和抗干擾能力。 OFDM調制的工作原…

推特API(Twitter API)V2 用戶關注

前面章節已經介紹使用code換取Token的整個流程了&#xff0c;這里不再重復闡述了&#xff0c;下面我們獲取到用戶token以后如何幫用戶自動關注別人。需要參數關注者的用戶ID&#xff08;token授權用戶&#xff09;以及關注的目標用戶ID。用戶ID如何獲取可以看上一章節獲取用戶信…

c++結構體內存對齊

結構體內存對齊 試試運行下面的例子 #include <stdio.h> #include <stdlib.h>using namespace std;struct A{char c;int i; };struct B{char c; int i; double d; };struct C{char c;int i;double d;char c1; };int main(){printf("sizeof(A): %d\n"…

SparkStreaming在實時處理的兩個場景示例

簡介 Spark Streaming是Apache Spark生態系統中的一個組件&#xff0c;用于實時流式數據處理。它提供了類似于Spark的API&#xff0c;使開發者可以使用相似的編程模型來處理實時數據流。 Spark Streaming的工作原理是將連續的數據流劃分成小的批次&#xff0c;并將每個批次作…

適配器模式 詳解 設計模式

適配器模式 適配器模式是一種結構型設計模式&#xff0c;其主要作用是解決兩個不兼容接口之間的兼容性問題。適配器模式通過引入一個適配器來將一個類的接口轉換成客戶端所期望的另一個接口&#xff0c;從而讓原本由于接口不匹配而無法協同工作的類能夠協同工作。 結構 適配…

想要調用淘寶開放平臺API,沒有申請應用怎么辦?

用淘寶自定義API接口可以訪問淘寶開放平臺API。 custom-自定義API操作 taobao.custom 公共參數 注冊賬號獲取API請求地址 名稱類型必須描述keyString是調用key&#xff08;必須以GET方式拼接在URL中&#xff09;secretString是調用密鑰api_nameString是API接口名稱&#xf…

Docker與虛擬機比較

在對比Docker和虛擬機前&#xff0c;先簡單了解下虛擬化&#xff0c;明確Docker和虛擬機分別對應的虛擬化級別&#xff0c;然后對Docker和虛擬機進行比較。需要注意的是&#xff0c;Docker和虛擬機并沒有什么可比性&#xff0c;而是Docker使用的容器技術和虛擬機使用的虛擬化技…

【K8S類型系統】一文梳理 K8S 各類型概念之間的關系(GVK/GVR/Object/Schema/RestMapper)

參考 k8s 官方文檔 https://kubernetes.io/zh-cn/docs/reference/https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/ 重點 Kubernetes源碼學習-kubernetes基礎數據結構 - 知乎 重點 Kubernetes類型系統 | 李乾坤的博客 重點 k8s源碼學習-三大核心數…

前端學習第二天-html提升

達標要求 了解列表的分類 熟練掌握列表的用法 熟練掌握表格的結構構成 合并單元格 表單的組成 熟練掌握表單控件分類的使用 1.列表 1.1 無序列表 <ul>&#xff1a;定義無序列表&#xff0c;并且只能包含<li>子元素。 <li>&#xff1a;定義列表項&a…

LZO索引文件失效說明

在hive中創建lzo文件和索引時&#xff0c;進行查詢時會出現問題.hive的默認輸入格式是開啟小文件合并的&#xff0c;會把索引也合并進來。所以要關閉hive小文件合并功能&#xff01;

Matlab:元胞自動機

元胞自動機是一種基于離散空間的動態系統&#xff0c;由許多簡單單元按照某些規則進行相互作用和演化而形成的復雜結構。元胞自動機可以用于模擬物理、生物、社會等領域的現象&#xff0c;以及進行優化、圖像處理、噪聲生成等方面的應用。 例1&#xff1a;生命游戲 nextState…

maven項目報錯Cannot resolve plugin org.apache.maven.plugins:maven-war-plugin:2.2

如果IDEA整合maven沒有問題&#xff0c;還是報這個錯誤&#xff0c;很大可能是由于在下載過程中存在網絡問題&#xff0c;導致文件下載一半而停止&#xff0c;但是已經在倉庫中存在這個文件夾&#xff0c;解決方法是刪除文件夾重新下載即可。 刪除本地倉庫下的\org\apache\mav…

(算法)位運算

常見的位運算符&#xff1a; 給定一個數n判斷他的二進制第x位是0還是1 把第x位修改為1 因為是只是修改n的某個位置&#xff0c;所以不應該移動改變n 既然修改為1&#xff0c;那么就要想到 | 運算符 把第x位修改為0 因為修改為0,所以要用&運算符 位圖思想 判定字符串…

C++17之std::invoke: 使用和原理探究(全)

目錄 1.概述 2.輔助類 3.原理分析 4.總結 1.概述 在之前的 C 版本中&#xff0c;要調用不同類型的可調用對象&#xff0c;需要使用不同的語法&#xff0c;例如使用函數調用運算符 () 來調用函數或函數指針&#xff0c;使用成員訪問運算符 -> 或 . 來調用成員函數。這樣的…

二維碼門樓牌管理系統技術服務的深度解析

文章目錄 前言一、標準地址名稱的定義與重要性二、二維碼門樓牌管理系統的核心技術三、標準地址名稱在二維碼門樓牌管理中的應用四、二維碼門樓牌管理系統的優勢與挑戰五、展望未來 前言 在數字化浪潮中&#xff0c;二維碼門樓牌管理系統以其高效、便捷的特性&#xff0c;正逐…

【一】【算法分析與設計】基礎測試

排列式 題目描述 7254是一個不尋常的數&#xff0c;因為它可以表示為7254 39 x 186&#xff0c;這個式子中1~9每個數字正好出現一次 輸出所有這樣的不同的式子&#xff08;乘數交換被認為是相同的式子&#xff09; 結果小的先輸出&#xff1b;結果相同的&#xff0c;較小的乘…

js 實戰小案例

實戰 時間 js 格式化時間 <script type"text/javascript">function formatDate(date) { let year date.getFullYear(); let month String(date.getMonth() 1).padStart(2, 0); // getMonth() 返回的月份是從0開始的&#xff0c;所以要加1&#xff0c;并…

【go從入門到精通】go包,內置類型和初始化順序

大家好&#xff0c;這是我給大家準備的新的一期專欄&#xff0c;專門講golang&#xff0c;從入門到精通各種框架和中間件&#xff0c;工具類庫&#xff0c;希望對go有興趣的同學可以訂閱此專欄。 go基礎 。 Go文件名&#xff1a; 所有的go源碼都是以 ".go" 結尾&…

Mamba 環境安裝:causal-conv1d和mamba-ssm報錯解決辦法

問題描述&#xff1a; 在執行命令 pip install causal_conv1d 和 mamba_ssm 出錯&#xff1a; 解決方案&#xff1a; 1、使用網友配置好的Docker環境&#xff0c;參考&#xff1a;解決causal_conv1d和mamba_ssm無法安裝 -&#xff1e; 直接使用Mamba基礎環境docker鏡像 DockH…

java實現圖片轉pdf,并通過流的方式進行下載(前后端分離)

首先需要導入相關依賴&#xff0c;由于具體依賴本人也不是記得很清楚了&#xff0c;所以簡短的說一下。 iText&#xff1a;PDF 操作庫&#xff0c;用于創建和操作 PDF 文件。可通過 Maven 或 Gradle 引入 iText 依賴。 MultipartFile&#xff1a;Spring 框架中處理文件上傳的類…