前端技术
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
[使用mysql_num_rows统计记录...]的搜索结果
这里是文章列表。热门标签的颜色随机变换,标签颜色没有特殊含义。
点击某个标签可搜索标签相关的文章。
点击某个标签可搜索标签相关的文章。
Shell
...行某些任务。然而,在使用while循环这玩意儿的时候,咱们可能时不时会碰上这么个状况——就是那个用来判断循环该不该继续的条件突然不灵了。本文将深入探讨这种问题,并提供一些解决方案。 二、While循环的基本原理与语法 首先,让我们回顾一下while循环的基本原理和语法。你知道吗,while循环就像是一个超级有耐心的小助手,它会一直重复做同一组任务,直到达到某个特定的要求才肯罢休。说白了,就是在条件没满足之前,它就一直在那儿坚守岗位,一遍又一遍地执行那组语句,可真是个执着的小家伙呢!其基本语法如下: bash while condition; do command1; command2; ... done 在这里,condition是一个布尔表达式,如果为真,则执行do后面的所有命令。 三、while循环条件判断失效的原因分析 那么,为什么我们在使用while循环时会遇到条件判断失效的问题呢?这通常是因为以下几个原因: 1. 条件表达式的错误 条件表达式可能包含语法错误或者逻辑错误,导致条件始终无法得到正确的评估。 2. 无限递归 如果while循环内部调用了其他while循环,而这些循环没有正确地退出,就会形成无限递归,最终导致条件判断失效。 3. 命令执行失败 如果while循环中的命令执行失败(例如,返回非零状态),那么下次循环时,条件表达式的结果就可能被误判为真,导致循环无限制地进行下去。 四、解决while循环条件判断失效的方法 对于以上提到的问题,我们可以采取以下几种方法来解决: 1. 检查并修复条件表达式 首先,我们需要检查while循环的条件表达式是否正确。如果发现有语法错误或逻辑错误,我们就需要对其进行修复。例如,下面的代码中,echo命令输出了非零状态,因此while循环条件判断始终为真: bash num=5 while [ "$num" -gt 0 ]; do echo "Hello World" num=$((num-1)) done 我们应该修复这个错误,确保条件表达式能够正确地评估: bash num=5 while [ "$num" -gt 0 ]; do echo "Hello World" num=$((num-1)) if [ "$num" -le 0 ]; then break fi done 2. 避免无限递归 如果while循环内部调用了其他while循环,我们应该确保这些循环能够在适当的时候退出。例如,下面的代码中,两个while循环相互调用,形成了无限递归: bash i=0 j=0 while [ $i -lt 10 ]; do j=$((j+1)) while [ $j -lt 10 ]; do i=$((i+1)) done done 我们应该调整逻辑,避免无限递归: bash i=0 j=0 while [ $i -lt 10 ]; do j=$((j+1)) while [ $j -lt 10 ]; do i=$((i+1)) j=$((j+1)) done j=0 done 3. 检查命令执行结果 如果我们发现while循环中的命令执行失败,我们就需要找出原因,并修复这个问题。例如,下面的代码中,sleep命令返回了非零状态,导致while循环条件判断始终为真: bash num=5 while true; do sleep 1 num=$((num-1)) if [ "$num" -eq 0 ]; then break fi done 我们应该修复这个错误,确保命令执行成功: bash num=5 while true; do sleep 1 num=$((num-1)) if [ "$num" -eq 0 ]; then break fi if ! some_command; then continue fi done 五、总结 通过本文的学习,我们应该对while循环条件判断失效有了更深刻的理解。无论是排查并搞定条件表达式的bug,防止程序陷入无限循环的漩涡,还是仔细审查命令执行的结果反馈,我们都能运用这些小妙招,手到病除地解决各类问题,让咱们的shell编程稳如磐石,靠得住得很。同时呢,咱们也得养成棒棒的编程习惯了,就像定期给车子做保养一样,时不时地给咱的代码做个“体检”和“调试”,这样一来,就能有效地防止这类问题再冒出来捣乱啦。
2023-07-15 08:53:29
71
蝶舞花间_t
转载文章
...实并删除相应内容。 mysql 帮助:A.2.3 Client does not support authentication protocol MySQL 4.1 and up uses an authentication protocol based on a password hashing algorithm that is incompatible with that used by older clients. If you upgrade the server to 4.1, attempts to connect to it with an older client may fail with the following message: shell> mysqlClient does not support authentication protocol requestedby server; consider upgrading MySQL client To solve this problem, you should use one of the following approaches: http://www.gaodaima.com/38584.htmlMYSQL 新版出现" Client does_mysql Upgrade all client programs to use a 4.1.1 or newer client library. When connecting to the server with a pre-4.1 client program, use an account that still has a pre-4.1-style password. Reset the password to pre-4.1 style for each user that needs to use a pre-4.1 client program. This can be done using the SET PASSWORD statement and the OLD_PASSWORD() function: mysql> SET PASSWORD FOR -> 'some_user'@'some_host' = OLD_PASSWORD('newpwd'); Alternatively, use UPDATE and FLUSH PRIVILEGES: mysql> UPDATE mysql.user SET Password = OLD_PASSWORD('newpwd') -> WHERE Host = 'some_host' AND User = 'some_user';mysql> FLUSH PRIVILEGES; Substitute the password you want to use for newpwd'' in the preceding examples. MySQL cannot tell you what the original password was, so you'll need to pick a new one. Tell the server to use the older password hashing algorithm: Start mysqld with the --old-passwords option. Assign an old-format password to each account that has had its password updated to the longer 4.1 format. You can identify these accounts with the following query: mysql> SELECT Host, User, Password FROM mysql.user -> WHERE LENGTH(Password) > 16; For each account record displayed by the query, use the Host and User values and assign a password using the OLD_PASSWORD() function and either SET PASSWORD or UPDATE, as described earlier. For additional background on password hashing and authentication, see section 5.5.9 Password Hashing in MySQL 4.1. 例子: SET PASSWORD FOR 用户名@localhost = OLD_PASSWORD('密码'); 欢迎大家阅读《MYSQL 新版出现" Client does_mysql》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码 微信 赏一包辣条吧~ 支付宝 赏一听可乐吧~ 本篇文章为转载内容。原文链接:https://blog.csdn.net/weixin_29363791/article/details/114779150。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-11-17 19:43:27
105
转载
Spark
...式数据处理和复杂的图计算,它都能轻松搞定,可以说是大数据界的多面手。它通过内存计算的方式,大大提高了数据处理的速度。 那么,如何将数据从SQL数据库导入到Spark中呢?我们可以分为以下几个步骤: 一、创建Spark会话 在Spark中,我们通常会使用SparkSession来与Spark进行交互。首先,我们需要创建一个SparkSession实例: python from pyspark.sql import SparkSession spark = SparkSession.builder.appName('MyApp').getOrCreate() 二、读取SQL数据库中的数据 在Spark中,我们可以使用read.jdbc()函数来读取SQL数据库中的数据。这个函数需要提供一些参数,包括数据库URL、表名、用户名、密码等: python df = spark.read.format("jdbc").options( url="jdbc:mysql://localhost:3306/mydatabase", driver="com.mysql.jdbc.Driver", dbtable="mytable", user="root", password="password" ).load() 以上代码会读取名为"mydatabase"的MySQL数据库中的"mytable"表,并将其转换为DataFrame对象。 三、查看读取的数据 我们可以使用show()函数来查看读取的数据: python df.show() 四、对数据进行处理 读取并加载数据后,我们就可以对其进行处理了。例如,我们可以使用select()函数来选择特定的列: python df = df.select("column1", "column2") 我们也可以使用filter()函数来过滤数据: python df = df.filter(df.column1 > 10) 五、将处理后的数据保存到文件或数据库中 最后,我们可以使用write()函数将处理后的数据保存到文件或数据库中。例如,我们可以将数据保存到CSV文件中: python df.write.csv("output.csv") 或者将数据保存回原来的数据库: python df.write.jdbc(url="jdbc:mysql://localhost:3306/mydatabase", table="mytable", mode="overwrite") 以上就是将数据从SQL数据库导入到Spark中的全部流程。敲黑板,划重点啦!要知道,不同的数据库类型就像是不同口味的咖啡,它们可能需要各自的“咖啡伴侣”——也就是JDBC驱动程序。所以当你打算用read.jdbc()这个小工具去读取数据时,千万记得先检查一下,对应的驱动程序是否已经乖乖地安装好啦~ 总结一下,Spark提供了简单易用的API,让我们能够方便地将数据从各种数据源导入到Spark中进行处理和分析。无论是进行大规模数据处理还是复杂的数据挖掘任务,Spark都能提供强大的支持。希望这篇文章能对你有所帮助,让你更好地掌握Spark。
2023-12-24 19:04:25
162
风轻云淡-t
Hive
...che Spark的计算力结合起来,实现了高性能的大数据处理。 总的来说,Hive正在不断进化,以适应数据科学的最新需求。对于那些已经在使用Hive的企业和开发者来说,关注这些新功能和趋势,将有助于他们在数据驱动的决策中保持领先。
2024-04-04 10:40:57
769
百转千回
Go Iris
...作为一款高性能且易于使用的Web框架,深受开发者喜爱。然而,在与数据库交互的过程中,SQL查询错误是难以避免的问题之一。本文将围绕“Go Iris中的SQL查询错误异常”这一主题,探讨其产生的原因、影响以及如何有效地进行捕获和处理,同时辅以丰富的代码示例,力求让您对这个问题有更深入的理解。 2. SQL查询错误概述 在使用Go Iris构建应用程序并集成数据库操作时,可能会遇到诸如SQL语法错误、数据不存在或权限问题等导致的SQL查询错误。这类异常情况如果不被好好处理,那可不只是会让程序罢工那么简单,它甚至可能泄露一些核心机密,搞得用户体验大打折扣,严重点还可能会对整个系统的安全构成威胁。 3. Go Iris中处理SQL查询错误的方法 让我们通过一段实际的Go Iris代码示例来观察和理解如何优雅地处理SQL查询错误: go package main import ( "github.com/kataras/iris/v12" "github.com/go-sql-driver/mysql" "fmt" ) func main() { app := iris.New() // 假设我们已经配置好了数据库连接 db, err := sql.Open("mysql", "user:password@tcp(127.0.0.1:3306)/testdb") if err != nil { panic(err.Error()) // 此处处理数据库连接错误 } defer db.Close() // 定义一个HTTP路由处理函数,其中包含SQL查询 app.Get("/users/{id}", func(ctx iris.Context) { id := ctx.Params().Get("id") var user User err = db.QueryRow("SELECT FROM users WHERE id=?", id).Scan(&user.ID, &user.Name, &user.Email) if err != nil { if errors.Is(err, sql.ErrNoRows) { // 处理查询结果为空的情况 ctx.StatusCode(iris.StatusNotFound) ctx.WriteString("User not found.") } else if mysqlErr, ok := err.(mysql.MySQLError); ok { // 对特定的MySQL错误进行判断和处理 ctx.StatusCode(iris.StatusInternalServerError) ctx.WriteString(fmt.Sprintf("MySQL Error: %d - %s", mysqlErr.Number, mysqlErr.Message)) } else { // 其他未知错误,记录日志并返回500状态码 log.Printf("Unexpected error: %v", err) ctx.StatusCode(iris.StatusInternalServerError) ctx.WriteString("Internal Server Error.") } return } // 查询成功,继续处理业务逻辑... // ... }) app.Listen(":8080") } 4. 深入思考与讨论 面对SQL查询错误,我们应该首先确保它被正确捕获并分类处理。就像刚刚提到的例子那样,面对各种不同的错误类型,我们完全能够灵活应对。比如说,可以选择扔出合适的HTTP状态码,让用户一眼就明白是哪里出了岔子;还可以提供一些既友好又贴心的错误提示信息,让人一看就懂;甚至可以细致地记录下每一次错误的详细日志,方便咱们后续顺藤摸瓜,找出问题所在。 在实际项目中,我们不仅要关注错误的处理方式,还要注重设计良好的错误处理策略,例如使用中间件统一处理数据库操作异常,或者在ORM层封装通用的错误处理逻辑等。这些方法不仅能提升代码的可读性和维护性,还能增强系统的稳定性和健壮性。 5. 结语 总之,理解和掌握Go Iris中SQL查询错误的处理方法至关重要。只有当咱们应用程序装上一个聪明的错误处理机制,才能保证在数据库查询出岔子的时候,程序还能稳稳当当地运行。这样一来,咱就能给用户带来更稳定、更靠谱的服务体验啦!在实际编程的过程中,咱们得不断摸爬滚打,积攒经验,像升级打怪一样,一步步完善我们的错误处理招数。这可是我们每一位开发者都该瞄准的方向,努力做到的事儿啊!
2023-08-27 08:51:35
458
月下独酌
转载文章
...jar还不够,还需要MySQL数据库与驱动,log4j的jar等等。下面我们开始今天的旅行: 第一步:创建数据库表 在Navicat下执行如下sql命令创建数据库mybatis和表t_user [sql] view plaincopy print? CREATE DATABASE IF NOT EXISTS mybatis; [sql] view plaincopy print? USE mybatis; [sql] view plaincopy print? create table t_user ( user_id int(11) NOT NULL AUTO_INCREMENT, user_name varchar(20) not null, user_age varchar(20) not null, PRIMARY KEY (user_id) )ENGINE=InnoDB DEFAULT CHARSET=utf8; 我们先看一下项目的完整目录,再继续下面的内容 第二步:添加jar包 对于下面代码的内容,我们就不再一一贴出来,只是把最重要的内容贴出来,大家可以下载源码。 第三步:创建model 创建一个model包并在其下创建一个User.Java文件。 [java] view plaincopy print? package com.tgb.model; / 用户 @author liang / public class User { private int id; private String age; private String userName; public User(){ super(); } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getAge() { return age; } public void setAge(String age) { this.age = age; } public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public User(int id, String age, String userName) { super(); this.id = id; this.age = age; this.userName = userName; } } 第四步:创建DAO接口 创建一个包mapper,并在其下创建一个UserMapper.java文件作为DAO接口。 [java] view plaincopy print? package com.tgb.mapper; import java.util.List; import com.tgb.model.User; public interface UserMapper { void save(User user); boolean update(User user); boolean delete(int id); User findById(int id); List<User> findAll(); } 第五步:实现DAO接口 在dao包下创建一个UserMapper.xml文件作为上一步创建的DAO接口的实现。 [html] view plaincopy print? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!-- namespace:必须与对应的接口全类名一致 id:必须与对应接口的某个对应的方法名一致 --> <mapper namespace="com.tgb.mapper.UserMapper"> <insert id="save" parameterType="User"> insert into t_user(user_name,user_age) values({userName},{age}) </insert> <update id="update" parameterType="User"> update t_user set user_name={userName},user_age={age} where user_id={id} </update> <delete id="delete" parameterType="int"> delete from t_user where user_id={id} </delete> <!-- mybsits_config中配置的alias类别名,也可直接配置resultType为类路劲 --> <select id="findById" parameterType="int" resultType="User"> select user_id id,user_name userName,user_age age from t_user where user_id={id} </select> <select id="findAll" resultType="User"> select user_id id,user_name userName,user_age age from t_user </select> </mapper> 这里对这个xml文件作几点说明: 1、namespace必须与对应的接口全类名一致。 2、id必须与对应接口的某个对应的方法名一致即必须要和UserMapper.java接口中的方法同名。 第六步:Mybatis和Spring的整合 对于Mybatis和Spring的整合是这篇博文的重点,需要配置的内容在下面有详细的解释。 [html] view plaincopy print? <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd"> <!-- 1. 数据源 : DriverManagerDataSource --> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver" /> <property name="url" value="jdbc:mysql://localhost:3306/mybatis" /> <property name="username" value="root" /> <property name="password" value="123456" /> </bean> <!-- 2. mybatis的SqlSession的工厂: SqlSessionFactoryBean dataSource:引用数据源 MyBatis定义数据源,同意加载配置 --> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource"></property> <property name="configLocation" value="classpath:config/mybatis-config.xml" /> </bean> <!-- 3. mybatis自动扫描加载Sql映射文件/接口 : MapperScannerConfigurer sqlSessionFactory basePackage:指定sql映射文件/接口所在的包(自动扫描) --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.tgb.mapper"></property> <property name="sqlSessionFactory" ref="sqlSessionFactory"></property> </bean> <!-- 4. 事务管理 : DataSourceTransactionManager dataSource:引用上面定义的数据源 --> <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource"></property> </bean> <!-- 5. 使用声明式事务 transaction-manager:引用上面定义的事务管理器 --> <tx:annotation-driven transaction-manager="txManager" /> </beans> 第七步:mybatis的配置文件 [html] view plaincopy print? <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> <configuration> <!-- 实体类,简称 -设置别名 --> <typeAliases> <typeAlias alias="User" type="com.tgb.model.User" /> </typeAliases> <!-- 实体接口映射资源 --> <!-- 说明:如果xxMapper.xml配置文件放在和xxMapper.java统一目录下,mappers也可以省略,因为org.mybatis.spring.mapper.MapperFactoryBean默认会去查找与xxMapper.java相同目录和名称的xxMapper.xml --> <mappers> <mapper resource="com/tgb/mapper/userMapper.xml" /> </mappers> </configuration> 总结 Mybatis和Spring的集成相对而言还是很简单的,祝你成功。 源码下载:SpringMVC+Spring4+Mybatis3 下篇博文我们将Hibernate和Mybatis进行一下详细的对比。 本篇文章为转载内容。原文链接:https://blog.csdn.net/konglongaa/article/details/51706991。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-09-05 11:56:25
111
转载
转载文章
... git 7. 安装MySQL MySQL :: Download MySQL Community Server 下载Debian版DEB Bundle 解压 进入目录,执行 sudo dpkg -i mysql-{common,community-client,client,community-server,server}_.deb 如果报错,执行 sudo apt-get -f install 中途设置root用户密码 8. 安装PostgreSQL 安装PostgreSQL sudo apt-get install -y postgresql-11 修改postgres用户密码 sudo -u postgres psql 进入后执行SQL ALTER USER postgres WITH PASSWORD 'postgres'; 退出 exit; 9. 安装Redis sudo apt-get install -y redis-server 修改配置文件 sudo vim /etc/redis/redis.conf 重启 sudo systemctl restart redis sudo systemctl enable redis-server 10. 安装Nginx sudo apt-get install -y nginx 修改配置文件 sudo vim /etc/nginx/nginx.conf 重启 sudo systemctl restart nginx sudo systemctl enable nginx 11. 安装VMWare Workstation 下载 https://www.vmware.com/go/getworkstation-linux 放到文件夹,进入,执行 sudo chmod +x VMware-Workstation-Full-17.0.0-20800274.x86_64.bundle sudo ./VMware-Workstation-Full-17.0.0-20800274.x86_64.bundle 安装gcc sudo apt-get install -y gcc 进入控制台,找到VMWare,开始安装,安装过程同Windows 如果如果遇到build environment error错误,执行下列命令后再重新在控制台打开图标 sudo apt-get install -y libcanberra 如果还不行,执行 sudo vmware-modconfig --console --install-all 看看还缺什么 12. 安装百度网盘 官网下载Linux版本的软件:百度网盘 客户端下载 deepin的软件包格式为deb。安装: sudo dpkg -i baidunetdisk_3.5.0_amd64.deb 最新版本 sudo dpkg -i baidunetdisk_4.17.7_amd64.deb 如果报错,执行 sudo apt-get -f install 13. 安装WPS 官网下载Linux版本的软件:WPS Office 2019 for Linux-支持多版本下载_WPS官方网站 deepin的软件包格式为deb。安装: sudo dpkg -i wps-office_11.1.0.10702_amd64.deb 最新版本 sudo dpkg -i wps-office_11.1.0.11691_amd64.deb 如果报错执行 sudo apt-get -f install wps有可能会报缺字体,缺的字体如下,双击安装 百度网盘 请输入提取码 提取码:lexo 14. 安装VS Code 官网下载Linux版本的软件:Visual Studio Code - Code Editing. Redefined deepin的软件包格式为deb。安装: sudo dpkg -i code_1.61.1-1634175470_amd64.deb 最新版本 sudo dpkg -i code_1.76.0-1677667493_amd64.deb 如果报错执行 sudo apt-get -f install 15. 安装微信、QQ、迅雷 微信 sudo apt-get install -y com.qq.weixin.deepin QQ sudo apt-get install -y com.qq.im.deepin 迅雷 sudo apt-get install -y com.xunlei.download 16. 安装视频播放器 sudo apt-get -y install smplayer sudo apt-get -y install vlc 17. 安装SSH工具electerm 下载electerm的deb版本 deepin的软件包格式为deb。安装: https://github.com/electerm/electerm/releases/download/v1.25.16/electerm-1.25.16-linux-amd64.deb sudo dpkg -i electerm-1.25.16-linux-amd64.deb 18.安装FTP/SFTP工具FileZilla sudo apt-get -y install filezilla 19. 安装edge浏览器 下载edge浏览器 deepin的软件包格式为deb。安装: 下载 Microsoft Edge sudo apt-get -y install fonts-liberation sudo apt-get -y install libu2f-udev sudo dpkg -i microsoft-edge-beta_95.0.1020.30-1_amd64.deb 最新版本 sudo dpkg -i microsoft-edge-stable_110.0.1587.63-1_amd64.deb 本篇文章为转载内容。原文链接:https://blog.csdn.net/weixin_42173947/article/details/119973703。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-11-15 19:14:44
54
转载
Docker
...别是结合Docker使用后,简直是如虎添翼! 所以今天,咱们就来聊聊这些工具,看看它们能不能成为你心目中的“神器”。 --- 2. Docker 让一切都变得简单 首先,我们得谈谈Docker。Docker是什么?简单来说,它是一种容器化技术,可以让你的应用程序及其依赖项打包成一个独立的“容器”,然后轻松地运行在任何支持Docker的环境中。 举个例子吧,假如你想在一个全新的服务器上安装WordPress,传统方法可能是手动下载PHP、MySQL、Nginx等一堆软件,再逐一配置。而如果你用Docker,只需要一条命令就能搞定: bash docker run --name wordpress -d -p 80:80 \ -v /path/to/wordpress:/var/www/html \ -e WORDPRESS_DB_HOST=db \ -e WORDPRESS_DB_USER=root \ -e WORDPRESS_DB_PASSWORD=yourpassword \ wordpress 这段代码的意思是:启动一个名为wordpress的容器,并将本地目录/path/to/wordpress挂载到容器内的/var/www/html路径下,同时设置数据库连接信息。是不是比传统的安装方式简洁多了? 不过,单独使用Docker虽然强大,但对于不熟悉命令行的人来说还是有点门槛。这时候就需要一些辅助工具来帮助我们更好地管理和调度容器了。 --- 3. Portainer 可视化管理Docker的好帮手 Portainer绝对是我最近发现的一颗“宝藏”。它的界面非常直观,几乎不需要学习成本。不管是想看看现有的容器啥情况,还是想启动新的容器,甚至连网络和卷的管理,都只需要动动鼠标拖一拖、点一点就行啦! 比如,如果你想快速创建一个新的MySQL容器,只需要打开Portainer的Web界面,点击“Add Container”,然后填写几个基本信息即可: yaml image: mysql:5.7 name: my-mysql ports: - "3306:3306" volumes: - /data/mysql:/var/lib/mysql environment: MYSQL_ROOT_PASSWORD: rootpassword 这段YAML配置文件描述了一个MySQL容器的基本参数。Portainer会自动帮你解析并生成对应的Docker命令。是不是超方便? 另外,Portainer还有一个特别棒的功能——实时监控。你打开页面就能看到每个“小房子”(就是容器)里用掉的CPU和内存情况,而且还能像穿越空间一样,去访问别的机器上跑着的那些“小房子”(Docker实例)。这种功能对于运维人员来说简直是福音! --- 4. Rancher 企业级的容器编排利器 如果你是一个团队协作的开发者,或者正在运营一个大规模的服务集群,那么Rancher可能是你的最佳选择。它不仅仅是一个Docker管理工具,更是一个完整的容器编排平台。 Rancher的核心优势在于它的“多集群管理”能力。想象一下,你的公司有好几台服务器,分别放在地球上的不同角落,有的在美国,有的在欧洲,还有的在中国。每台服务器上都跑着各种各样的服务,比如网站、数据库啥的。这时候,Rancher就派上用场了!它就像一个超级贴心的小管家,让你不用到处切换界面,在一个地方就能轻松搞定所有服务器和服务的管理工作,省时又省力! 举个例子,如果你想在Rancher中添加一个新的节点,只需要几步操作即可完成: 1. 登录Rancher控制台。 2. 点击“Add Cluster”按钮。 3. 输入目标节点的信息(IP地址、SSH密钥等)。 4. 等待几分钟,Rancher会自动为你安装必要的组件。 一旦节点加入成功,你就可以直接在这个界面上部署应用了。比如,用Kubernetes部署一个Redis集群: bash kubectl create deployment redis --image=redis:alpine kubectl expose deployment redis --type=LoadBalancer --port=6379 虽然这条命令看起来很简单,但它背后实际上涉及到了复杂的调度逻辑和网络配置。而Rancher把这些复杂的事情封装得很好,让我们可以专注于业务本身。 --- 5. Traefik 反向代理与负载均衡的最佳拍档 最后要介绍的是Traefik,这是一个轻量级的反向代理工具,专门用来处理HTTP请求的转发和负载均衡。它最厉害的地方啊,就是能跟Docker完美地融为一体,还能根据容器上的标签,自动调整路由规则呢! 比如说,你有两个服务分别监听在8080和8081端口,现在想通过一个域名访问它们。只需要给这两个容器加上相应的标签: yaml labels: - "traefik.enable=true" - "traefik.http.routers.service1.rule=Host(service1.example.com)" - "traefik.http.services.service1.loadbalancer.server.port=8080" - "traefik.http.routers.service2.rule=Host(service2.example.com)" - "traefik.http.services.service2.loadbalancer.server.port=8081" 这样一来,当用户访问service1.example.com时,Traefik会自动将请求转发到监听8080端口的容器;而访问service2.example.com则会指向8081端口。这种方式不仅高效,还极大地减少了配置的工作量。 --- 6. 总结 找到最适合自己的工具 好了,到这里咱们已经聊了不少关于服务器管理工具的话题。从Docker到Portainer,再到Rancher和Traefik,每一种工具都有其独特的优势和适用场景。 我的建议是,先根据自己的需求确定重点。要是你只想弄个小玩意儿,图个省事儿快点搞起来,那用Docker配个Portainer就完全够用了。但要是你们团队一起干活儿,或者要做大范围的部署,那Rancher这种专业的“老司机工具”就得安排上啦! 当然啦,技术的世界永远没有绝对的答案。其实啊,很多时候你会发现,最适合你的工具不一定是最火的那个,而是那个最合你心意、用起来最顺手的。就像穿鞋一样,别人觉得好看的根本不合脚,而那双不起眼的小众款却让你走得又稳又舒服!所以啊,在用这些工具的时候,别光顾着看,得多动手试试,边用边记下自己的感受和想法,这样你才能真的搞懂它们到底有啥门道! 好了,今天的分享就到这里啦!如果你还有什么问题或者想法,欢迎随时留言交流哦~咱们下次再见啦!
2025-04-16 16:05:13
97
月影清风_
转载文章
...析出哪个对象上锁? Mysql索引类型和区别,事务的隔离级别和事务原理 Spring scope 和设计模式 Sql优化 三面 fullgc的时候会导致接口的响应速度特别慢,该如何排查和解决? 项目内存或者CPU占用率过高如何排查? ConcurrentHashmap原理 数据库分库分表 MQ相关,为什么kafka这么快,什么是零拷贝? 小算法题 http和https协议区别,具体原理 四面(Leader) 手画自己项目的架构图,并且针对架构和中间件提问 印象最深的一本技术书籍是什么? 五面(HR) 没什么过多的问题,主要就是聊了一下自己今后的职业规划,告知了薪资组成体系等等。 插播一条福利!!!最近整理了一套1000道面试题的文档(详细内容见文首推荐文章),以及大厂面试真题,和最近看的几本书。 需要刷题和跳槽的朋友,这些可以免费赠送给大家,帮忙转发文章,宣传一下,后台私信【面试】免费领取! 小天:好像问了两次看书的情况诶?现在面试还问这个? 程序员H:是啊,幸亏之前为了弄懂JVM还看了两本书,不然真不知道说啥了! 小天:看来,我也要找几本书去看了,感情没看过两本书都不敢跳槽了! 程序员H:对了,还有简历,告诉你一个捷径 简历尽量写好一些,项目经验突出: 1、自己的知识广度和深度 2、自身的优势 3、项目的复杂性和难度以及指标 4、自己对于项目做的贡献或者优化 程序员H:唉~这还不能走可怎么办呀!你说,我把主管打一顿,是不是马上就可以走了? 小天:... 查看全文 http://www.taodudu.cc/news/show-3387369.html 相关文章: 阿里菜鸟面经 Java后端开发 社招三年 已拿offer 阿里 菜鸟网络(一面) 2021年阿里菜鸟网络春招实习岗面试分享,简历+面试+面经全套资料! 阿里菜鸟国际Java研发面经(三面+总结):JVM+架构+MySQL+Redis等 2021年3月29日 阿里菜鸟实习面试(一面)(含部分总结) mongodb 子文档排序_猫鼬101:基础知识,子文档和人口简介 特征工程 计算方法Gauss-Jordan消去法求线性方程组的解 使用(VAE)生成建模,理解可变自动编码器背后的数学原理 视觉SLAM入门 -- 学习笔记 - Part2 带你入门nodejs第一天——node基础语法及使用 python3数据结构_Python3-数据结构 debezium-connect-oracle使用 相关数值分析多种算法代码 android iphone treeview,Android之IphoneTreeView带组指示器的ExpandableListView效果 nginx rewrite功能使用 3-3 OneHot编码 JavaWeb:shiro入门小案例 MySQL的定义、操作、控制、查询语言的用法 MongoDB入门学习(三):MongoDB的增删查改 赋值、浅复制和深复制解析 以及get/set应用 他是吴恩达导师,被马云聘为「达摩院」首座 Jordan 标准型定理 列主元的Gauss-Jordan消元法-python实现 Jordan 块的几何 若尔当型(The Jordan form) 第七章 其他神经网络类型 解决迁移系统后无法配置启用WindowsRE环境的问题 宝塔面板迁移系统盘/www到数据盘/home 使用vmware vconverter从物理机迁移系统到虚拟机P2V 本篇文章为转载内容。原文链接:https://blog.csdn.net/m0_62695120/article/details/124510157。 该文由互联网用户投稿提供,文中观点代表作者本人意见,并不代表本站的立场。 作为信息平台,本站仅提供文章转载服务,并不拥有其所有权,也不对文章内容的真实性、准确性和合法性承担责任。 如发现本文存在侵权、违法、违规或事实不符的情况,请及时联系我们,我们将第一时间进行核实并删除相应内容。
2023-03-08 20:01:49
68
转载
转载文章
...开放源代码:(源协议使用宽松的“Mozilla Public License”许可,允许将开源代码与闭源代码混在一起使用。) 完全的ACID支持 可横向扩展的关系型数据库(RDBMS) 支持OLAP应用,采用MPP(Massively Parallel Processing:大规模并行处理系统)架构模式 支持OLTP应用,读写性能可扩展 集群级别的ACID特性 多租户安全 也可被用作分布式Key-Value存储 事务处理与数据分析处理混合型数据库 支持丰富的SQL语句类型,比如:关联子查询 支持绝大部分PostgreSQL的SQL语句 分布式多版本并发控制(MVCC:Multi-version Concurrency Control) 支持JSON和XML格式 Postgres-XL缺少的功能 内建的高可用机制 使用外部机制实现高可能,如:Corosync/Pacemaker 有未来功能提升的空间 增加节点/重新分片数据(re-shard)的简便性 数据重分布(redistribution)期间会锁表 可采用预分片(pre-shard)方式解决,在同台物理服务器上建立多个数据节点,每个节点存储一个数据分片。数据重分布时,将一些数据节点迁出即可 某些外键、唯一性约束功能 Postgres-XL架构 [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(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
转载
JQuery插件下载
...件”是一款专为提升网页数据展示效果与用户体验而设计的高级交互组件。它采用了业界流行的jQuery库结合CSS3的强大功能,将传统的HTML表格进行彻底革新,以无序列表的形式构建,不仅拥有出色的响应式布局特性,能够自动适应各种屏幕尺寸,包括桌面、平板及手机等移动设备,确保在不同环境下均能提供清晰易读的数据视图。该插件的核心亮点在于其斑马线隔行变色功能,通过巧妙的CSS3样式规则实现交替行背景颜色变化,显著增强了表格内容的可扫描性,使用户能够快速定位和区分不同的行记录。此外,响应式设计使得在窄屏或小屏幕设备上时,表格可以智能地调整列宽和布局,保持最佳的视觉效果和操作便捷性。总之,这款插件是网页开发者优化数据展示、增强网站专业感与用户友好度的理想工具,无论是企业报表、数据分析还是内容管理系统中复杂数据的呈现,都能发挥出色的表现力和实用性。 点我下载 文件大小:54.65 KB 您将下载一个JQuery插件资源包,该资源包内部文件的目录结构如下: 本网站提供JQuery插件下载功能,旨在帮助广大用户在工作学习中提升效率、节约时间。 本网站的下载内容来自于互联网。如您发现任何侵犯您权益的内容,请立即告知我们,我们将迅速响应并删除相关内容。 免责声明:站内所有资源仅供个人学习研究及参考之用,严禁将这些资源应用于商业场景。 若擅自商用导致的一切后果,由使用者承担责任。
2023-06-23 23:25:48
48
本站
Java
...之前有一篇文章介绍了计算机领域的分词器词汇词典:点这里传送过去 但这里面只有计算机领域的术语,对于常用中文,比如“吃饭”、“逛街”...等词汇是不包括的。 所以,如果大家需要对日常中文文章或语料做分词,需要用这里的词典。两个词典可以并存,配置到分词器的配置文件中。 2. 下载地址 点我免费下载 词库txt文件一览(49万多个词汇): 建议:如果你的程序对分词比较敏感,请务必先小范围用少量样本测试试用,看看分词效果是否符合预期,没有问题再放入正式环境。 3. 分词器使用 关于分词器的使用,见本文第一小节的链接,那个链接里面有介绍。 如果你是用的是IKAnalyzer,可以把新的词典加入到配置文件中:IKAnalyzer.cfg.xml 4. 补充说明 尽管该文章以IKAnalyzer为例,但是这个词典是通用的,它的格式是“词汇1\n词汇2\n词汇3\n”,即用回车符分隔的一个个词汇。很多分词器都是通用的。 分词器有很多,大家根据实际需求选择使用。比如: IK Analyzer:一款基于Java开发的开源中文分词工具,广泛应用于Elasticsearch和Solr中。 Ansj:一个高效的Java分词框架,支持多种分词模式如最大匹配、最小切分等。 Stanford Segmenter:斯坦福大学提供的分词器,基于统计模型和规则,具有较高的准确性。 FudanNLP分词器:复旦大学自然语言处理小组研发的分词系统。 jieba分词:Python社区中流行的开源中文分词库,支持精确模式、全模式、搜索引擎模式等多种分词模式。 LTP(哈工大 Language Technology Platform)分词器:哈尔滨工业大学开发的一套全面的自然语言处理工具包,其中包含高质量的分词模块。 THULAC:由清华大学自然语言处理与社会人文计算实验室推出的分词和词性标注工具。 HanLP:由李航团队开发的自然语言处理库,包含高效准确的分词组件。
2024-01-27 19:37:56
370
admin-tim
HBase
...景。你会如何选型? mysql、mongo、elasticsearch等完全可以,当然,你肯定不会忘了hbase。“海量数据存储”的海量,非hbase莫属。 几种常见数据库的对比如下: 2. hbase应用场景 如果你的查询场景就是根据key拿到结果,没有其它的过滤筛选条件,这就是经典的“点查”,“点查”在hbase上是非常合适的。 当然,除了hbase,还有很多适合“点查”的数据库,比如aws的dynamodb、google的bigtable。但一般公司或自用站点,还是用hbase更合适。 不用很纠结技术选型,hbase依旧非常经典,而且版本也在源源不断的迭代,适合自己的就是最好的。 3. hbase安装依赖 如果你的机器资源不足或只有一两台机器的站点,那么不建议使用hbase,因为它严格依赖hdfs存储系统和hadoop计算架构,以及zookeeper。 如果你的机器配置不高,在安装完这一些,还没安装完hbase的时候,内存就已经被占据了不少了。 4. 场景解析 本篇文章更关注于选型的探讨,不涉及原理的解析。所以当什么场景下应该会使用到hbase,我们再来回顾一下。 hbase的查询方式是通过rowkey做交互。所以,如果你的查询能够抽象为用rowkey直接获取,那么就适合用hbase查询。 这里的rowkey不仅仅是一个id或uuid,它甚至可以是几个字段组成的一个有限长度的字符串,比如“zhangsan-18-beijing”都是可以的。 但是,hbase不能带有其它的filter,比如你要过滤age<18,虽然可以使用hbase的一些协处理器实现,但性能会十分让你惊讶。性能是不好的。 所以,如果你的查询能够抽象为有意义的rowkey,那直接用hbase存储和查询是没有问题的。而且要注意rowkey的长度和散列,太长的rowkey会带来性能的损失,不具备散列特性的rowkey会带来热点问题。 5 自定义过滤下的hbase 从本篇文章的第一小节可以看到,极好的一列出现了三位选手:hbase、redis和elasticsearch 大数据情况下,或海量数据场景下,咱就先让redis休个假吧。如果你的数据较为海量,使用elasticsearch+hbase的搜索存储架构是非常好的选择。 这里引用阿里云的一篇文章:https://developer.aliyun.com/article/941191 6 总结 只有点查的场景,你只需要使用hbase。 只有搜索的场景,其实你完全可以只使用elasticsearch。 但当数据量不断扩大,而且参数搜索的字段可能只是所有字段的一部分,你不妨使用elasticsearch+hbase架构。搜索字段放elasticsearch,需要拿出来数据计算或展示的字段放hbase。各司其职,索引库+存储库分离。 索引库+存储库这个思想也不是为elasticsearch+hbase特定准备的,比如索引库你可以替换为lucene或solr,存储库可以替换为casandra或berkeleydb等都是可以的。任意两个组件都可以组合。
2024-01-27 18:28:18
556
admin-tim
Python
...thon中列表的属性计算之后,我们还可以探索更多高级且实用的列表操作技巧。例如,Python 3.8引入了一种新的表达式结构——" walrus operator "(:=),它使得在单行代码中计算列表长度、查找元素索引以及执行条件判断更为简洁高效。此外,对于大数据处理或科学计算场景,NumPy库提供的ndarray对象在性能上远超Python原生列表,可以实现快速的矩阵运算和统计分析。 近期,一篇发布于“Real Python”网站的文章深入探讨了如何利用列表推导式(List Comprehensions)和生成器表达式(Generator Expressions)对列表进行复杂操作,如过滤、映射和压缩数据,从而提升代码可读性和运行效率。文章还介绍了functools模块中的reduce函数,用于对列表元素执行累积操作,如求乘积、求序列中最长连续子序列等。 另外,在实际编程实践中,掌握列表的排序、切片、连接、复制等基本操作同样至关重要。例如,使用sorted()函数或列表的sort()方法对列表进行排序;利用切片技术实现列表的部分提取或替换;通过extend()和+运算符完成列表合并等。这些操作不仅能丰富你对Python列表的理解,更能在日常开发任务中助你事半功倍。 总的来说,深入学习和熟练运用Python列表的各种特性与功能,不仅有助于数据分析和处理,更能提升代码编写质量,使程序更加简洁、高效。同时,关注Python社区的最新动态和最佳实践,将能持续拓展你的编程技能边界,紧跟时代发展步伐。
2023-10-05 18:16:18
359
算法侠
MySQL
MySQL , MySQL是一个开源的关系型数据库管理系统,由Oracle公司开发并维护。在本文的语境中,MySQL被用于存储和管理结构化数据,用户可通过SQL语言实现对数据库的各种操作,如新建、查询、更新和删除数据等。MySQL因其稳定、高效、可扩展性强以及支持多种操作系统平台而被广泛应用于网站开发、企业级应用系统以及各种需要持久化存储数据的应用场景。 关系型数据库管理系统(RDBMS) , 关系型数据库管理系统是一种建立在关系模型基础上的软件系统,它能通过表格、列和行的形式来组织、存储和管理数据,并利用SQL(Structured Query Language)语句进行数据操作。在文章中,MySQL即是一个典型的关系型数据库管理系统,通过它可以创建多个相互关联的数据库,确保数据的一致性和完整性。 SQL , SQL(Structured Query Language)是一种标准化的编程语言,用于管理和处理关系型数据库中的数据。在本文所描述的MySQL环境中,用户使用SQL命令来与数据库交互,例如“CREATE DATABASE”用于创建新的数据库,“SHOW DATABASES”则用于查看所有已存在的数据库列表。SQL语言不仅包括数据定义语言(DDL,如创建表或数据库),还包括数据操作语言(DML,如插入、更新和删除记录)以及数据查询语言(DQL,如SELECT语句)。
2023-08-12 18:53:34
138
码农
Python
...视化的功能,将数学函数以图像的形式展现,帮助用户更好地理解函数的特点和性质。 Matplotlib库 , Matplotlib是一个专为Python设计的数据可视化库,提供了一整套绘制静态、动态、交互式图表的功能。在文中,开发者导入了Matplotlib.pyplot模块并使用其plot()函数来绘制函数f(x)=x^2的图像,通过设置线型、颜色等属性优化图像显示效果,使用户能够更清晰地观察函数曲线的变化特点。 STEM教育 , STEM代表科学(Science)、技术(Technology)、工程(Engineering)、数学(Mathematics)四门学科领域的综合教育。在文章语境下,Python编程与Matplotlib绘图工具被整合进数学教学中,体现了STEM教育理念,即鼓励学生通过实践操作,如编写代码绘制函数图像,以跨学科的方式理解和掌握数学概念,提升解决问题的能力以及对科技应用的敏感度。
2023-10-08 22:57:22
84
算法侠
MySQL
如果你在使用MySQL时发现了一个问题,反馈你不存在数据库表,可能是由于以下缘由: 问题信息:Table 'database_name.table_name' doesn't exist. 问题缘由可能是: 1. 表空间名称输入问题。请核实您输入的表空间名称是否准确。 比方说,输入“my_database”而不是“myDataBase”。 2. 数据表名问题。请核实您输入的数据表名是否准确。 比方说,输入“user”而不是“users”。 3. 您没有许可查阅该数据库表。请核实您是否有查阅该表所需的许可。 4. 数据库表已被删除。请核实您输入的表名是否准确,或者您的表是否已被删除。 5. 数据库连接故障。请核实您的MySQL连接是否正常工作。 比方说,您的MySQL服务器是否正常工作,或者您是否使用了准确的用户名和密码。 解决方法: 1. 确认表空间名称和表名称是否准确。 2. 确认您是否具有查阅该数据库表的许可。 3. 如果表已经被删除,请尝试恢复表或使用备份复制该表。 4. 确认MySQL连接是否正常。 如果您还是无法解决问题,请联系MySQL管理员或开发人员进行支持。
2023-11-28 12:42:54
55
算法侠
Python
...,Python的算术计算功能十分强劲,可以用来完成各种算术计算。下面我们就来介绍Python中求一个数的个位、十位和百位的方法。 求一个三位数的个位、十位、百位 number = 123 a = number % 10 取个位 b = (number // 10) % 10 取十位 c = number // 100 取百位 显示后果 print("个位数是:%d,十位数是:%d,百位数是:%d" % (a, b, c)) 首先,我们需要设定一个三位数,这里我们选择了123作为例子。接着,我们各自用%和//计算符来获取个位、十位和百位。其中,%代表求余(余数)计算,//代表整除计算。通过以上代码,我们可以得到number的个位是3,十位是2,百位是1。最后,我们使用字符串的格式化显示,把后果显示到终端上。 除了三位数,其实我们可以使用类似的方法来求任何多位数的个位、十位和百位。只需要稍稍更改上述代码即可。比如,如果我们要求一个五位数的个位、十位和百位,只需要将代码中的100改成1000即可: 求一个五位数的个位、十位、百位 number = 12345 a = number % 10 取个位 b = (number // 10) % 10 取十位 c = (number // 100) % 10 取百位 显示后果 print("个位数是:%d,十位数是:%d,百位数是:%d" % (a, b, c)) Python的算术计算功能非常强劲,不仅仅能够求出一个数的个、十、百位,还可以进行各种算术计算。希望大家能通过学习Python,精通更多的算术及编程知识。
2023-04-20 12:09:22
42
软件工程师
Python
...会出现负数的情况。 num_list = [1, -2, 3, 4, -5] sum = 0 for num in num_list: if num >0: sum += num print(sum) 以上是一个求正数和的简单示例,该程序会遍历序列中的每个元素,如果元素为正数,则将其加入到加总变量中。如果执行该代码,会得到如下结果: -1 可以看到,虽然序列中拥有正数,但最终的和却是负数,这是由于序列中同样拥有负数所致。如果想要得到正确的结果,需要在代码中进行修改: num_list = [1, -2, 3, 4, -5] sum = 0 for num in num_list: if num >0: sum += num print(abs(sum)) 在修改后的代码中,我们使用了Python内置函数abs(),该函数可以返回指定数值的绝对值,所以即使拥有负数,也不会影响结果的正确性。执行以上代码,我们得到的结果就是: 8 可以看到,我们已经顺利地解决了正数加总为负数的问题,在实际应用中,我们需要根据具体情况进行相应的处理,使得代码能够实现预期效果。
2023-04-28 23:59:16
1590
软件工程师
VUE
...形式。对于处理金额、统计数据和其他需要显示众多数字的项目尤其有用。 Vue提供了一个内置处理器currency,可以自动地将数字通过千位分隔符变为金额格式。这个处理器可以用于模板中的数据显示中: { { 1000 | currency } } // 输出: $1,000.00 当你需要自定义千位分隔符或数目时,Vue的计算字段可以发挥作用。下面的代码将数字变为金额格式,并允许您在千位分隔符和小数位数间输出。 computed: { formattedAmount() { let amount = this.amount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return "$" + amount + (this.decimals ? "." + this.decimals : ""); } } 在这个计算字段中,我们先将数字变为字符串,然后使用正则表达式来添加千位符号。最后我们将金额符号和小数位添加到字符串结尾。 最后,我们可以将计算字段用于模板中: { { formattedAmount } } 上面的代码将会输出格式化后的金额金额。 千位分隔符对一些项目来说是必需品。Vue提供了很多方便的工具使得我们能够轻松地将数字变为金额格式。
2023-12-25 14:14:35
46
电脑达人
MySQL
MySQL , MySQL是一种广泛使用的开源关系型数据库管理系统(RDBMS),由Oracle公司开发并维护。在本文的语境中,MySQL指的是用户需要在Windows操作系统下启动和管理的数据库服务。MySQL以其稳定、安全、性能优越和跨平台支持等特点,被众多网站、应用程序以及企业级系统选作数据存储解决方案。 命令行窗口 , 命令行窗口,又称为控制台或终端,是Windows操作系统中的一个界面程序,允许用户通过输入文本命令来与操作系统进行交互。在本文中,用户需通过命令行窗口执行特定的命令以启动MySQL服务器和连接到MySQL数据库,这包括更改目录至MySQL的bin目录,运行mysqld命令启动MySQL服务,以及使用mysql命令登录MySQL服务器等操作。 root用户 , 在MySQL数据库系统中,“root”是一个特殊的系统管理员账号,拥有对整个MySQL服务器及其所有数据库的最高权限。启动MySQL数据库后,用户通过命令行工具以root用户身份登录,可以执行创建数据库、修改用户权限、删除数据表等各种高级管理操作。在本文的步骤中,用户需要输入root用户的密码来验证身份,并进入MySQL的命令行界面进行后续管理任务。
2023-12-12 11:10:15
135
数据库专家
MySQL
MySQL 是一款普遍的关联型DBMS,我们可以通过一些基础操作来看 MySQL 中的表格基本信息。 首先,我们需要登陆到 MySQL 数据库中。下面是用命令行方式登陆 MySQL 的示例脚本: mysql -h host -u user -p 其中, host 表示 MySQL 数据库服务器 IP 地址或服务器名称, user 是接入 MySQL 数据库所使用的账户名, -p 是要求输入口令,用于校验登陆。 接着,我们可以查看 MySQL 中当前所有的数据库,使用 的命令为: SHOW DATABASES; 然后,我们需要选择一个数据库进行操作,使用的命令为: USE database; 其中, database 表示需要操作的数据库名称。 现在,我们已经成功进入到了 MySQL 数据库中,可以看到库中的表格基本信息,使用命令如下: SHOW TABLES; 执行该命令后,MySQL 将会显示该库中所有的表名称。 最后,我们可以查看特定表中的所有信息,使用的命令如下: DESCRIBE table; 其中, table 表示需要查看的表名称。 通过上述基础操作,我们可以轻松地了解 MySQL 数据库中的基础表信息。
2023-08-18 09:15:20
63
算法侠
站内搜索
用于搜索本网站内部文章,支持栏目切换。
知识学习
实践的时候请根据实际情况谨慎操作。
随机学习一条linux命令:
echo $BASH_VERSION
- 显示当前bash shell版本。
推荐内容
推荐本栏目内的其它文章,看看还有哪些文章让你感兴趣。
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
历史内容
快速导航到对应月份的历史文章列表。
随便看看
拉到页底了吧,随便看看还有哪些文章你可能感兴趣。
时光飞逝
"流光容易把人抛,红了樱桃,绿了芭蕉。"