postgre安装

1、安装rpm文件

yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

2、安装客户端

yum install postgresql10

3、安装服务端

yum install postgresql10-server

4、初始化

/usr/pgsql-10/bin/postgresql-10-setup initdb

5、设置自动启动并且启动postgresql服务

systemctl enable postgresql-10
systemctl start postgresql-10

登录

su - postgres

psql

退出
\q
create user test_user with password 'abc123';            // 创建用户
create database test_db owner test_user;                 // 创建数据库
grant all privileges on database test_db to test_user;   // 授权

drop table student2; 删除表

CREATE TABLE student(id integer,name varchar,sex varchar); 创建表

INSERT INTO student(id,name,sex)VALUES(1,'Aspirin','M'); 插入数据
CREATE TABLE student2(id smallint,name varchar,sex varchar);
INSERT INTO student2(id,name,sex)VALUES(1909,'Aspirin','M');

CREATE TABLE student3(id smallint,id2 integer,id3 bigint,name varchar,sex varchar);
INSERT INTO student3(id,id2,id3,name,sex)VALUES(19090,2121290,212019200,'Aspirin','M');

CREATE TABLE student4(id real,id2 double precision,id3 smallserial,id4 serial,id5 bigserial,name varchar,sex varchar);
INSERT INTO student4(id,id2,id3,id4,id5,name,sex)VALUES(28982932,09898984938439,9092,21209093,809840389042,'Aspirin','M');

CREATE TABLE student6(id decimal,id2 numeric,name varchar,sex varchar);
INSERT INTO student6(id,id2,name,sex)VALUES(12331314414141,211212114441213,'Aspirin','M');

CREATE TABLE student7(id decimal(30,2),id2 numeric(90,3),name varchar,sex varchar);
INSERT INTO student7(id,id2,name,sex)VALUES(123313.14,2112121144412.13,'Aspirin','M');

CREATE TABLE student8(id numeric(90,3),name varchar,sex varchar);
INSERT INTO student8(id,name,sex)VALUES(123313.14,'Aspirin','M');

CREATE TABLE student9(id numeric(5,2),name varchar,sex varchar);
INSERT INTO student9(id,name,sex)VALUES(100.01,'Aspirin','M');


CREATE TABLE student10(id decimal(5,2),id2 numeric(5,2),name varchar,sex varchar);
INSERT INTO student10(id,id2,name,sex)VALUES(100.14,100.13,'Aspirin','M');

切换数据库

\c postgres;

修改远程访问

-bash-4.2$ vi /var/lib/pgsql/10/data/postgresql.conf
listen_addresses = '*'
-bash-4.2$ vi /var/lib/pgsql/10/data/pg_hba.conf
# IPv4 local connections:
#host    all             all             127.0.0.1/32            ident

在idnet下增加一行
host    all             all             0.0.0.0/0               md5
-bash-4.2$ exit

登出

重启

systemctl restart postgresql-10.service

1、修改默认生成的 postgres 用户密码(此postgres非上面的postgres用户,此为数据库的用户,上面的为操作系统的用户)

su - postgres
psql -U postgres
alter user postgres with encrypted password '123456';

二 python连接postgresql

yum -y install epel-release
yum -y install python-pip
yum -y install python-psycopg2

kafka查看topic

bin/kafka-topics.sh --list --zookeeper localhost:2181

kafka查看topic中数据

/opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server 10.0.2.20:9092 --topic JDBC02  --from-beginning
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

时空无限

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值