前端技术
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
[pg_hbaconf认证设置 ]的搜索结果
这里是文章列表。热门标签的颜色随机变换,标签颜色没有特殊含义。
点击某个标签可搜索标签相关的文章。
点击某个标签可搜索标签相关的文章。
转载文章
...stgre-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
转载
PostgreSQL
...致,这也正是许多系统设置密码有效期的原因所在。 进一步了解,美国国家标准技术研究院(NIST)在最新的数字身份认证指南中建议,除了定期更换密码外,应推广使用多因素认证,例如结合生物特征、物理令牌或手机验证码等手段,以增强账户安全性。同时,提倡采用长密码或密码短语,而非易于猜测的组合,并强调了密码复杂度与长度的重要性。 另外,针对数据库系统的密码管理,如PostgreSQL,不仅要在密码过期后及时更新,还应当采用加密存储、限制访问权限等多种方式加强防护。实践中,可利用自动化工具实施密码策略,确保所有账户遵循一致的安全标准。 总的来说,面对不断升级的网络安全威胁,我们需要持续关注并紧跟行业最佳实践,从个人用户到企业机构,都应积极响应并落实严格的密码管理和安全策略,为我们的数字资产筑起坚固的防线。
2023-04-17 13:39:52
113
追梦人-t
MySQL
...更加安全且高效的密码认证机制。 近期,针对MySQL数据库的安全事件频发,各大云服务商和企业纷纷升级自家数据库系统的安全防护措施。例如,某知名云服务商就推出了数据库审计服务,可以实时记录并分析MySQL用户的登录行为、查询操作等,一旦发现异常,立即告警,从而有效防止恶意查看或篡改数据的行为。 另外,在日常运维中,管理员应遵循最小权限原则,为每个MySQL用户分配仅满足其工作需求的最低权限,并定期更新密码策略,包括强制密码复杂度、设置定期更换密码等措施。同时,利用SSL/TLS加密技术保护MySQL客户端与服务器之间的通信,也是防止中间人攻击、保障密码传输安全的重要手段。 对于忘记MySQL密码的情况,除了上述提到的通过命令行工具以具有足够权限的用户重置密码外,还可以借助第三方MySQL管理工具,如phpMyAdmin、Navicat等,它们通常提供了更为直观的操作界面来处理这类问题,大大降低了数据库管理的门槛。 综上所述,MySQL账号和密码的管理不仅涉及到查询和重置这些基本操作,更涵盖了数据库访问控制、密码加密存储、安全审计等多个层面,需要结合最新的安全技术和最佳实践,以实现对MySQL数据库的有效安全管理。
2024-01-21 10:37:36
52
算法侠
MySQL
...骤: 1. 开启 "设置面板" 并进入 "应用程序"。 2. 在 "应用程序" 中找到 MySQL 并右键单击 "移除"。 3. 在弹出的对话框中选取 "完全移除" 并点击 "继续"。 4. 点击 "移除" 并等候移除完成。 5. 完成移除后,请手动移除 MySQL 安装目录和服务。 以下是 Mac 系统移除 MySQL 的步骤: 1. 在终端中输入以下命令:sudo rm /usr/local/mysql 2. 运行下面的命令以移除 MySQL 安装目录: sudo rm -rf /usr/local/mysql sudo rm -rf /Library/StartupItems/MySQLCOM sudo rm -rf /Library/PreferencePanes/MySQL 3. 运行以下命令以编辑 /etc/hostconfig 文件并移除以下行: MYSQLCOM=-YES- 4. 如果您要彻底移除 MySQL,请使用 Finder 软件找到并移除以下文件: /Library/Receipts/mysql-VERSION.pkg /Library/Receipts/mysql-VERSION.pkg /Library/Receipts/mysql-VERSION.pkg 完成以上步骤后,您已经成功移除 MySQL。
2023-09-27 12:06:50
55
码农
MySQL
...据不同的身份验证插件设置,MySQL服务器可以采用不同的方式验证用户提供的用户名和密码(或其它凭证),如使用加密算法对比密码、通过PAM系统进行多因素认证或者与LDAP目录服务集成进行集中式身份验证。在文章中,它被提及作为控制和管理用户登录权限的一种手段。 加密密码(authentication_string) , 在MySQL的用户表(mysql.user)中,authentication_string 字段存储了用户的经过加密处理的密码信息。为了保护数据库安全,MySQL并不直接保存明文密码,而是将其通过特定的加密算法进行加密存储。当用户尝试登录时,MySQL服务器会将输入的密码通过相同的加密算法处理后,与authentication_string字段中的值进行比对,只有匹配成功才能允许用户登录。在文中,它是查看和理解MySQL用户权限配置时的一个关键属性。
2024-01-18 17:26:02
133
码农
MySQL
...口令或不当的远程访问设置。 为强化MySQL远程连接安全性,建议关注以下几个方面: 1. 强化身份验证机制:采用双因素认证或多因素认证,避免仅依赖用户名和密码;启用MySQL的SSL加密连接功能,确保数据传输过程中的安全性。 2. 权限最小化原则:遵循“按需分配”的权限策略,只给每个用户提供完成其工作所需的最低权限,减少潜在的安全风险。 3. 定期审计与更新:定期审查MySQL用户表中的远程访问权限设置,及时移除不再需要的远程访问账号;同时保持MySQL服务器及其插件的版本更新,利用最新安全补丁修复已知漏洞。 4. 配合防火墙规则:在服务器层面,结合IPtables或其他防火墙工具精细控制对MySQL服务端口(默认3306)的访问,只允许特定可信IP地址进行远程连接。 5. 利用专门的数据库访问代理服务:对于大型企业或高安全需求场景,可考虑部署数据库访问代理服务,如Amazon RDS Proxy、Azure Database for MySQL Flexible Server等,它们提供了细粒度的访问控制、负载均衡及日志审计等功能,有助于提升远程访问MySQL数据库的整体安全性。 总之,在实现MySQL数据库远程访问便利性的同时,务必重视并实施严格的安全措施,以确保数据库资源不被恶意利用,有效保障企业信息资产的安全。
2023-12-17 16:15:36
63
数据库专家
MySQL
...上安装了MySQL并设置了口令,有时候需要查阅该口令以供进行其他处理。下面将介绍几种方式来查阅自己电脑上MySQL的口令。 方式一:查阅MySQL设置文件 1. 在电脑上搜索MySQL的设置文件my.cnf或my.ini,并开启文件。 2. 在文件中搜索[client]或[mysqldump]部分,通常口令会在该部分中显示。 3. 在该部分中搜索password或passwd的内容,该内容即为MySQL的口令。 方式二:通过MySQL工具查阅口令 1. 开启MySQL命令行工具或其它MySQL客户端。 2. 使用以下命令登录到MySQL服务器:mysql -u root -p。 3. 输入你自己设置的口令以登录到MySQL服务器。 4. 执行以下命令来查阅口令:SELECT user, host, password FROM mysql.user; 方式三:重置MySQL口令 如果以上方式都不能帮助你找回MySQL口令,那么可以考虑重置口令。以下是重置MySQL口令的基本步骤: 1. 停止MySQL服务。 2. 创建一个备份文件。 3. 启动MySQL服务,并跳过权限验证。 4. 使用UPDATE语句更新用户口令。 5. 停止MySQL服务并重新启动,以使更改生效。 总结 在工作中,有时候需要查阅自己电脑MySQL的口令,可以使用上述方式来实现。无论是通过查阅设置文件还是登录MySQL服务器,都十分简单。如果以上方式都不能找回口令,那么重置口令是最后的手段。希望这篇文章能够帮助到你。
2024-02-18 15:42:33
121
码农
MySQL
...库名称 // SSH设置 $ssh_host = 'ssh.example.com'; // SSH主机名 $ssh_user = 'sshuser'; // SSH账号 $ssh_password = 'sshpassword'; // SSH口令 $ssh_port = 22; // SSH端口 // SSH到MySQL服务器 $connection = ssh2_connect($ssh_host, $ssh_port); if (ssh2_auth_password($connection, $ssh_user, $ssh_password)) { // SSH认证成功 $tunnel = ssh2_tunnel($connection, $host, 3306); // 连接MySQL服务器 $conn = mysqli_connect('127.0.0.1', $user, $password, $database, '3306', $tunnel); // 检测连接是否成功 if (!$conn) { die('连接不成功: ' . mysqli_connect_error()); } // 查询数据 $sql = 'SELECT FROM user'; $result = mysqli_query($conn, $sql); // 处理查询结果 if (mysqli_num_rows($result) >0) { while ($row = mysqli_fetch_assoc($result)) { echo '账号: ' . $row['username'] . ', 口令: ' . $row['password'] . ' '; } } else { echo '没有结果'; } // 关闭连接 mysqli_close($conn); } else { // SSH认证不成功 die('SSH认证不成功'); } SSH连接的代码相对复杂,需要用ssh2_connect()函数连接SSH服务器,用ssh2_auth_password()函数进行SSH认证,然后用ssh2_tunnel()函数创建隧道,最后用mysqli_connect()函数连接MySQL服务器和数据库。SSH连接的好处是可以通过SSH隧道连接到远程的MySQL服务器,提升了数据传输的安全性。
2023-06-22 12:09:56
134
码农
Docker
...p或服务器版本中直接设置就近的registry mirror以提升下载速度。例如,2021年Docker就新增了多个地区的官方镜像缓存节点,用户可根据自身地理位置选择最优源。 其次,阿里云、腾讯云等国内云服务商也提供了稳定高效的Docker镜像加速服务,并且不断更新支持更多的镜像仓库,比如Harbor、Amazon ECR等。用户通过简单的认证与配置,即可利用这些服务快速拉取所需的Docker镜像。 此外,对于企业级用户而言,除了关注镜像拉取效率,更应注重镜像的安全性与合规性。因此,可以考虑搭建私有镜像仓库,如使用Harbor进行内部镜像托管,同时结合Notary实现镜像签名验证,确保整个CI/CD流程中的镜像安全可控。 近期,CNCF社区也在推动OCI(Open Container Initiative)标准的普及和应用,旨在提高容器镜像格式的互操作性和安全性,这将对Docker及各类容器技术产生深远影响。未来,无论是镜像构建、存储还是分发,都可能迎来更加标准化、高效便捷的新方案。 综上所述,在解决Docker镜像拉取问题时,我们可以从选择合适的镜像源、利用云服务商提供的加速服务、构建私有镜像仓库以及关注行业标准动态等多个角度综合考量,以满足不同场景下的需求并不断提升容器化应用的部署体验与安全性。
2024-03-06 16:10:51
401
程序媛
JSON
...及,JSON还在安全认证方面发挥着关键作用。JWT利用JSON格式封装用户信息,通过加密算法保证数据传输的安全性,被广泛应用于无状态、跨域的身份验证场景。 总之,从数据交换、API设计到数据存储和安全认证,JSON已成为现代软件开发不可或缺的一部分。深入理解和掌握JSON及其相关工具和技术,对于提升开发者工作效率和应用性能具有重要意义。未来,随着技术演进及新应用场景的拓展,JSON的作用和影响力预计将进一步增强。
2023-12-14 20:46:43
491
程序媛
转载文章
...是FTP服务拒绝用户认证的常见错误代码,其背后的原因往往涉及到服务器端的身份验证配置,尤其是PAM(Pluggable Authentication Modules)模块的设置。 近日,一项针对Linux系统下vsftpd服务器安全强化的研究报告指出,通过优化PAM配置可以有效防止未经授权的访问尝试,并确保合法用户的正常登录。例如,正确配置/etc/pam.d/vsftpd文件中的auth与account模块规则,利用pam_userdb.so从指定数据库(如/etc/vsftpd/loginusers)进行用户验证,能够实现更精细化的权限控制与安全管理。 同时,值得注意的是,对于日志审计的重要性也不容忽视。像/var/log/secure这样的系统日志文件,记录了sshd服务以及其他安全相关的事件信息,是排查身份验证问题、追踪异常登录行为的重要线索来源。因此,在应对FTP登录失败等问题时,运维人员除了细致检查PAM配置之外,还应充分利用日志分析工具,实时监控并及时响应潜在的安全威胁。 此外,鉴于FTP协议本身存在的安全隐患(如明文传输密码),许多企业正逐步转向更为安全的FTPS或SFTP等加密传输协议。相关技术社区和研究机构也在不断发布新的解决方案和最佳实践,以帮助用户更好地管理和维护他们的FTP服务器环境,确保数据传输的安全性和稳定性。
2024-01-06 14:11:49
141
转载
转载文章
...skey 5 再在默认证书路径下的ca.pem、key.pem、cert.pem Docker 运行时目录:/var/run/docker Docker PID 文件目录:/var/run/docker.pid containerd 通信sock路径 /run/containerd/containerd.sock 本篇文章为转载内容。原文链接:https://blog.csdn.net/xjmtxwd24/article/details/127860371。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-09-08 20:50:40
88
转载
转载文章
...orge.net/ 设置用户名密码 打开cntlm.ini文件,在Username,Domain, Password中写入相应的数据。 最后点击cntml.exe开始运行。 设置程序代理 在程序代理中写入127.0.0.1:3128(默认设置)。程序就可以连到外面了。 在公司内使用github只能通过代理连上,因为GIT不支持ntml代理认证。 转载于:https://www.cnblogs.com/Mingxx/archive/2012/11/06/2756915.html 本篇文章为转载内容。原文链接:https://blog.csdn.net/weixin_30784141/article/details/96634076。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-03-01 12:15:31
72
转载
Linux
...wget这家伙,默认设置下只会下载http的内容,而对于https的数据呢,它可没打算一并捎上。如果你想下载的是HTTPS类型的数据,那就得在使用wget这个命令行工具的时候,给它加上几个特定的小参数。 我们来看一下如何添加这些参数。首先,我们需要打开终端并输入以下命令: css sudo apt-get update && sudo apt-get install wget 这条命令的作用是更新系统并安装wget。然后,我们可以使用以下命令来下载http数据: php-template wget http://example.com 这条命令的作用是从"http://example.com"这个网址下载数据。如果一切正常的话,你应该能看到数据被下载下来了。 现在,让我们来看看如何添加参数来下载https数据。首先,我们需要使用以下命令来打开wget的帮助文档: ruby man wget 在这个文档中,你可以看到许多关于wget的详细信息,包括如何使用参数。我们主要关心的是有关https的数据的部分。简单说吧,兄弟,咱们得在命令行里头加上个“-k”这个小玩意儿,这就意味着我们要下载https类型的数据啦。这样,我们就可以使用以下命令来下载https数据了: css wget -k https://example.com 这条命令的作用是从"https://example.com"这个网址下载数据。如果一切正常的话,你应该能看到数据被下载下来了。 3. 结论 总的来说,wget是可以下载http数据的,但如果你想下载https的数据,就需要在命令行中添加一些参数。通过这种方法,我们可以很方便地下载我们需要的数据。所以,当你发现wget没法顺利下载http内容的时候,不妨来试试加点小参数的魔法,没准问题就这么迎刃而解啦!
2023-01-17 22:13:36
146
半夏微凉_t
Linux
...的 SSH 配置文件设置有误,也可能导致密钥对不匹配。 三、解决方案 针对以上可能出现的问题,我们可以采取以下几种解决方案: 1. 增加用户权限 如果是因为用户权限不足导致的 SSH 密钥对生成失败,可以尝试提升用户的权限级别。 示例: bash sudo usermod -aG sudo username 这样就将用户名添加到了 sudo 组中,拥有执行命令的权限。 2. 升级 SSH 服务器版本 如果是因为 SSH 服务器版本过低导致的密钥对不匹配,可以尝试升级 SSH 服务器到最新版本。 示例: bash sudo apt-get update sudo apt-get upgrade openssh-server 然后重启 SSH 服务: bash sudo service ssh restart 3. 检查网络连接 如果是因为网络问题导致的 SSH 密钥对生成失败,可以检查网络连接是否正常。 示例: bash ping remote_host 如果网络不通,则需要检查网络设置或联系网络管理员。 4. 检查 SSH 配置文件 如果是因为错误的 SSH 配置文件导致的密钥对不匹配,可以检查 ~/.ssh/config 文件中的设置。 示例: bash cat ~/.ssh/config 如果有错误的设置,需要修改后保存并关闭文件。 四、总结 本文详细介绍了 Linux 中 SSH 密钥对生成失败或密钥对不匹配的问题,并提供了相应的解决方案。在我们实际做开发的时候,千万不能忽视这些时常冒出来的小问题,得时刻留个心眼儿,及时逮住它们,顺手就把它们给解决了。同时呢,咱们也得时刻给自己充充电,不断提升手里的技术活儿,不断探索和学习新的知识、技能,好让自己随时能够应对各种意想不到的复杂挑战。 五、参考文献 - - 希望这篇文章能对你有所帮助!
2023-06-06 18:34:56
116
星辰大海-t
MySQL
...2_password认证插件),这些改进对于系统数据存储与管理的安全性和效率都带来了显著提升。 其次,随着云服务的发展,各大云服务商如AWS、阿里云、腾讯云等均提供了MySQL托管服务,用户无需关心底层硬件维护与软件升级,只需关注数据模型设计和SQL查询优化,大大降低了数据库运维门槛。例如,AWS RDS MySQL服务提供了一键备份恢复、读写分离、自动扩展等功能,为系统数据的高效管理和高可用性提供了有力支持。 再者,深入探讨MySQL在大数据处理领域的应用也不容忽视。虽然MySQL传统上主要用于OLTP在线交易处理场景,但在结合Hadoop、Spark等大数据框架后,也能够实现大规模数据分析和处理。比如使用Apache Sqoop工具将MySQL数据导入HDFS,或通过JDBC连接Spark SQL对MySQL数据进行复杂分析。 此外,对于系统安全性的考虑,如何有效防止SQL注入、实施权限管理以及加密敏感数据也是MySQL使用者需要关注的重点。MySQL自带的多层访问控制机制及密码加密策略可确保数据安全性,同时,业界还推荐遵循OWASP SQL注入防护指南来编写安全的SQL查询语句。 总之,在实际工作中,熟练掌握MySQL并结合最新的技术趋势与最佳实践,将有助于构建更为稳定、高效且安全的系统数据存储解决方案。
2023-01-17 16:44:32
123
程序媛
MySQL
...2_password认证插件等,这些新特性不仅提升了查询效率,也增强了数据安全性。实时跟踪MySQL官方发布的性能测试报告和最佳实践案例,可以帮助我们更好地利用新版本特性优化现有数据库。 其次,随着云原生技术的发展,MySQL在云环境下的部署和调优策略也在不断更新。比如AWS RDS提供的自动扩展、读写分离和性能指标监控等功能,使得用户能够更加便捷地管理在线MySQL数据库,并根据业务需求动态调整资源,有效防止性能瓶颈的发生。 再者,近年来数据库索引结构的研究也有突破性进展。如Google Spanner和Amazon Aurora等分布式数据库系统采用的时间序列有序键索引、SSTable存储格式等创新设计,对传统MySQL数据库索引结构优化提供了新的思路。阅读相关论文和技术博客,有助于我们在实际场景中借鉴和应用这些先进的索引设计理念。 最后,对于持续监测MySQL数据库性能而言,业界涌现出诸多优秀的开源工具和平台,如Percona Monitoring and Management(PMM)、Prometheus与Grafana集成方案等,它们能提供详尽的数据库性能指标可视化,辅助运维人员快速识别并解决潜在的性能问题。 总之,在面对在线MySQL数据库性能挑战时,紧跟行业发展趋势,结合理论研究与实践经验,辅以现代化的监控工具,无疑将极大地提高我们解决问题的能力和效率。
2023-04-11 19:17:38
93
电脑达人
转载文章
...连接管理、请求重试、认证、代理设置等功能。对于需要进行复杂HTTP通信功能开发的Java应用来说,HttpClient是一个强有力的选择。
2023-05-22 10:11:18
302
转载
Linux
...优化,包括改进的安全认证插件、增强的性能以及对JSON数据类型更全面的支持,用户在升级或初次配置时,可能需要针对新版本进行相应的权限管理与防火墙规则更新。 同时,随着云计算和容器化技术的发展,越来越多的企业选择将MySQL部署在云环境如AWS RDS、阿里云RDS等服务上,这不仅简化了运维工作,也引入了新的连接和安全性挑战。例如,云服务中的MySQL实例往往通过VPC和安全组规则来控制访问,因此,理解和配置这些规则以确保数据库的安全连接成为了新的必备技能。 此外,在保障数据库连接稳定的同时,强化数据安全同样重要。今年,业界爆出多起因数据库配置不当导致的数据泄露事件,提醒我们在设置MySQL账户权限时应遵循最小权限原则,并定期审计数据库用户的操作日志。建议读者参考《数据库安全最佳实践》等相关资料,以提升数据库系统的整体安全防护能力。
2023-03-28 20:22:57
162
柳暗花明又一村-t
SpringBoot
...ion) { // 设置状态码和消息 response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.setHeader("WWW-Authenticate", "Basic realm=\"myRealm\""); return new ResponseEntity<>(authException.getMessage(), HttpStatus.UNAUTHORIZED); } } 这样,当鉴权失败时,服务器就会返回一个包含错误信息的状态码和消息。 四、问题2 无法获取到鉴权失败的具体原因 在某些情况下,服务器可能会返回一个通用的错误信息,而没有具体的错误原因。这使得开发者很难找出问题所在。 五、解决方法 同样地,我们可以通过自定义一个全局异常处理器来解决这个问题。我们可以将具体的错误原因作为异常的信息,然后将其返回给客户端。例如: java @ControllerAdvice public class GlobalExceptionHandler { @ResponseBody @ResponseStatus(HttpStatus.UNAUTHORIZED) public ResponseEntity handleAuthenticationException(HttpServletResponse response, AuthenticationException authException) { // 获取具体的错误原因 String errorMessage = authException.getLocalizedMessage(); // 设置状态码和消息 response.setStatus(HttpStatus.UNAUTHORIZED.value()); response.setHeader("WWW-Authenticate", "Basic realm=\"myRealm\""); return new ResponseEntity<>(errorMessage, HttpStatus.UNAUTHORIZED); } } 这样,当鉴权失败时,服务器就会返回一个包含具体错误原因的状态码和消息。 六、结论 Spring Boot提供了强大的工具来帮助我们处理HTTP请求的鉴权问题。然而,我们在实际应用中可能会遇到一些问题,需要我们自己去解决。当我们使用自定义的全局异常处理机制时,就等于给程序装上了一位机智灵活的小助手,一旦鉴权出现差错,它能迅速抓取到问题的具体原因,并且随我们心意去定制响应结果。这样一来,咱们的应用程序就能得到更加贴心、周全的保护啦。
2023-07-21 22:51:44
105
山涧溪流_t
Superset
...审计SMTP邮件服务设置,并遵循行业最佳实践,如定期更换密码、启用双因素认证、监控异常登录行为等,以防止潜在的安全威胁。 实际上,Apache Superset作为一个开源的企业级BI工具,在其后续版本中也逐渐加强了对SMTP邮件服务安全特性的支持,比如提供更多的自定义选项来满足不同企业的安全需求。因此,不仅要在配置过程中避免常见错误,更应积极关注并适应电子邮件安全领域的最新发展动态,确保高效、安全地运用Superset进行数据分享与协作。
2023-07-14 19:44:18
654
半夏微凉-t
Go Gin
...的时候,我们可以这样设置动态路由:Router.GET("/path/:param", func(c gin.Context) { ... }),就像跟朋友聊天那样说,就是给Router安排个任务,当GET请求遇到"/path/后面跟着任意参数"这种路径时,就执行那个匿名函数,这个函数会接收一个gin.Context参数,然后你就可以在这个函数里面自由发挥,对不同的参数做出不同的响应啦。 例如,如果我们想要创建一个可以接收GET请求的接口,当路径为"/users/:id"时,返回用户信息,我们可以这样做: go r := gin.Default() r.GET("/users/:id", func(c gin.Context) { id := c.Param("id") // 从数据库或其他数据源获取用户信息 user, err := getUserById(id) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"user": user}) }) 三、参数捕获 在动态路由中,我们已经看到如何通过:param来捕获路径中的参数。除了这种方式,Gin还提供了其他几种方法来捕获参数。 1. 使用c.Params 这个变量包含了所有的参数,包括路径上的参数和URL查询字符串中的参数。例如: go r := gin.Default() r.GET("/users/:id", func(c gin.Context) { id := c.Params.ByName("id") // 获取by name的方式 fmt.Println("User ID:", id) user, err := getUserById(id) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"user": user}) }) 2. 使用c.Request.URL.Query().Get(":param"):这种方式只适用于查询字符串中的参数。例如: go r := gin.Default() r.GET("/search/:query", func(c gin.Context) { query := c.Request.URL.Query().Get("query") // 获取query的方式 fmt.Println("Search Query:", query) results, err := search(query) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()}) return } c.JSON(http.StatusOK, gin.H{"results": results}) }) 四、总结 通过这篇文章,我们了解了如何在Go Gin中实现动态路由和参数捕获。总的来说,Gin这玩意儿就像个神奇小帮手,它超级灵活地帮咱们处理那些HTTP请求,这样一来,咱们就能把更多的精力和心思花在编写核心业务逻辑上,让工作变得更高效、更轻松。如果你正在寻觅一款既简单易上手,又蕴藏着强大功能的web框架,我强烈推荐你试试看Gin,它绝对会让你眼前一亮,大呼过瘾!
2023-01-16 08:55:08
433
月影清风-t
站内搜索
用于搜索本网站内部文章,支持栏目切换。
知识学习
实践的时候请根据实际情况谨慎操作。
随机学习一条linux命令:
last reboot
- 显示最近的系统重启记录。
推荐内容
推荐本栏目内的其它文章,看看还有哪些文章让你感兴趣。
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
历史内容
快速导航到对应月份的历史文章列表。
随便看看
拉到页底了吧,随便看看还有哪些文章你可能感兴趣。
时光飞逝
"流光容易把人抛,红了樱桃,绿了芭蕉。"