• libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm
  • libxslt-1.1.28-5.el7.x86_64.rpm
  • pgdg-redhat95-9.5-2.noarch.rpm
  • postgresql95-9.5.5-1PGDG.rhel7.x86_64.rpm
  • postgresql95-contrib-9.5.5-1PGDG.rhel7.x86_64.rpm
  • postgresql95-devel-9.5.5-1PGDG.rhel7.x86_64.rpm
  • postgresql95-libs-9.5.5-1PGDG.rhel7.x86_64.rpm
  • postgresql95-odbc-09.05.0400-1PGDG.rhel7.x86_64.rpm
  • postgresql95-server-9.5.5-1PGDG.rhel7.x86_64.rpm
  • unixODBC-2.3.1-11.el7.x86_64.rpm
  • 配置ODBC数据源
  • 创建软链接
    [root@localhost ~]# ln -sf /usr/pgsql-9.5/bin/pg_config /usr/bin/pg_config
    [root@localhost ~]# ln -sf /usr/lib64/libodbcpsqlS.so /usr/lib/libodbcpsqlS.so
    [root@localhost ~]# ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib64/psqlodbcw.so
    [root@localhost ~]# ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib/psqlodbcw.so

    创建/etc/odbc.ini

    点击(此处)折叠或打开

    1. [freeswitch]
    2. Driver=PostgreSQL
    3. Database=freeswitch
    4. Servername=127.0.0.1
    5. Port=5432

    ODBC数据源测试:
        isql freeswitch freeswitch freeswitch

  • shell自动安装
  • 文件目录结构,其中odbc.ini内容如上节所示。

    点击(此处)折叠或打开

    1. [root@localhost postgresql]# tree
    2. .
    3. ├── ini
    4. │   └── odbc.ini
    5. ├── install-pgql95
    6. ├── libtool-ltdl-2.4.2-21.el7_2.x86_64.rpm
    7. ├── libxslt-1.1.28-5.el7.x86_64.rpm
    8. ├── pgdg-redhat95-9.5-2.noarch.rpm
    9. ├── postgresql95-9.5.5-1PGDG.rhel7.x86_64.rpm
    10. ├── postgresql95-contrib-9.5.5-1PGDG.rhel7.x86_64.rpm
    11. ├── postgresql95-devel-9.5.5-1PGDG.rhel7.x86_64.rpm
    12. ├── postgresql95-libs-9.5.5-1PGDG.rhel7.x86_64.rpm
    13. ├── postgresql95-odbc-09.05.0400-1PGDG.rhel7.x86_64.rpm
    14. ├── postgresql95-server-9.5.5-1PGDG.rhel7.x86_64.rpm
    15. ├── readme.txt
    16. ├── sql
    17. │   ├── mod_cdr_pg_csv.sql
    18. │   └── mod_cidlookup.sql
    19. └── unixODBC-2.3.1-11.el7.x86_64.rpm

    20. 2 directories, 15 files
    21. [root@localhost postgresql]#
    postgresql95安装字段安装脚本名 install-pgql95,使用 sh install-pgql95 执行脚本进行安装
    在线安装脚本(install-pgql95

    点击(此处)折叠或打开

    1. #!/bin/bash


    2. DATE=`date +'%Y-%m%d-%H%M'`

    3. UOUT="/tmp/install-pgql95.out"

    4. if [ -f $UOUT ];then
    5.   echo "script has already been executed. "
    6.   exit 0
    7. fi


    8. hm=$(echo $0 |sed 's/install-pgql95//')
    9. [[ ! -z $hm ]] && cd $hm

    10. HOME_DIR=`pwd`

    11. echo "Entering into $HOME_DIR, use yum install postgresql95, please wait ..."

    12. yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm >>${UOUT} 2>&1

    13. yum install -y postgresql95-server postgresql95-contrib postgresql95-devel postgresql95-odbc >>${UOUT} 2>&1

    14. echo "postgresql95 initdb ..."
    15. /usr/pgsql-9.5/bin/postgresql95-setup initdb >>${UOUT} 2>&1

    16. sed -i 's/127.0.0.1\/32 ident/0.0.0.0\/0 md5/g' /var/lib/pgsql/9.5/data/pg_hba.conf
    17. sed -i 's/localhost/*/g' /var/lib/pgsql/9.5/data/postgresql.conf
    18. sed -i 's/#listen_addresses/listen_addresses/g' /var/lib/pgsql/9.5/data/postgresql.conf
    19. #sed -i 's%#listen_addresses = 'localhost'%listen_addresses = '*'%g' /var/lib/pgsql/9.5/data/postgresql.conf
    20. ## listen_addresses = '*'


    21. ln -sf /usr/pgsql-9.5/bin/pg_config /usr/bin/pg_config

    22. ln -sf /usr/lib64/libodbcpsqlS.so /usr/lib/libodbcpsqlS.so

    23. ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib64/psqlodbcw.so

    24. ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib/psqlodbcw.so

    25. echo "start posrtgresql-9.5 ..."
    26. systemctl enable postgresql-9.5.service >>${UOUT} 2>&1

    27. systemctl start postgresql-9.5.service >>${UOUT} 2>&1

    28. sleep 3

    29. su - postgres -c "psql -c \" ALTER USER postgres WITH PASSWORD 'postgres';\"" >>${UOUT} 2>&1
    30. su - postgres -c "psql -c \" CREATE USER freeswitch WITH PASSWORD 'freeswitch';\"" >>${UOUT} 2>&1
    31. su - postgres -c "psql -c \" CREATE DATABASE freeswitch;\"" >>${UOUT} 2>&1
    32. su - postgres -c "psql -c \" ALTER DATABASE freeswitch OWNER TO freeswitch;\"" >>${UOUT} 2>&1
    33. su - postgres -c "psql -c \" GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;\"" >>${UOUT} 2>&1

    34. for sqlfile in $HOME_DIR/sql/*.sql
    35. do
    36.   echo "execute sql file : "$sqlfile
    37.   su - postgres -c "psql -d freeswitch -f $sqlfile" >>${UOUT} 2>&1
    38. done

    39. if [ -f /etc/odbc.ini ];then
    40.   if [ -f /etc/odbc.ini.bak ];then
    41.     rm -rf /etc/odbc.ini.bak
    42.   fi
    43.   mv /etc/odbc.ini /etc/odbc.ini.bak
    44. fi

    45. /bin/cp -rf $HOME_DIR/ini/odbc.ini /etc/odbc.ini

    46. echo "you can use 'isql freeswitch freeswitch freeswitch' to test odbc"

    离线安装脚本(install-pgql95

    点击(此处)折叠或打开

    1. #!/bin/bash


    2. DATE=`date +'%Y-%m%d-%H%M'`

    3. UOUT="/tmp/install-pgql95.out"

    4. if [ -f $UOUT ];then
    5.   echo "script has already been executed. "
    6.   exit 0
    7. fi


    8. hm=$(echo $0 |sed 's/install-pgql95//')
    9. [[ ! -z $hm ]] && cd $hm

    10. HOME_DIR=`pwd`

    11. echo "Entering into $HOME_DIR, install rpms ..."
    12. rpm_dir=$HOME_DIR/"*.rpm"
    13. for i in $rpm_dir
    14. do
    15.   rpm -Uvh --nodeps $i >>${UOUT} 2>&1
    16. done

    17. echo "postgresql95 initdb ..."
    18. /usr/pgsql-9.5/bin/postgresql95-setup initdb >>${UOUT} 2>&1

    19. sed -i 's/127.0.0.1\/32 ident/0.0.0.0\/0 md5/g' /var/lib/pgsql/9.5/data/pg_hba.conf
    20. sed -i 's/localhost/*/g' /var/lib/pgsql/9.5/data/postgresql.conf
    21. sed -i 's/#listen_addresses/listen_addresses/g' /var/lib/pgsql/9.5/data/postgresql.conf
    22. #sed -i 's%#listen_addresses = 'localhost'%listen_addresses = '*'%g' /var/lib/pgsql/9.5/data/postgresql.conf
    23. ## listen_addresses = '*'


    24. ln -sf /usr/pgsql-9.5/bin/pg_config /usr/bin/pg_config

    25. ln -sf /usr/lib64/libodbcpsqlS.so /usr/lib/libodbcpsqlS.so

    26. ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib64/psqlodbcw.so

    27. ln -sf /usr/pgsql-9.5/lib/psqlodbcw.so /usr/lib/psqlodbcw.so

    28. echo "start posrtgresql-9.5 ..."
    29. systemctl enable postgresql-9.5.service >>${UOUT} 2>&1

    30. systemctl start postgresql-9.5.service >>${UOUT} 2>&1

    31. sleep 3

    32. su - postgres -c "psql -c \" ALTER USER postgres WITH PASSWORD 'postgres';\"" >>${UOUT} 2>&1
    33. su - postgres -c "psql -c \" CREATE USER freeswitch WITH PASSWORD 'freeswitch';\"" >>${UOUT} 2>&1
    34. su - postgres -c "psql -c \" CREATE DATABASE freeswitch;\"" >>${UOUT} 2>&1
    35. su - postgres -c "psql -c \" ALTER DATABASE freeswitch OWNER TO freeswitch;\"" >>${UOUT} 2>&1
    36. su - postgres -c "psql -c \" GRANT ALL PRIVILEGES ON DATABASE freeswitch to freeswitch;\"" >>${UOUT} 2>&1

    37. for sqlfile in $HOME_DIR/sql/*.sql
    38. do
    39.   echo "execute sql file : "$sqlfile
    40.   su - postgres -c "psql -d freeswitch -f $sqlfile" >>${UOUT} 2>&1
    41. done

    42. if [ -f /etc/odbc.ini ];then
    43.   if [ -f /etc/odbc.ini.bak ];then
    44.     rm -rf /etc/odbc.ini.bak
    45.   fi
    46.   mv /etc/odbc.ini /etc/odbc.ini.bak
    47. fi

    48. /bin/cp -rf $HOME_DIR/ini/odbc.ini /etc/odbc.ini

    49. echo "you can use 'isql freeswitch freeswitch freeswitch' to test odbc"


    01-16 04:22