失效链接处理 |
PostgreSQL研究 PDF 下载
本站整理下载:
提取码:ks6v
相关截图:
主要内容:
【1 - Linux安装PostgreSQL】 1.查看是否已经安装:$yum list installed |grep post postgresql-libs.x86_64 8.4.18-1.el6_4 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 2.卸载:$ yum remove postgresql-libs.x86_64 3.查看Linux版本:$lsb_release -a 4.到官网获取对应版本的安装包:https://www.postgresql.org/download/linux/redhat/ 5.官方网站给的安装方法【可能是无法连接网络安装失败】 Install the repository RPM:yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-redhat10- 10-1.noarch.rpm Install the client packages:yum install postgresql10 Optionally install the server packages:yum install postgresql10-server Optionally initialize the database and enable automatic start:service postgresql-10 initdb chkconfig postgresql-10 on service postgresql-10 start 【2 - Linux安装PostgreSQL】 1.查看官方文档http://www.postgres.cn/docs/9.5/install-getsource.html 2.下载source文件: $wget https://ftp.postgresql.org/pub/source/v10.1/postgresql-10.1.tar.bz2 3.解压: $bunzip2 postgresql-10.1.tar.bz2 $tar xf postgresql-10.1.tar 4.执行官方文档安装操作: ./configure make sumake install adduser postgres mkdir /usr/local/pgsql/data chown postgres /usr/local/pgsql/data su - postgres /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & /usr/local/pgsql/bin/createdb test /usr/local/pgsql/bin/psql test 【修改postgres密码】 /usr/local/pgsql/bin/psql ALTER USER postgres WITH PASSWORD 'postgres'; 5.创建数据库: psql CREATE USER xxxx1 WITH PASSWORD 'xxxx'; CREATE DATABASE xxxx2; GRANT ALL PRIVILEGES ON DATABASE xxxx2 to xxxx1; 6.停止数据库: /usr/local/pgsql/bin/pg_ctl stop -D /usr/local/pgsql/data
7.配置远程访问: 7.1 $vi data/pg_hba.conf 文件最后加上 host all all 0.0.0.0/0 md5 7.2 $vi data/postgresql.conf 查找listen_addresses,将其设置为listen_addresses = '*' 8.启动数据库: /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & 9.通过pgadmin连接数据库: 10.pg导出表结构: ./pg_dump -h 172.16.19.168 -p 5432 -U test -s test10thousand > /home/postgres/q.sql 解释:-s 选项用来只导出表结构,而不会导出表中的数据 -t 选项用来指定要导出的数据库表 导出数据: c:\Program Files\PostgreSQL\10\bin>pg_dump -h 172.16.19.168 -p 5432 -U postgres --column-inserts -t \"AnalysisJobQueue\" -d metadb -f d:\share\pg_dump.sql 11.PostgreSQL问题解决--连接数过多 【问题】Connection could not be allocated because: FATAL: sorry, too many clients already 【解决】 First find your postgresql.conf file If you don’t know where it is, query the database with the sql: SHOW config_file; Mine is in: /var/lib/pgsql/data/postgresql.conf Login as root and edit that file. Search for the string: “max_connections”. You’ll see a line that says max_connections=100. Set that number bigger, check the limit for your postgresql version. Restart the postgresql database for the changes to take effect. 12.创建dblink: 执行sql语句: create extension dblink; 报错: ERROR: could not open extension control file "/usr/local/pgsql/share/extension/dblink.control": No such file or directory 解决:
cd /home/pg/postgresql-10.1/contrib/dblink make make install 然后在执行create extension dblink
|