postgresSQL
postgresSQL 9.2.4 설치
-
설치정보
- Postgressql : 9.2.4
- OS : Centos 5.10
-
postgressql 컴파일때 필요한 패키지 설치
$> yum -y install compat-readline43 readline-devel crypto-utils.* openssl* readline-devel pam-devel
-
압축 해제하고 , 컴파일 -> 설치 들어가기
$> tar -zxvf postgresql-9.2.4.tar.gz $> cd postgresql-9.2.4 ./configure \ --enable-nls=’ko’ \ --enable-depend \ --enable-thread-safety \ --mandir=/usr/share/man \ --with-includes=/usr/include \ --with-pam \ --with-openssl \ --without-tcl \ --without-perl \ --without-python $> gmake ; gmake install
-
postgres사용자 추가
$> groupadd dba $> adduser -d /usr/local/pgsql -g dba -c “PostgreSQL Master User” -m -s $> /bin/bash postgres $> mkdir /usr/local/pgsql/data $> chown postgres /usr/local/pgsql/data $> chown -R postgres:dba /usr/local/pgsql $> cd /usr/local/pgsql $> chown -R root lib include
-
추가된 postgres sql 사용자에 대해서 postgessql 사용할수 있게 설정
$> su – postgres $> echo " export MANPATH=\$HOME/man export PGDATA=/usr/local/pgsql/data export PATH=$PATH:/usr/local/pgsql/bin" >> /usr/local/pgsql/.bash_profile $> source /usr/local/pgsql/.bash_profile $> exit
-
postgressql DB초기화 하기
$> su - postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
-
재부팅 이후에도 실행할 수 있게 rc.local에 등록하기
$> echo 'su – postgres -c "/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data/" &' >> /etc/rc.d/rc.local
-
네트워크에서 5432번 포트 열려있는지 확인
$> netstat -antp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name ... tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 22435/postgres ...
postgresSQL 9.4.26 설치
패키지 설치진행
- db실행 사용자 및 data 디렉토리 생성
$> useradd psql $> mkdir /home/data $> chown -R psql: /home/data
- source 파일 다운로드
$> wget https://ftp.postgresql.org/pub/source/v9.4.26/postgresql-9.4.26.tar.gz --no-check-certificate
- depencency 패키지 설치
$> yum install \ readline-devel \ zlib-devel \ openssl-devel \ tcl-devel -y
- 컴파일 후 설치진행
$> ./configure --prefix=/usr/local/psql --with-openssl --with-tcl $> make -j 4 $> make -j 4 install
DB 실행
- psql 실행
$> su - psql $> cd /usr/local/psql/bin $> ./initdb -D /home/data The files belonging to this database system will be owned by user "psql". This user must also own the server process. The database cluster will be initialized with locale "ko_KR.UTF-8". The default database encoding has accordingly been set to "UTF8". initdb: could not find suitable text search configuration for locale "ko_KR.UTF-8" The default text search configuration will be set to "simple". Data page checksums are disabled. fixing permissions on existing directory /home/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... ROK selecting dynamic shared memory implementation ... posix creating configuration files ... ok creating template1 database in /home/data/base/1 ... ok initializing pg_authid ... ok initializing dependencies ... ok creating system views ... ok loading system objects' descriptions ... ok creating collations ... ok creating conversions ... ok creating dictionaries ... ok setting privileges on built-in objects ... ok creating information schema ... ok loading PL/pgSQL server-side language ... ok vacuuming database template1 ... ok copying template1 to template0 ... ok copying template1 to postgres ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. Success. You can now start the database server using: ./postgres -D /home/data or ./pg_ctl -D /home/data -l logfile start
- 프로세스 실행
$ /usr/local/psql/bin/postgres -D /home/data/ >logfile 2>&1 &
- 프로세스 실행상태 확인
$> ps -ef | grep post psql 16193 16108 0 10:54 pts/0 00:00:00 /usr/local/psql/bin/postgres -D /home/data/ psql 16195 16193 0 10:54 ? 00:00:00 postgres: checkpointer process psql 16196 16193 0 10:54 ? 00:00:00 postgres: writer process psql 16197 16193 0 10:54 ? 00:00:00 postgres: wal writer process psql 16198 16193 0 10:54 ? 00:00:00 postgres: autovacuum launcher process psql 16199 16193 0 10:54 ? 00:00:00 postgres: stats collector process psql 16201 16108 0 10:54 pts/0 00:00:00 grep --color=auto post netstat -antp | grep postgres (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 16193/postgres tcp6 0 0 ::1:5432 :::* LISTEN 16193/postgres
postgresql 데이터 백업/관리
- DB데이터 백업하기
-bash-4.1$ pg_dump testdb > test.sql
- DB 스키마만 덤프할때
bash-4.1$ pg_dump -s testdb > test.sql
- 데이터 복원
bash-4.1$ psql testdb < test.sql
싱글모드 진입절차
Centos7버전에서 HDD 수동 드라이버 구성
HDD 수동 드라이버 구성 (자동으로 드라이브 검색 실패시)
설치 옵션 입력
Tab키 입력 후 하단에 inst.dd 입력
드라이버 추가
입력 완료 후 'c' 입력
Centos 7.x 설치하기 (DVD 미디어로 설치) 3번과정 참조
- 수동으로 HDD 드라이브 추가하여 설치 한 이후, 커널 업데이트 진행시,업데이트하는 커널에는 해당 드라이브 정보가 빠져있게 되어 디스크정보를 못찾거나, 레이드 정보가 틀어지는 이슈사항이 있기 때문에, 수동 HDD 드라이브 추가시 yum update부분은 신중하게 판단해야 함.
- 해결방안은 업데이트하는 커널에도 해당 디스크 드라이브를 추가할 수 있게
커널 컴파일을 하는 방법과 Yum update 시 커널은 제외할 수 있게 옵션 설정이 필요함