centos 7オフラインインストール構成駆動pymssql,pyodbcおよびcx_Oracle

22730 ワード

centos 7オフラインインストール構成駆動pymssql,pyodbcおよびcx_Oracle
  • オフラインインストールpymssqlおよび駆動freetds
  • オフライン実装gcc
  • オフラインインストールfreeTDS
  • オフラインインストールpymssql
  • オフラインインストールcx_Oracleおよび駆動
  • オフラインインストールoracleクライアント
  • インストールcx_Oracle
  • オフラインインストールpyodbc
  • インストール依存
  • インストールunixODBC
  • インストールpyodbc
  • 登録駆動
  • オフラインインストールibm_dbおよびdb 2駆動
  • オフラインインストールpymssqlおよび駆動freetds
    python呼び出しsqlserver依存pymssql+freetds駆動、freetds依存gcc
    オフライン実装gcc
  • gcc-4.8.5関連依存パッケージ:
  • cpp-4.8.5-36.el7.x86_64.rpm
    gcc-4.8.5-36.el7.x86_64.rpm
    glibc-2.17-260.el7.x86_64.rpm
    glibc-common-2.17-260.el7.x86_64.rpm
    glibc-devel-2.17-260.el7.x86_64.rpm
    glibc-headers-2.17-260.el7.x86_64.rpm
    kernel-headers-3.10.0-957.el7.x86_64.rpm
    libgcc-4.8.5-36.el7.x86_64.rpm
    libgomp-4.8.5-36.el7.x86_64.rpm
    libmpc-1.0.1-3.el7.x86_64.rpm
    mpfr-3.1.1-4.el7.x86_64.rpm
    

    依存パッケージのダウンロードアドレス:https://pkgs.org/
  • 上記依存パッケージのインストール
  • #  glibc-2.17-260.el7.x86_64.rpm   glibc-common-2.17-260.el7.x86_64.rpm,     ,      
    rpm -qa | grep glibc;
    ---------------------------------------
    > glibc-common-2.17-55.el7.x86_64
    > glibc-2.17-55.el7.x86_64
    ---------------------------------------
    #           
    rpm -Uvh glibc-2.17-260.el7.x86_64.rpm glibc-common-2.17-260.el7.x86_64.rpm libgomp-4.8.5-36.el7.x86_64.rpm libgcc-4.8.5-36.el7.x86_64.rpm;
    #        
    rpm -ivh gcc-4.8.5-36.el7.x86_64.rpm cpp-4.8.5-36.el7.x86_64.rpm glibc-devel-2.17-260.el7.x86_64.rpm glibc-headers-2.17-260.el7.x86_64.rpm kernel-headers-3.10.0-957.el7.x86_64.rpm libmpc-1.0.1-3.el7.x86_64.rpm mpfr-3.1.1-4.el7.x86_64.rpm;
    #  gcc  
    gcc -v
    ----------------------------------------
    >Using built-in specs.
    >COLLECT_GCC=gcc
    >COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
    >Target: x86_64-redhat-linux
    >Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
    >Thread model: posix
    >gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
    ----------------------------------------
    #    
    

    オフラインインストールfreeTDS
  • freetds-1.00.109
  • をダウンロード
    公式サイトのダウンロードページ:http://www.freetds.org/files/stable/バージョンのダウンロード先:http://www.freetds.org/files/stable/freetds-1.00.109.tar.gz
  • コンパイルインストールfreetds
  • tar xvf freetds-1.00.109.tar.gz;
    cd freetds-1.00.109;
    #--with-unixodbc=/usr/local/unixODBC-2.3.7
    ./configure --prefix=/usr/local/freetds --with-tdsver=7.4 --enable-msdblib --enable-dbmfix --enable-shared --enable-static;
    make;
    make install;
    #  
    -------------------------------------------
    >--prefix  FreeTDS     
    >--with-tdsver  TDS  
    >--enable-msdblib  Microsoft      
    -------------------------------------------
    
    # tsql        
    -------------------------------------------
    
    vim ~/.bashrc;
    
    -------------------------------------------
    >FREETDS_HOME=/usr/local/freetds
    >export PATH=$FREETDS_HOME/bin:$PATH
    -------------------------------------------
    
    source ~/.bashrc;
    
    -------------------------------------------
    tsql -C;   #      
    -------------------------------------------
    >Compile-time settings (established with the "configure" script)
    >                            Version: freetds v1.00.109
    >             freetds.conf directory: /usr/local/freetds/etc
    >     MS db-lib source compatibility: yes
    >        Sybase binary compatibility: no
    >                      Thread safety: yes
    >                      iconv library: yes
    >                        TDS version: 7.4
    >                              iODBC: no
    >                           unixodbc: no
    >              SSPI "trusted" logins: no
    >                           Kerberos: no
    >                            OpenSSL: no
    >                             GnuTLS: no
    >                               MARS: no
    -----------------------------------------------------------
    #     
    echo "/usr/local/freetds/lib" > /etc/ld.so.conf.d/freetds.conf;
    ldconfig;
    
  • プロファイルの変更、データベースへの接続
  • vim /usr/local/freetds/etc/freetds.conf;
    
    ------------------------------------
    #sqlserver 2012  
    >[sql-server-2012]
    >		host = xxx.xxx.xxx
    >		port = 1433
    >		tds version = 7.4
    #sqlserver 2005  
    >[2005SQL]
    >		host = xxx.xxx.xxx
    >		port = 1433
    >		tds version = 8.0
    #sqlserver 2008  
    >[sql-server-2008]
    >		host = xxx.xxx.xxx
    >		port = 1433
    >		tds version = 8.0
    >		client chaeset = UTF-8
    ------------------------------------
    #    
    tsql -S sql-server-2008 -U     -P   ;
    use test;#       
    go;
    

    オフラインインストールpymssql
  • オフラインインストールpip
  • 拡張パッケージのダウンロードアドレス:https://pypi.org/project
    tar xvf setuptools-0.6c11.tar.gz;
    tar xvf pip-18.1.tar.gz;
    cd setuptools-0.6c11 && python setup.py install;
    cd pip-18.1 && python setup.py install;
    
  • pipインストールpymssql
  • pip install pymssql-2.1.4-cp27-cp27mu-manylinux1_x86_64.whl;
    python;
    ----------------------------------
    >import pymssql
    >
    
  • pymssqlおよび駆動取付完了
  • オフラインインストールcx_Oracleおよびドライバ
    python呼び出しoracleデータはcx_に依存Oracle+oracle-instantclient
    Oracleクライアントのオフラインインストール
  • インストールoracle 11 g
  • ダウンロード先:https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.htmlOracleのバージョンに従って、対応するrpmパッケージをダウンロードします:リスト:oracle-instantclient 11.2-basic-11.2.0.3.0-1.x86_64.rpm        oracle-instantclient11.2-devel-11.2.0.3.0-1.x86_64.rpm        oracle-instantclient11.2-sqlplus-11.2.0.3.0-1.x86_64.rpm
    rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
    
  • 環境変数の修正(3つの方法)
  • #       (  )
    vim /etc/profile
    source /etc/profile
    #       (  )          /home/xxx/
    vim ~/.bash_profile;
    source ~/.bash_profile;
    #    export(   shell    )
    export ..........
    #----------------------------------------------------------
    vim ~/.bash_profile;
    -----------------------------------------------------------
    >export ORACLE_HOME=/usr/lib/oracle/11.2/client64
    >export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
    -----------------------------------------------------------
    source ~/.bash_profile;
    echo $ORACLE_HOME;#    
    
    #     
    cd /usr/lib/oracle/11.2/client64/lib && ln –s libclntsh.so.11.1 libclntsh.so
    

    cx_のインストールOracle
    ダウンロード先:https://pypi.org/project/cx-Oracle/
  • インストールcx_Oracle拡張パッケージ
  • pip install cx_Oracle-7.0.0-cp27-cp27mu-manylinux1_x86_64.whl;
    python;
    >import cx_Oracle
    >cx_Oracle.SessionPool(user= 't', password= 't', dsn= '192.168.0.xxx:1521/orcl', min=1, max=10, increment=1)
    >> :OK!
    

    オフラインインストールpyodbc
    インストール依存yum install -y gcc-c++ python-devel ; オフラインインストールはご自身でお問合せください
    unixODBCのインストール
  • ソースコードインストール公式ダウンロードアドレス:http://www.unixodbc.org/
  • 運転命令
  • tar xvf unixODBC-2.3.7.tar.gz;
    cd unixODBC-2.3.7/
    ./configure --prefix=/usr/local/unixODBC-2.3.7 --includedir=/usr/include --libdir=/usr/local/lib -bindir=/usr/bin --sysconfdir=/usr/local/etc;
    make && make install
    
  • yumインストールyum install -y unixODBC unixODBC-devel
  • rpmインストール公式ダウンロードアドレス:https://pkgs.org/download/unixODBC-devel http://rpmfind.net/linux/rpm2html/search.php?query=unixODBC uname -r rpm -ivh unixODBC-devel-2.3.1-11.el7.x86_64.rpm
  • 検査isql --versionisql -j
  • pyodbcのインストールpip install pyodbcまたはpip install pyodbc-4.0.28.tar.gz登録ドライバ
    バックアップ
    [root@dongfangyiyuan ~]# cat /usr/local/etc/odbcinst.ini 
    [FreeTDS]
    Description     = FreeTDS unixODBC Driver
    Driver          = /usr/local/freetds/lib/libtdsodbc.so
    Setup           = /usr/local/freetds/lib/libtdsodbc.so
    
    vim /usr/local/etc/odbcinst.ini;
    -------------------------------------------------
    [FreeTDS]					# unixodbc    
    Description=ODBC of FreeTDS for MS SQL 2008		#   	
    Driver=/usr/local/freetds/lib/libtdsodbc.so	#       
    #################################################################
    vim /usr/local/etc/odbc.ini;
    ---------------------------------------------------
    [root@dongfangyiyuan ~]# cat /usr/local/etc/odbc.ini 
    [BYZY]
    Driver = FreeTDS
    Description = odbc for sybase
    Server = 192.168.3.16
    Port = 5000
    TDS_Version = 5.0
    
    [BYMZ]
    Driver = FreeTDS
    Description = odbc for sybase
    Server = 192.168.3.15
    Port = 5000
    TDS_Version = 5.0    
    
    [NYZY]
    Driver = FreeTDS
    Description = odbc for sybase
    Server = 172.31.10.202
    Port = 5000
    TDS_Version = 5.0    
    
    [NYMZ]
    Driver = FreeTDS
    Description = odbc for sybase
    Server = 172.31.10.201
    Port = 5000
    TDS_Version = 5.0    
    
    [BSEMR]
    Driver = FreeTDS
    Description = odbc for sybase
    Server = 172.31.10.87
    Port = 5000
    TDS_Version = 5.0    
    
    
  • 接続テスト
  • isql -v TEST2dsn ${user} ${password};
    

    オフラインインストールibm_dbおよびdb 2駆動
  • ダウンロードアドレス:https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/
  • 拡張パッケージダウンロードアドレス:https://pypi.org/project/ibm-db/#files