1. 설치목적

  - 이 블로그에서 postgresql DB를 설치하는 목적은 시각화 분석시스템인 superset (https://dodo-it.tistory.com/71)에서

   postgresql을 연결해 보기 위함이다.


2. 설치순서

   1) CentOS7에서는 yum으로 쉽게 설치된다. 

 # sudo yum install postgresql-server postgresql-contrib


   2) 초기 DB구성 설치

 # sudo postgresql-setup initdb


   3) 암호인증 허용하기 위한 설정 편집      

      - vi 에디터로 설정파일을 OPEN한다.

 # vi /var/lib/pgsql/data/pg_hba.conf

      - 열려진 에디터 창에서 Ctrl + G 를 눌러 한번에 제일 아래로 이동한다.(제일 아래쪽에 수정내용이 있다)

        그러면 아래 부분이 보인다. (수정할 부분은 빨간색 칠한부분이다)B


# "local" is for Unix domain socket connections only

local   all             all                                     md5

# IPv4 local connections:

host    all             all             127.0.0.1/32            ident

# IPv6 local connections:

host    all             all             ::1/128                 ident

# Allow replication connections from localhost, by a user with the

# replication privilege.

#local   replication     postgres                                peer

#host    replication     postgres        127.0.0.1/32            ident

#host    replication     postgres        ::1/128                 ident



     - 해당 위치로 커서 이동 후 i 를 눌러 편집모드에서 ident를 지우고 그 위치에 md5를 입력한다.

       또한 본인의 경우 virtualbox를 사용하여 virtualbox 아이피도 추가해준다.

       최종결과는 아래와 같은 모습이다.


# "local" is for Unix domain socket connections only

local   all             all                                     md5

# IPv4 local connections:

host    all             all             127.0.0.1/32            md5

# IPv6 local connections:

host    all             all             ::1/128                 md5

host    all             all             10.0.2.15/24            md5

# Allow replication connections from localhost, by a user with the

# replication privilege.

#local   replication     postgres                                peer

#host    replication     postgres        127.0.0.1/32            ident

#host    replication     postgres        ::1/128                 ident



   - vi 편집을 종료,저장하고 나가기 위해 esc 한번 ":"(콜론) 입력 wq 입력 enter 하면 완료된다.

 :wq


   - DB를 구동해본다.

 # sudo systemctl start postgresql

   

   - 시작시 자동으로 시작되도록 설정 

 # sudo systemctl enable postgresql

   

   - 외부접속가능하도록 방화벽을 열어준다.     

# firewall-cmd --permanent --zone=public --add-port=5432/tcp 

# firewall-cmd --reload


3. 기타 사용법

   1) 초기접속은 postgres 계정으로접속한다. (sudo -i -u postgres  --> password입력 --> psql 입력)

      * 초기 postgres 비번변경필요시 # sudo passwd postgres 명령어 사용


# sudo -i -u postgres

-bash-4.2$ psql

Password:

psql (9.2.24)

Type "help" for help.


postgres=#



  2) postgres=# 프롬프트에서 빠져나가기  

 postgres=# \q

      이후 아래 프롬프트 나오면 exit 입력후 엔터      

 -bash-4.2exit


  3) DB 생성하기(superset db를 생성하기로 함) 

 postgres=# CREATE DATABASE superset OWNER postgres;


  4) 생성된 DB List 보기 (역슬레쉬 + 소문자 엘)

 postgres=# \l

      * 결과        List of databases


   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges

-----------+----------+----------+-------------+-------------+-----------------------

 postgres  | postgres | UTF8     | ko_KR.UTF-8 | ko_KR.UTF-8 |

 sharkdb   | sharkdb  | UTF8     | en_US.UTF-8 | en_US.UTF-8 | sharkdb=CTc/sharkdb  +

           |          |          |             |             | =CTc/sharkdb

 superset  | postgres | UTF8     | ko_KR.UTF-8 | ko_KR.UTF-8 | =Tc/postgres         +

           |          |          |             |             | postgres=CTc/postgres+

           |          |          |             |             | soo=CTc/postgres

 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +

           |          |          |             |             | postgres=CTc/postgres

 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +

           |          |          |             |             | postgres=CTc/postgres

(5 rows)




어때요? 도움이 많이 되셨나요? ~~~~~~~


