欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

CentOS7 yum PostgreSQL(11) 并啟用 python...3編寫存儲(chǔ)過(guò)程(Python3

系統(tǒng) 1725 0

CentOS7 yum PostgreSQL(11) 并啟用 python3編寫存儲(chǔ)過(guò)程(Python3.6)

一、安裝python3.6

  1. 下載Python3.6.6.tgz 至 /tmp 下
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # wget -c https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
              
            
          
  1. 解壓 Python3.6.6.tgz
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # tar -zvxf Python-3.6.6.tgz 
              
            
          
  1. 安裝需要的依賴包(dependence)
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # yum install gcc openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel -y
              
            
          
  1. 編譯安裝
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # cd Python-3.6.6/
              
              
                [
              
              root@localhost Python-3.6.6
              
                ]
              
              
                # ./configure --prefix=/usr/local/Python36 --enable-shared
              
              
                [
              
              root@localhost Python-3.6.6
              
                ]
              
              
                # make && make install
              
              
………………………………省略………………………………
Looking 
              
                in
              
               links: /tmp/tmpjbfza4ut
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-10.0.1 setuptools-39.0.1

            
          
  1. 將python3.6 與pip3 軟鏈接到/usr/local/bin目錄下
            
              
                [
              
              root@localhost bin
              
                ]
              
              
                # ln -s /usr/local/Python36/bin/python3.6 /usr/local/bin/python3
              
              
                [
              
              root@localhost bin
              
                ]
              
              
                # ln -s /usr/local/Python36/bin/pip3 /usr/local/bin/pip3
              
            
          
  1. 添加動(dòng)態(tài)庫(kù)配置文件
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # python3
              
              
python3: error 
              
                while
              
               loading shared libraries: libpython3.6m.so.1.0: cannot 
              
                open
              
               shared object file: No such 
              
                file
              
               or directory  
              
                <=
              
              
                ==
              
               執(zhí)行python3 報(bào)錯(cuò)

              
                [
              
              root@localhost ~
              
                ]
              
              
                # ldd /usr/local/bin/python3 
              
              
	linux-vdso.so.1 
              
                =
              
              
                >
              
              
                (
              
              0x00007ffd451fc000
              
                )
              
              
	libpython3.6m.so.1.0 
              
                =
              
              
                >
              
               not found  
              
                <=
              
              
                ==
              
               此動(dòng)態(tài)文件未找到
	libpthread.so.0 
              
                =
              
              
                >
              
               /lib64/libpthread.so.0 
              
                (
              
              0x00007f725d3d5000
              
                )
              
              
	libdl.so.2 
              
                =
              
              
                >
              
               /lib64/libdl.so.2 
              
                (
              
              0x00007f725d1d1000
              
                )
              
              
	libutil.so.1 
              
                =
              
              
                >
              
               /lib64/libutil.so.1 
              
                (
              
              0x00007f725cfce000
              
                )
              
              
	libm.so.6 
              
                =
              
              
                >
              
               /lib64/libm.so.6 
              
                (
              
              0x00007f725cccc000
              
                )
              
              
	libc.so.6 
              
                =
              
              
                >
              
               /lib64/libc.so.6 
              
                (
              
              0x00007f725c8ff000
              
                )
              
              
	/lib64/ld-linux-x86-64.so.2 
              
                (
              
              0x00007f725d5f1000
              
                )
              
              
                [
              
              root@localhost ~
              
                ]
              
              
                # echo /usr/local/Python36/lib/ >> /etc/ld.so.conf.d/python3.6.conf
              
              
                [
              
              root@localhost ~
              
                ]
              
              
                # ldconfig
              
              
                [
              
              root@localhost ~
              
                ]
              
              
                # python3
              
              
Python 3.6.6 
              
                (
              
              default, May 17 2019, 14:04:59
              
                )
              
              
                [
              
              GCC 4.8.5 20150623 
              
                (
              
              Red Hat 4.8.5-36
              
                )
              
              
                ]
              
               on linux
Type 
              
                "help"
              
              , 
              
                "copyright"
              
              , 
              
                "credits"
              
               or 
              
                "license"
              
              
                for
              
              
                more
              
               information.

              
                >>
              
              
                >
              
               exit
              
                (
              
              
                )
              
            
          

二、安裝PG11

  1. PostgreSQL官網(wǎng)
    下載PG的repo包
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # wget -c https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
              
              
--2019-05-17 13:43:55--  https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Resolving download.postgresql.org 
              
                (
              
              download.postgresql.org
              
                )
              
              
                ..
              
              . 72.32.157.246, 87.238.57.227, 204.145.124.244, 
              
                ..
              
              .
Connecting to download.postgresql.org 
              
                (
              
              download.postgresql.org
              
                )
              
              
                |
              
              72.32.157.246
              
                |
              
              :443
              
                ..
              
              . connected.
HTTP request sent, awaiting response
              
                ..
              
              . 200 OK
Length: 5720 
              
                (
              
              5.6K
              
                )
              
              
                [
              
              application/x-redhat-package-manager
              
                ]
              
              
Saving to: ‘pgdg-redhat-repo-latest.noarch.rpm’

100%
              
                [
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                ==
              
              
                =
              
              
                >
              
              
                ]
              
               5,720       5.66KB/s   
              
                in
              
               1.0s   

2019-05-17 13:43:57 
              
                (
              
              5.66 KB/s
              
                )
              
               - ‘pgdg-redhat-repo-latest.noarch.rpm’ saved 
              
                [
              
              5720/5720
              
                ]
              
            
          
  1. 安裝PostgreSQL源
            
              
                [
              
              root@localhost tmp
              
                ]
              
              
                # yum install pgdg-redhat-repo-latest.noarch.rpm -y
              
            
          
  1. 安裝PostgresSQL11 客戶端與服務(wù)端
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # yum install postgresql11 postgresql11-server -y
              
            
          

PostgreSQL版本與其對(duì)應(yīng)支持的python3版本

PostgreSQL Version Python Version
9.X 3.3
10.X 3.4
11.X 3.6
  1. 將python3.6對(duì)應(yīng)的plpython3.so 文件添加到/usr/pgsql-11/lib/中
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # wget -c https://gitee.com/CodeForLive/PGEnablePlpython3/raw/master/py36/plpython3.so -C /usr/pgsql-11/lib
              
              
plpython3.so                                                             100%  143KB   9.9MB/s   00:00    

              
                [
              
              root@localhost ~
              
                ]
              
              
                # chmod 755 /usr/pgsql-11/lib/plpython3.so
              
            
          
  1. 初始化數(shù)據(jù)庫(kù)
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # /usr/pgsql-11/bin/postgresql-11-setup initdb
              
            
          

數(shù)據(jù)庫(kù)文件一般在/var/lib/pgsql/11/目錄下
6. 啟動(dòng)PostgreSQL服務(wù)

            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # systemctl start postgresql-11 && systemctl status postgresql-11
              
              
● postgresql-11.service - PostgreSQL 11 database server
   Loaded: loaded 
              
                (
              
              /usr/lib/systemd/system/postgresql-11.service
              
                ;
              
               disabled
              
                ;
              
               vendor preset: disabled
              
                )
              
              
   Active: active 
              
                (
              
              running
              
                )
              
               since Fri 2019-05-17 14:27:53 CST
              
                ;
              
               14ms ago
     Docs: https://www.postgresql.org/docs/11/static/
  Process: 14099 ExecStartPre
              
                =
              
              /usr/pgsql-11/bin/postgresql-11-check-db-dir 
              
                ${PGDATA}
              
              
                (
              
              code
              
                =
              
              exited, status
              
                =
              
              0/SUCCESS
              
                )
              
              
 Main PID: 14106 
              
                (
              
              postmaster
              
                )
              
              
    Tasks: 8
   CGroup: /system.slice/postgresql-11.service
           ├─14106 /usr/pgsql-11/bin/postmaster -D /var/lib/pgsql/11/data/
           ├─14107 postgres: logger   
           ├─14109 postgres: checkpointer   
           ├─14110 postgres: background writer   
           ├─14111 postgres: walwriter   
           ├─14112 postgres: autovacuum launcher   
           ├─14113 postgres: stats collector   
           └─14114 postgres: logical replication launcher   

May 17 14:27:53 localhost.localdomain systemd
              
                [
              
              1
              
                ]
              
              : Starting PostgreSQL 11 database server
              
                ..
              
              .
May 17 14:27:53 localhost.localdomain postmaster
              
                [
              
              14106
              
                ]
              
              : 2019-05-17 14:27:53.839 CST 
              
                [
              
              14106
              
                ]
              
               LOG:  listening on IPv6 addr
              
                ..
              
              . 5432
May 17 14:27:53 localhost.localdomain postmaster
              
                [
              
              14106
              
                ]
              
              : 2019-05-17 14:27:53.839 CST 
              
                [
              
              14106
              
                ]
              
               LOG:  listening on IPv4 addr
              
                ..
              
              . 5432
May 17 14:27:53 localhost.localdomain postmaster
              
                [
              
              14106
              
                ]
              
              : 2019-05-17 14:27:53.841 CST 
              
                [
              
              14106
              
                ]
              
               LOG:  listening on Unix sock
              
                ..
              
              .5432
              
                "
May 17 14:27:53 localhost.localdomain postmaster[14106]: 2019-05-17 14:27:53.843 CST [14106] LOG:  listening on Unix sock...5432"
              
              
May 17 14:27:53 localhost.localdomain postmaster
              
                [
              
              14106
              
                ]
              
              : 2019-05-17 14:27:53.860 CST 
              
                [
              
              14106
              
                ]
              
               LOG:  redirecting log output
              
                ..
              
              .ocess
May 17 14:27:53 localhost.localdomain postmaster
              
                [
              
              14106
              
                ]
              
              : 2019-05-17 14:27:53.860 CST 
              
                [
              
              14106
              
                ]
              
               HINT:  Future log output wil
              
                ..
              
              .log".
May 17 14:27:53 localhost.localdomain systemd
              
                [
              
              1
              
                ]
              
              : Started PostgreSQL 11 database server.
Hint: Some lines were ellipsized, use -l to show 
              
                in
              
               full.

            
          
  1. 設(shè)置為開機(jī)啟動(dòng)
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # systemctl enable postgresql-11
              
              
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-11.service to /usr/lib/systemd/system/postgresql-11.service.

            
          
  1. 登陸postgreSQl 并修改密碼
            
              
                [
              
              root@localhost ~
              
                ]
              
              
                # su - postgres
              
              
-bash-4.2$ psql
psql 
              
                (
              
              11.3
              
                )
              
              
Type 
              
                "help"
              
              
                for
              
               help.

postgres
              
                =
              
              
                # \password
              
              
Enter new password: 
Enter it again: 

            
          
  1. 查看plpython3 是否可以使用
            
              postgres=# create language plpython3u;
CREATE LANGUAGE
postgres=# CREATE FUNCTION pymax (a integer, b integer)
postgres-#    RETURNS integer
postgres-# AS $$
postgres$#   if a > b:
postgres$#     return a
postgres$#   return b
postgres$# $$ LANGUAGE plpython3u;
CREATE FUNCTION
postgres=# select pymax(20,12);
 pymax 
-------
    20
(1 row)

postgres=# select pymax(10,12);
 pymax 
-------
    12
(1 row)


            
          
  1. 設(shè)置遠(yuǎn)程連接
    1. 修改postgresql.conf 文件
                    
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # vim /var/lib/pgsql/11/data/postgresql.conf
                      
                      
    59 listen_addresses 
                      
                        =
                      
                      
                        '*'
                      
                      
                        # what IP address(es) to listen on;
                      
                      
    60                                         
                      
                        # comma-separated list of addresses;
                      
                      
    61                                         
                      
                        # defaults to 'localhost'; use '*' for all
                      
                      
    62                                         
                      
                        # (change requires restart)
                      
                      
    63 
                      
                        #port = 5432                            # (change requires restart)
                      
                      
    64 max_connections 
                      
                        =
                      
                       100                   
                      
                        # (change requires restart)
                      
                      
    65 
                      
                        #superuser_reserved_connections = 3     # (change requires restart)
                      
                    
                  
    1. 修改pg_hba.conf文件 最后一行添加
                    
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # vim /var/lib/pgsql/11/data/pg_hba.conf
                      
                      
    host    all             all             0.0.0.0/0              md5
    
                    
                  
    1. 打開防火墻5432端口并重啟postgresql服務(wù)
                    
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # vim /var/lib/pgsql/11/data/postgresql.conf 
                      
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # vim /var/lib/pgsql/11/data/pg_hba.conf 
                      
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # firewall-cmd --zone=public --add-port=5432/tcp --permanent
                      
                      
    success
    
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # firewall-cmd --reload
                      
                      
    success
    
                    
                  
    1. 重啟postgresql-11 服務(wù)并測(cè)試
                    
                      
                        [
                      
                      root@localhost ~
                      
                        ]
                      
                      
                        # systemctl restart postgresql-11
                      
                    
                  

更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對(duì)您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 亚洲成年网站在线777 | 成人国产精品齐天大性 | 亚洲成人网在线 | 美腿丝袜中文字幕 | 国产不卡视频在线 | 精品亚洲福利一区二区 | 亚洲黄色片在线观看 | 欧美高清色 | 激情网站免费观看 | 成人在线中文字幕 | 国产综合久久 | 日本a v在线播放 | 亚洲综合色婷婷在线观看 | 欧美激情精品久久久久久 | 亚洲第一页在线视频 | 国产日韩欧美一区 | 亚洲精品国产第1页 | 欧美淫 | 五月天激激婷婷大综合蜜芽 | 国产麻豆传媒视频 | 91精品国产色综合久久 | 成年人网站在线免费观看 | 日韩av电影在线播放 | 日韩亚洲欧美中文高清在线 | 国产精品久久久久一区二区三区 | 色.com | 一区二区在线不卡 | 大伊香蕉在线精品不卡视频 | 亚洲永久中文字幕在线 | 亚洲国产一区二区三区四区 | 亚洲最大黄色网址 | 一区在线播放 | 97色在线 | 欧美成人生活片 | 久久视频国产 | 日韩电影在线看 | 午夜婷婷网 | 午夜视频网址 | 91短视频app下载 | 欧美久久久 | 黄色小视频在线观看 |