• centos 安装 jdk PostgreSQL


    1.下载:

    anzhuang  jDK

    http://blog.csdn.net/youzhouliu/article/details/51183115

    -------------------------------

    http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

    http://www.cnblogs.com/tjpanda88/p/4306149.html

    ---------------------------------------------------------------------------------------------------------------

    2.//官方安装_Postgresql

    https://www.postgresql.org/download/linux/redhat/

    3.//博客安装过程

    http://blog.csdn.net/lk10207160511/article/details/50359549

    http://www.jianshu.com/p/7e95fd0bc91a

    1.添加RPM

      
    [root@localhost ~]# yum install https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm Loaded plugins: fastestmirror, langpacks pgdg-centos95-9.5-2.noarch.rpm | 5.3 kB 00:00 Examining /var/tmp/yum-root-a5MmUk/pgdg-centos95-9.5-2.noarch.rpm: pgdg-centos95-9.5-2.noarch Marking /var/tmp/yum-root-a5MmUk/pgdg-centos95-9.5-2.noarch.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package pgdg-centos95.noarch 0:9.5-2 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pgdg-centos95 noarch 9.5-2 /pgdg-centos95-9.5-2.noarch 2.2 k Transaction Summary ================================================================================ Install 1 Package Total size: 2.2 k Installed size: 2.2 k Is this ok [y/d/N]: y Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Warning: RPMDB altered outside of yum. ** Found 4 pre-existing rpmdb problem(s), 'yum check' output follows: ipa-client-4.4.0-12.el7.centos.x86_64 has installed conflicts freeipa-client: ipa-client-4.4.0-12.el7.centos.x86_64 ipa-client-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-client-common: ipa-client-common-4.4.0-12.el7.centos.noarch ipa-common-4.4.0-12.el7.centos.noarch has installed conflicts freeipa-common: ipa-common-4.4.0-12.el7.centos.noarch 1:java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64 has missing requires of tzdata-java >= ('0', '2015d', None) Installing : pgdg-centos95-9.5-2.noarch 1/1 Verifying : pgdg-centos95-9.5-2.noarch 1/1 Installed: pgdg-centos95.noarch 0:9.5-2 Complete!

    2.安装PostgreSQL 9.5


    [root@localhost
    ~]# yum install postgresql95-server postgresql95-contrib Loaded plugins: fastestmirror, langpacks Repository pgdg95 is listed more than once in the configuration Repository pgdg95-source is listed more than once in the configuration Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package postgresql95-contrib.x86_64 0:9.5.6-2PGDG.rhel7 will be installed --> Processing Dependency: postgresql95-libs(x86-64) = 9.5.6-2PGDG.rhel7 for package: postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64 --> Processing Dependency: postgresql95(x86-64) = 9.5.6-2PGDG.rhel7 for package: postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64 --> Processing Dependency: libpq.so.5()(64bit) for package: postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64 ---> Package postgresql95-server.x86_64 0:9.5.6-2PGDG.rhel7 will be installed --> Running transaction check ---> Package postgresql95.x86_64 0:9.5.6-2PGDG.rhel7 will be installed ---> Package postgresql95-libs.x86_64 0:9.5.6-2PGDG.rhel7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: postgresql95-contrib x86_64 9.5.6-2PGDG.rhel7 pgdg95 530 k postgresql95-server x86_64 9.5.6-2PGDG.rhel7 pgdg95 4.1 M Installing for dependencies: postgresql95 x86_64 9.5.6-2PGDG.rhel7 pgdg95 1.3 M postgresql95-libs x86_64 9.5.6-2PGDG.rhel7 pgdg95 219 k Transaction Summary ================================================================================ Install 2 Packages (+2 Dependent packages) Total size: 6.1 M Total download size: 530 k Installed size: 26 M Is this ok [y/d/N]: y Downloading packages: pgdg95/7/x86_64/prestodelta | 12 kB 00:02 postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64.rpm | 530 kB 00:02 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : postgresql95-libs-9.5.6-2PGDG.rhel7.x86_64 1/4 Installing : postgresql95-9.5.6-2PGDG.rhel7.x86_64 2/4 Installing : postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64 3/4 Installing : postgresql95-server-9.5.6-2PGDG.rhel7.x86_64 4/4 Verifying : postgresql95-contrib-9.5.6-2PGDG.rhel7.x86_64 1/4 Verifying : postgresql95-server-9.5.6-2PGDG.rhel7.x86_64 2/4 Verifying : postgresql95-libs-9.5.6-2PGDG.rhel7.x86_64 3/4 Verifying : postgresql95-9.5.6-2PGDG.rhel7.x86_64 4/4 Installed: postgresql95-contrib.x86_64 0:9.5.6-2PGDG.rhel7 postgresql95-server.x86_64 0:9.5.6-2PGDG.rhel7 Dependency Installed: postgresql95.x86_64 0:9.5.6-2PGDG.rhel7 postgresql95-libs.x86_64 0:9.5.6-2PGDG.rhel7 Complete!
      

    3.初始化数据库

    [root@localhost ~]# /usr/pgsql-9.5/bin/postgresql95-setup initdb Initializing database ... OK
    4.设置开机自启动

    [root@localhost
    ~]# systemctl enable postgresql-9.5 Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.5.service to /usr/lib/systemd/system/postgresql-9.5.service.
    5.启动服务
    [root@localhost
    ~]# systemctl start postgresql-9.5 [root@localhost ~]# systemctl status postgresql-9.5 ● postgresql-9.5.service - PostgreSQL 9.5 database server Loaded: loaded (/usr/lib/systemd/system/postgresql-9.5.service; enabled; vendor preset: disabled) Active: active (running) since 一 2017-03-27 12:23:28 CST; 49s ago Process: 7768 ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 (code=exited, status=0/SUCCESS) Process: 7761 ExecStartPre=/usr/pgsql-9.5/bin/postgresql95-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS) Main PID: 7770 (postgres) CGroup: /system.slice/postgresql-9.5.service ├─7770 /usr/pgsql-9.5/bin/postgres -D /var/lib/pgsql/9.5/data ├─7779 postgres: logger process ├─7781 postgres: checkpointer process ├─7782 postgres: writer process ├─7783 postgres: wal writer process ├─7784 postgres: autovacuum launcher process └─7785 postgres: stats collector process 3月 27 12:23:27 localhost.localdomain systemd[1]: Starting PostgreSQL 9.5 da... 3月 27 12:23:27 localhost.localdomain pg_ctl[7768]: < 2017-03-27 12:23:27.60…程 3月 27 12:23:27 localhost.localdomain pg_ctl[7768]: < 2017-03-27 12:23:27.60…. 3月 27 12:23:28 localhost.localdomain systemd[1]: Started PostgreSQL 9.5 dat... Hint: Some lines were ellipsized, use -l to show in full.
    //自此,PostgreSQL 9.5 安装完成,此过程中注意安装权限,我在安装过程中一直使用的是root用户进行的安装。


    [root@localhost
    ~]# psql --version psql (PostgreSQL) 9.5.6





    接下来,进行一下简单的配置。

    //su postgres  切换用户,执行后提示符会变为 '-bash-4.2$'
    [root@localhost ~]# su postgres

    //登录数据库,执行后提示符变为
    bash
    -4.2$ psql -U postgres could not change directory to "/root": Permission denied psql (9.5.6) Type "help" for help.
    //设置postgres用户密码 postgres
    =# alter user postgres with password 'postgres123'

    //退出数据库
    postgres-# q
    //系统管理用的帐号和密码变更完成,现在配置一下远程连接 可以参考:http://www.jianshu.com/p/7e95fd0bc91a或者http://www.cnblogs.com/Amos-Turing/p/7681323.html

    .开启远程访问
        vi /var/lib/pgsql/9.5/data/postgresql.conf
        修改#listen_addresses = 'localhost'  为  listen_addresses='*'
        当然,此处‘*’也可以改为任何你想开放的服务器IP



    //远程连接配置完成,由于系统原因,还需要在防火墙中打开相应的端口。
    bash
    -4.2$ firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: wlp4s0 sources: services: dhcpv6-client ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules:
    //开放postgresql服务 bash
    -4.2$ firewall-cmd --add-service=postgresql --permanent success
    //重载防火墙 bash
    -4.2$ firewall-cmd --reload success bash-4.2$ firewall-cmd --list-all public (active) target: default icmp-block-inversion: no interfaces: wlp4s0 sources: services: dhcpv6-client postgresql ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules:
    //最后一步,不能忘记的,是重启数据库服务,使配置生效。 bash
    -4.2$ systemctl restart postgresql-9.5.service bash-4.2$

     卸载数据库:

    http://www.cnblogs.com/tjpanda88/p/4306149.html4:

    http://www.educity.cn/linux/1581284.html

    ---------------------------------------------------------------------------------------------------------------

  • 相关阅读:
    DTD与shema学习
    xml基本语法学习
    快速写出main方法和system.out.print()
    Eclipse常见快捷键
    System.out.print()与toString()
    HttpURLConnection学习
    如何查看开关机时间
    阿里云云服务器硬盘分区及挂载
    java环境搭建
    使用jstack 发现死锁
  • 原文地址:https://www.cnblogs.com/Amos-Turing/p/6625663.html
Copyright © 2020-2023  润新知