1. 에러상황

   : 평소 잘 되던 yum update 시도시 갑자기 아래와 같은 "No more mirrors to try"에러가 발생하면서

     update가 되지 않음. 

    (아래는 나의 패키지며, 사람마다 다르게 나올수 있음. 에러메시지에만 신경써주기 바람.) downloading packages:

  Error downloading packages:

    3:docker-ce-18.09.1-3.el7.x86_64: [Errno 256] No more mirrors to try.

    python36u-devel-3.6.7-1.ius.centos7.x86_64: [Errno 256] No more mirrors to try.

    tzdata-2018i-1.el7.noarch: [Errno 256] No more mirrors to try.

    containerd.io-1.2.2-3.el7.x86_64: [Errno 256] No more mirrors to try.

    python36u-libs-3.6.7-1.ius.centos7.x86_64: [Errno 256] No more mirrors to try.

    python36u-3.6.7-1.ius.centos7.x86_64: [Errno 256] No more mirrors to try.

    1:docker-ce-cli-18.09.1-3.el7.x86_64: [Errno 256] No more mirrors to try.

    tzdata-java-2018i-1.el7.noarch: [Errno 256] No more mirrors to try.

    python34-setuptools-39.2.0-1.el7.noarch: [Errno 256] No more mirrors to try.


2. 해결방법

  # yum clean all


  위와같이 yum을 clean해주고 다시 yum update 또는 install 시 아래와 같은 시원한 메시지를 볼 수 있다.


   Complete!



1. Apache superset이란?

   - 오픈소스 웹기반의 데이터 시각화 BI툴로 Airbnb에서 오픈소스(Apache2.0 라이센스)로 공개한 프로그램이다.

   - URL : https://superset.incubator.apache.org/

   - 상용 프로그램인 tableau의 대안으로 선택할 수 있다. 


2. 설치방법

   : superset 홈피에 보면 여러가지 설치방법이 나오는데 docker를 이용한 설치는 docker-build.sh 파일이 없어 

    에러가 발생한다. ==> 포기

    그래서 아래쪽에 pip로 설치해보니 정상적으로 작동되어 pip설치방법을 설명하도록 하겠음.

   1) 먼저 python3.6과 pip3 버전을 설치해야한다.

      : 설치방법은 기존글 참조 ==> CentOS 7 에 yum으로 python3.6 , pip3 설치하기 클릭


   2) superset 설치에 필요한 패키지를 설치한다.

      $ sudo yum upgrade python-setuptools 

      $ sudo yum install gcc gcc-c++ libffi-devel python-devel python-pip python-wheel openssl-devel libsasl2-devel openldap-devel   ==> sudo 부터 openldap-devel 까지 복사


   3) pip 로 superset 설치

      $ pip install superset 

  

   4) supserset admin 사용자 생성 (원하는대로 입력하면 됨.)

     : fabmanager create-admin --app superset      


     [root@localhost local]# fabmanager create-admin --app superset

     Username [admin]: dasdes                          ==> admin 사용자명

     User first name [admin]: dasdes                   ==> 사용자 이름

     User last name [user]: dasdes                      ==> 사용자 성

     Email [admin@fab.org]: dasdes@dasdes.com  ==> 사용자 이메일

     Password:                                               ==> 사용자비밀번호 (원하는대로)

     Repeat for confirmation:                            ==> 사용자비밀번호확인

     Recognized Database Authentications.          ==> 이하 생성성공메시지

     Admin User dasdes created.

 

※ 혹시 Was unable to import superset Error: cannot import name '_maybe_box_datetimelike' 에러가 나면

   원인은 pandas 버전 때문이라 기존버전을 지우고 0.23.X 버전으로 다운그레이드 하면 된다.

   -  pip uninstall pandas

   -  pip install pandas==0.23.4

   - 그런 다음 다시 fabmanager create-admin --app superset 하면 됨.



   5) superset db 초기화

     $ superset db upgrade 

 ※ 이 상황에서 에러가 나면 다음과 같은 에러가 나올거다.

sqlalchemy.exc.InvalidRequestError: Can't determine which FROM clause to join from, there are multiple FROMS which can join to this entity. Try adding an explicit ON clause to help resolve the ambiguity.

  그러면 pip 추가모듈을 설치해주고 다시 도전하면 된다.

  : pip install sqlalchemy==1.2.18


   6) 샘플데이터를 붙는다.

     $ superset load_examples 


   7) 초기 권한 자동셋팅

     $ superset init 

 

   8) centos7 에서 방화벽 port 8088을 열어준다.

     $ firewall-cmd --permanent --zone=public --add-port=8088/tcp 

     $ firewall-cmd --reload        ==> 방화벽 적용 


   9) 서버실행

    $ superset runserver -d


  10) 접속URL 

       http://localhost:8088

   그런다음 위에서 admin 계정만들때 사용했던 ID와 비밀번호를 입력하고 들어가면 됨.







 



어때요? 도움이 많이 되셨나요? ~~~~~~~


'오픈소스 > 기타 오픈소스' 카테고리의 다른 글

windows 10 docker 설치 및 필요 명령어  (0) 2019.12.09

 

◈ 설치순서

   1) ius repository 설치

      yum install -y https://centos7.iuscommunity.org/ius-release.rpm  링크깨짐
      $ yum install https://repo.ius.io/ius-release-el7.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

 

     * 참고

        - 위 명령을 실행했을 때 아래와 같은 오류가 발생했을 경우에는 다운로드 후 yum install을 실행하면 된다.

       [root@localhost local]#  yum install -y https://centos7.iuscommunity.org/ius-release.rpm
       Loaded plugins: fastestmirror
       Cannot open: https://centos7.iuscommunity.org/ius-release.rpm. Skipping.
       Error: Nothing to do

        - $ cd /usr/local ==> /usr/local 로 이동(다운로드 받으려고)

        - $ wget https://centos7.iuscommunity.org/ius-release.rpm --no-check-certificate ==> ius-release.rpm 다운로드

        - $ yum install -y ius-release.rpm  ==> repository 설치

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

        위에 wget으로 받은 후 yum install -y ius-release.rpm 했는데 ius-release.rpm 파일을 오픈할 수 없다는 둥...

        이런 메시지가 나오면 과감히 아래 링크에서 rpm을 따로 받아서 받은 rpm을 설치하세요.

         - 파일다운로드 : wget https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-15.ius.centos7.noarch.rpm --no-check-certificate

         - Install 하기 :   yum install -y ius-release-1.0-15.ius.centos7.noarch.rpm

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


2) 추가 패키지 설치

     $ yum install -y python36u python36u-devel python36u-libs python36u-pip

 

   3) pip명령어로 바로 pip3.6용 pip가 인식되도록 하기 위한 파일 다운로드 및 다운로드 파일 실행

     $ wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
     $ python3.6 get-pip.py      

     위 명령어를 실행하고 pip -V 을 실행시 아래와 같이 python 3.6 용 pip가 설치된것을 알 수 있다.

     pip 18.1 from /usr/lib/python3.6/site-packages/pip (python 3.6) 
     pip 21.1.2 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)


   * 참고

     - python 만 쳐도 python3.6을 인식하게 하기 위해서는 Python3.7 설치하기(https://dodo-it.tistory.com/69)의

       제일 아래쪽 글을 참고하면 됨.

 

 

어때요? 도움이 많이 되셨나요? ~~~~~~~

 


1. 문제상황

  : CentOS7을 설치하고 나면 기본으로 설치되는 Python은 2.7이다.

   다른 프로그램을 설치해서 사용하고자 하는데 Python 최소요구버전이 3.7일 경우 

   따로 다운로드 받아서 설치해야 하는 상황임.


2. 설치순서

   1) 먼서 필요한 프로그램을 yum으로 설치한다.

      yum install gcc openssl-devel  libffi-devel bzip2-devel 

 

   2) python 최신버전 확인

      브라우저주소창에 붙여넣는다. (클릭하면 바로 뜸) ==> https://www.python.org/ftp/python/ 

      현재시점에서 최신버전은 3.7.1이다.


   3) 다운로드 한다. 다운로드 경로는 python3.7 폴더를 어디에 두고싶은지 본인이 결정하면 된다.

       본인은 /usr/src 나 /usr/local 로 이동 후 주로 다운로드 한다.

       여기서는 /usr/src 로 이동 ==> cd /usr/src      

      wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz


   4) 압축을 푼다.

     tar xzf Python-3.7.1.tgz 

     ==> 이렇게 하면 Python-3.7.1 폴더가 생김


   5) Python-3.7.1 폴더 안에 들어가서 configure를 실행한다.

      cd Python-3.7.1 

      ./configure --enable-optimizations

      ==> C 컴파일이 막 되는듯....


   6) 설치

     make altinstall 

      ==> 이 과정이 끝나면 python3.7의 설치과정이 끝난다. 


   7) 확인(python3.7이 어딨는지 보려면 which python3.7 로 확인)

     python3.7 -V 



   8) 그냥 python 명령어로 python3.7 을 실행하고 싶을 때...

      $ vi /root/.bashrc  ==> /root/.bashrc 편집창을 연다.

      $ 아래와 같이 alias python="/usr/local/bin/python3.7" 라고 붙여넣는다. (편집창을 저장 후 나간다) 

      $  source /root/.bashrc  ==> 적용

     

* 참고로 vi 에디터 사용법은 i 키는 편집, 입력 후 ESC클릭 :wq 입력 하면 종료하고 나간다.


   9) 확인  

     python -V   ==> 이러면 Python 3.7.1 이라고 나올것이다.


* 원래 상태로 되돌리기

   - 위에 입력한 alias 라인을 지운다. (저장후 나감)

   $ hash -r  ==>bash cache를 초기화(alias삭제후 python명령어 치면 계속  /usr/local/bin/python3.7 를 찾는다)



어때요? 도움이 많이 되셨나요? ~~~~~~~


+ Recent posts