전체 글

[MySQL] 접속

2023. 3. 16. 14:53

1. MySQL 활성화 & 상태 확인

[root@kim ~]# systemctl enable mysqld && systemctl start mysqld && systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 목 2023-03-16 14:30:58 KST; 1min 32s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
 Main PID: 1640 (mysqld)
   Status: "Server is operational"
   CGroup: /system.slice/mysqld.service
           └─1640 /usr/sbin/mysqld

 3월 16 14:30:56 kim systemd[1]: Starting MySQL Server...
 3월 16 14:30:58 kim systemd[1]: Started MySQL Server.

 

2. root 계정으로 MySQL 접속

[root@kim ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

 

3. 계정 생성을 위해 기본 DB에 접속

mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed

 

+ 처음에 대문자로 입력했더니 오류 계속남,, 검색하니까 DB 생성 어쩌꾸 bin 하위 폴더 어쩌구 하는데 

ERROR 1049 (42000): Unknown database 'MYSQL'
mysql> USE MYSQL;

mysql > show databases;

해보면 소문자길래 혹시 하고 소문자로 입력해보니까 됨,,ㅠ

 

 

4. 계정 생성 & 권한부여

mysql> create user 'testuser' identified by '비밀번호';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'testuser'@'%';

-- 권한 반영
mysql> flush privileges;

※ %는 모든 권한

 

 

[MariaDB] 삭제

2023. 3. 16. 11:34

1. root 계정 로그인

2. MariaDB 패키지 설치 여부 확인

[oracle@kim ~]$  yum list installed mariadb\*

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: ftp.riken.jp
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
Error: No matching Packages to list

위 cmd 날리면 안나오는데, 아래 날리면 있다고 나옴ㅠ

[oracle@kim ~]$ rpm -qa | grep -i mariadb

mariadb-server-5.5.68-1.el7.x86_64
mariadb-libs-5.5.68-1.el7.x86_64
mariadb-5.5.68-1.el7.x86_64

 

3. mariadb.x86_64 1:5.5.68-1.el7, mariadb-server.x86_64 1:5.5.68-1.el7 삭제

[root@kim ~]# yum remove -y mariadb.x86_64

Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.68-1.el7 will be erased
--> Processing Dependency: mariadb(x86-64) = 1:5.5.68-1.el7 for package: 1:mariadb-server-5.5.68-1.el7.x86_64
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.68-1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================
 Package          Arch     Version          Repository
                                                     Size
==========================================================
Removing:
 mariadb          x86_64   1:5.5.68-1.el7   @base    49 M
Removing for dependencies:
 mariadb-server   x86_64   1:5.5.68-1.el7   @base    58 M

Transaction Summary
==========================================================
Remove  1 Package (+1 Dependent package)

Installed size: 107 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : 1:mariadb-server-5.5.68-1.el7.x86_64   1/2
경고: /var/log/mariadb/mariadb.log(이)가 /var/log/mariadb/mariadb.log.rpmsave(으)로 저장되었습니다
  Erasing    : 1:mariadb-5.5.68-1.el7.x86_64          2/2
  Verifying  : 1:mariadb-server-5.5.68-1.el7.x86_64   1/2
  Verifying  : 1:mariadb-5.5.68-1.el7.x86_64          2/2

Removed:
  mariadb.x86_64 1:5.5.68-1.el7

Dependency Removed:
  mariadb-server.x86_64 1:5.5.68-1.el7

Complete!
[root@kim ~]# rpm -qa | grep -i mariadb

mariadb-libs-5.5.68-1.el7.x86_64

 

위 안되면, 아래 명령어로 수동 삭제

$ yum remove -y MariaDB-client.x86_64
$ yum remove -y MariaDB-common.x86_64
$ yum remove -y MariaDB-compat.x86_64
$ yum remove -y MariaDB-server.x86_64

 

 

4. lib 파일 제거

[root@kim ~]# yum -y remove mariadb-libs

Loaded plugins: fastestmirror, langpacks
Resolving Dependencies
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.68-1.el7 will be erased
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-6.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Running transaction check
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be erased
---> Package postfix.x86_64 2:2.10.1-9.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================
 Package         Arch    Version         Repository  Size
==========================================================
Removing:
 mariadb-libs    x86_64  1:5.5.68-1.el7  @anaconda  4.4 M
Removing for dependencies:
 perl-DBD-MySQL  x86_64  4.023-6.el7     @base      323 k
 postfix         x86_64  2:2.10.1-9.el7  @anaconda   12 M

Transaction Summary
==========================================================
Remove  1 Package (+2 Dependent packages)

Installed size: 17 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : perl-DBD-MySQL-4.023-6.el7.x86_64      1/3
  Erasing    : 2:postfix-2.10.1-9.el7.x86_64          2/3
  Erasing    : 1:mariadb-libs-5.5.68-1.el7.x86_64     3/3
  Verifying  : 2:postfix-2.10.1-9.el7.x86_64          1/3
  Verifying  : 1:mariadb-libs-5.5.68-1.el7.x86_64     2/3
  Verifying  : perl-DBD-MySQL-4.023-6.el7.x86_64      3/3

Removed:
  mariadb-libs.x86_64 1:5.5.68-1.el7

Dependency Removed:
  perl-DBD-MySQL.x86_64 0:4.023-6.el7
  postfix.x86_64 2:2.10.1-9.el7

Complete!

 

5. 삭제 확인 

[root@kim ~]# rpm -qa | grep -i mariadb
[root@kim ~]#

 

 

+ MariaDB가 사용 했던 모든 로그까지 제거

[root@kim ~]# rm /var/log/mariadb/mariadb.log.rpmsave
rm: remove 일반 파일 `/var/log/mariadb/mariadb.log.rpmsave'?

 

 

참고 https://www.iorad.com/player/1579826/CentOs--Mysql---------1--Maria-db--- , https://ansan-survivor.tistory.com/1339

ERROR: ORA-01017 : invalid username/password; logon denied

위와 같은 오류 발생으로 sys 계정 연결 불가 시 아래 쿼리로 비밀번호 변경

 

[oracle@kim ~]$ lsnrctl start
[oracle@kim ~]$ sqlplus / as sysdba

Connected to an idle instance.


SQL> startup

ORACLE instance started.
Database mounted.
Database opened.

SQL> alter user sys identified by [비밀번호];

User altered.

'Database > Oracle' 카테고리의 다른 글

RMAN  (0) 2023.11.12
[Oracle] 자주 쓰는 명령어  (0) 2023.11.10
[Oracle] 이전 명령어 방향키로 출력  (0) 2023.03.15
[Oracle] Sequence  (0) 2023.03.13
[Oracle] Listener & Oracel DB  (0) 2023.03.12

1. https://technet.tmaxsoft.com/  홈페이지 접속 & 파일 다운을 위해 가입 필요

1.1 상단의 '다운로드' - 좌측의 '데모라이선스 신청' 클릭 으로 라이선스 발급 필요

이때 Host Name은 Linux 서버의 host name과 동일하게 기입 필요

--hostname 확인
# hostname
# uname -n

 

2. 상단의 '다운로드' - 좌측의 '데이터베이스' - 'Tibero' - '다운로드' 클릭

 

3. 스크롤을 내려 하단의 'Linux - Linux (x86) 64-bit' 클릭

 

4. 리눅스 환경에서 tibero db 사용을 위해 티베로 전용 사용자 계정 추가

# useradd tibero
# passwd tibero

 

5. JDK 및 Tibero 패키지 설치 (root)

# yum install gcc gcc-c++ libstdc++ libstdc++-devele compat-libstdc++ libaio libaio-devel;
# yum install 1.8.0-openjdk-devel.x86_64 # jdk

 

6. WinSCP를 이용해 tar파일과 메일로 전달받은 license.xml 파일 복사

 

7. 압축 풀기 (tibero)

$ tar -zxvf tibero6-bin-FS07_CS_2005-linux64_3.10-189892-opt.tar.gz

 

8. 라이선스 파일 이동

$ mv license.xml /home/tibero/tibero6/license/
$ chown tibero:tibero /home/tibero/tibero6/license/license.xml


# cd /Tibero/tibero6/license
# ls

license.xml  oss_licenses

 

9. 추가 환경설정

-- 환경변수 파일 열기
# su - tibero
$ vi .bash_profile

-- 아래내용 추가
export TB_HOME=~/tibero6 --압축파일 푼 경로
export TB_SID=tibero
export LD_LIBRARY_PATH=$TB_HOME/lib:$TB_HOME/client/lib
export PATH=$PATH:$TB_HOME/bin:$TB_HOME/client/bin

-- 설정 적용
$ source .bash_profile


-- RemoveIPC 주석 제거
# su - root
# vi /etc/systemd/logind.conf




-- 환경설정
# su - root
# vi /etc/sysctl.conf

-- 아래 내용 수정
#fs.file-max = 6815744
#kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
#kernel.shmall = 1073741824
#kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
fs.aio-max-nr = 1048576
#net.ipv4.ip_local_port_range = 9000 65500

kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.sem = 10000 32000 10000 10000
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 1024 65500



-- 환경설정
# vi /etc/security/limits.conf

-- 아래 내용 추가
tibero           soft    nproc           2047
tibero           hard    nproc           16384
tibero           soft    nofile          1024
tibero           hard    nofile          65536

 

10. Tibero 환경 파일 생성

[tibero@kim license]$ cd $TB_HOME/config
[tibero@kim config]$ ./gen_tip.sh

Using TB_SID "tibero"
/home/tibero/tibero6/config/tibero.tip generated
/home/tibero/tibero6/config/psm_commands generated
/home/tibero/tibero6/client/config/tbdsn.tbr generated.
Running client/config/gen_esql_cfg.sh
Done.

 

 

11. Tibero 기동

[tibero@kim config]$ tbboot nomount

Listener port = 8629

Tibero 6

TmaxData Corporation Copyright (c) 2008-. All rights reserved.
Tibero instance started up (NOMOUNT mode).

-> nomount 모드로 시작 시 control file 생성

-- sys 계정으로 접속 / 초기 암호(tibero) 입력
$ tbsql sys/tibero
-- Database 생성
SQL> create database "tibero" user sys identified by tibero;

완료되면 quit를 입력해 tbsql을 종료하고, 티베로 서버를 NORMAL 모드로 실행한다.

 

[tibero@kim tibero6]$ tbboot
Listener port = 8629

Tibero 6

TmaxData Corporation Copyright (c) 2008-. All rights reserved.
Tibero instance started up (NORMAL mode).
--Data dictionary와 System 패키지생성 
$ cd /home/tibero/tibero6/scripts
$ ./system.sh
 
Enter SYS password: tibero
Enter SYSCAT password: syscat

설치 과정 중 작업 수행 여부 y/n 입력 필요

 

 

12. Tibero 서버 정상 구동 확인

[tibero@kim scripts]$ ps -ef | grep tbsvr
tibero    5345     1  0 17:08 pts/0    00:00:00 tbsvr          -t NORMAL -SVR_SID tibero
tibero    5348  5345  0 17:08 pts/0    00:00:00 tbsvr_MGWP     -t NORMAL -SVR_SID tibero
tibero    5349  5345  2 17:08 pts/0    00:00:15 tbsvr_FGWP000  -t NORMAL -SVR_SID tibero
tibero    5350  5345  0 17:08 pts/0    00:00:00 tbsvr_FGWP001  -t NORMAL -SVR_SID tibero
tibero    5351  5345  0 17:08 pts/0    00:00:00 tbsvr_PEWP000  -t NORMAL -SVR_SID tibero
tibero    5352  5345  0 17:08 pts/0    00:00:00 tbsvr_PEWP001  -t NORMAL -SVR_SID tibero
tibero    5353  5345  0 17:08 pts/0    00:00:00 tbsvr_PEWP002  -t NORMAL -SVR_SID tibero
tibero    5354  5345  0 17:08 pts/0    00:00:00 tbsvr_PEWP003  -t NORMAL -SVR_SID tibero
tibero    5355  5345  0 17:08 pts/0    00:00:00 tbsvr_AGNT     -t NORMAL -SVR_SID tibero
tibero    5356  5345  0 17:08 pts/0    00:00:01 tbsvr_DBWR     -t NORMAL -SVR_SID tibero
tibero    5357  5345  0 17:08 pts/0    00:00:00 tbsvr_RCWP     -t NORMAL -SVR_SID tibero
tibero    7264  2603  0 17:19 pts/0    00:00:00 grep --color=auto tbsvr

 

※ 실제 데이터가 저장되는 데이터베이스의 위치는 설치된 티베로의 디렉토리를 기준으로 /tibero6/database/{데이터베이스명}

1. https://yum.postgresql.org/ 홈페이지 접속

 

2. Repository 설치를 위해 'Repo RPMs' 클릭

3. 환경에 맞는 버전 마우스 오른쪽 버튼 - 링크주소 복사

 

4. Repository 설치

[root@key ~]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm


Loaded plugins: fastestmirror, langpacks
pgdg-redhat-repo-latest.noarch.rpm                                                                  | 8.6 kB  00:00:00
Examining /var/tmp/yum-root-KID3Oy/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-32.noarch
Marking /var/tmp/yum-root-KID3Oy/pgdg-redhat-repo-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package pgdg-redhat-repo.noarch 0:42.0-32 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================
 Package                       Arch                Version              Repository                                    Size
===========================================================================================================================
Installing:
 pgdg-redhat-repo              noarch              42.0-32              /pgdg-redhat-repo-latest.noarch               13 k

Transaction Summary
===========================================================================================================================
Install  1 Package

Total size: 13 k
Installed size: 13 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : pgdg-redhat-repo-42.0-32.noarch                                                                         1/1
  Verifying  : pgdg-redhat-repo-42.0-32.noarch                                                                         1/1

Installed:
  pgdg-redhat-repo.noarch 0:42.0-32

Complete!

 

5. 저장소를 추가한 후 시스템 재부팅 수행 (권고)

# yum -y update
# reboot

 

6. 활성화 된 저장소 목록 확인

[root@key ~]# yum repolist


Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
repo id                                    repo name                                                                 status
base/7/x86_64                              CentOS-7 - Base                                                           10,072
epel/x86_64                                Extra Packages for Enterprise Linux 7 - x86_64                            13,768
extras/7/x86_64                            CentOS-7 - Extras                                                            515
pgdg-common/7/x86_64                       PostgreSQL common RPMs for RHEL / CentOS 7 - x86_64                          388
pgdg11/7/x86_64                            PostgreSQL 11 for RHEL / CentOS 7 - x86_64                                 1,451
pgdg12/7/x86_64                            PostgreSQL 12 for RHEL / CentOS 7 - x86_64                                 1,069
pgdg13/7/x86_64                            PostgreSQL 13 for RHEL / CentOS 7 - x86_64                                   821
pgdg14/7/x86_64                            PostgreSQL 14 for RHEL / CentOS 7 - x86_64                                   550
pgdg15/7/x86_64                            PostgreSQL 15 for RHEL / CentOS 7 - x86_64                                   261
updates/7/x86_64                           CentOS-7 - Updates                                                         4,839
repolist: 33,734

 

7. V13 설치 가능 여부 확인

[root@key ~]# yum search postgresql13


Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
================================================ N/S matched: postgresql13 ================================================
postgresql13.x86_64 : PostgreSQL client programs and libraries
postgresql13-contrib.x86_64 : Contributed source and binaries distributed with PostgreSQL
postgresql13-devel.x86_64 : PostgreSQL development header files and libraries
postgresql13-docs.x86_64 : Extra documentation for PostgreSQL
postgresql13-libs.x86_64 : The shared libraries required for any PostgreSQL clients
postgresql13-llvmjit.x86_64 : Just-in-time compilation support for PostgreSQL
postgresql13-odbc.x86_64 : PostgreSQL ODBC driver
postgresql13-plperl.x86_64 : The Perl procedural language for PostgreSQL
postgresql13-plpython3.x86_64 : The Python3 procedural language for PostgreSQL
postgresql13-pltcl.x86_64 : The Tcl procedural language for PostgreSQL
postgresql13-server.x86_64 : The programs needed to create and run a PostgreSQL server
postgresql13-test.x86_64 : The test suite distributed with PostgreSQL

  Name and summary matches only, use "search all" for everything.

 

 

8. PostgreSQL13 패키치 설치

[root@key ~]# yum -y install postgresql13 postgresql13-server


Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-jp.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package postgresql13.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql13-libs(x86-64) = 13.10-1PGDG.rhel7 for package: postgresql13-13.10-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql13-13.10-1PGDG.rhel7.x86_64
---> Package postgresql13-server.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Running transaction check
---> Package postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================
 Package                             Arch                   Version                           Repository              Size
===========================================================================================================================
Installing:
 postgresql13                        x86_64                 13.10-1PGDG.rhel7                 pgdg13                 1.4 M
 postgresql13-server                 x86_64                 13.10-1PGDG.rhel7                 pgdg13                 5.4 M
Installing for dependencies:
 postgresql13-libs                   x86_64                 13.10-1PGDG.rhel7                 pgdg13                 385 k

Transaction Summary
===========================================================================================================================
Install  2 Packages (+1 Dependent package)

Total download size: 7.1 M
Installed size: 31 M
Downloading packages:
경고: /var/cache/yum/x86_64/7/pgdg13/packages/postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm is not installed
(1/3): postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm                                               | 385 kB  00:00:02
(2/3): postgresql13-13.10-1PGDG.rhel7.x86_64.rpm                                                    | 1.4 MB  00:00:02
(3/3): postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm                                             | 5.4 MB  00:00:05
---------------------------------------------------------------------------------------------------------------------------
Total                                                                                      927 kB/s | 7.1 MB  00:00:07
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 Package    : pgdg-redhat-repo-42.0-32.noarch (@/pgdg-redhat-repo-latest.noarch)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : postgresql13-libs-13.10-1PGDG.rhel7.x86_64                                                              1/3
  Installing : postgresql13-13.10-1PGDG.rhel7.x86_64                                                                   2/3
  Installing : postgresql13-server-13.10-1PGDG.rhel7.x86_64                                                            3/3
  Verifying  : postgresql13-server-13.10-1PGDG.rhel7.x86_64                                                            1/3
  Verifying  : postgresql13-13.10-1PGDG.rhel7.x86_64                                                                   2/3
  Verifying  : postgresql13-libs-13.10-1PGDG.rhel7.x86_64                                                              3/3

Installed:
  postgresql13.x86_64 0:13.10-1PGDG.rhel7                  postgresql13-server.x86_64 0:13.10-1PGDG.rhel7

Dependency Installed:
  postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7

Complete!

 

9. 기본 데이터베이스 설정 (초기화)

# sudo /usr/pgsql-13/bin/postgresql-13-setup initdb

Initializing database ... OK

+ 이때, 기본 데이터베이스는 'postgres' 이름으로 생성 됨

 

10. PostgreSQL 서비스 구동

[root@key ~]# systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: https://www.postgresql.org/docs/13/static/

처음에 cmd 입력 했더니 .service도 disabled / Active : inactive (dead) ,,,,

 

아래와 같이 enable, start 시켜줌

[root@key ~]# sudo systemctl enable postgresql-13
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-13.service to /usr/lib/systemd/system/postgresql-13.service.
[root@key ~]# systemctl start postgresql-13
[root@key ~]# systemctl status postgresql-13
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since 수 2023-03-15 13:55:21 KST; 4s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 10788 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 10794 (postmaster)
    Tasks: 8
   CGroup: /system.slice/postgresql-13.service
           ├─10794 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─10796 postgres: logger
           ├─10798 postgres: checkpointer
           ├─10799 postgres: background writer
           ├─10800 postgres: walwriter
           ├─10801 postgres: autovacuum launcher
           ├─10802 postgres: stats collector
           └─10803 postgres: logical replication launcher

 3월 15 13:55:21 key systemd[1]: Starting PostgreSQL 13 database server...
 3월 15 13:55:21 key postmaster[10794]: 2023-03-15 13:55:21.123 KST [10794] 로그:  서버 로그를 로그 수집 프로세스…냅니다.
 3월 15 13:55:21 key postmaster[10794]: 2023-03-15 13:55:21.123 KST [10794] 힌트:  이제부터 서버 로그는 "log" 디렉…됩니다.
 3월 15 13:55:21 key systemd[1]: Started PostgreSQL 13 database server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@key ~]#

 

 

11. PostgreSQL 접속

[root@key ~]# su - postgres

-bash-4.2$ psql
psql (13.10)
도움말을 보려면 "help"를 입력하십시오.

1. https://mariadb.org/download 홈페이지 접속

 

2. 'MariaDB Repositories' - 환경에 맞는 버전 클릭

3. 'Mirror'는 자동생성

4. 아래의 설치 코드 복사

 

 

5. Repository 파일 생성 후 위 복사한 코드 입력

# vi /etc/yum.repos.d/MariaDB.repo

 

 

6. MariaDB 설치

# yum install MariaDB
 
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile

 

 

 

7. 설치 확인

--rpm 패키지 확인
[root@key ~]# rpm -qa | grep MariaDB
MariaDB-compat-10.4.28-1.el7.centos.x86_64
MariaDB-common-10.4.28-1.el7.centos.x86_64
MariaDB-server-10.4.28-1.el7.centos.x86_64
MariaDB-client-10.4.28-1.el7.centos.x86_64

--버전 확인
# mairadb -V
mariadb  Ver 15.1 Distrib 10.4.26-MariaDB, for Linux (x86_64) using readline 5.1

 

 

 

 

8. mariaDB 시작

[root@key ~]# systemctl start mariadb

 

9. 패스워드 변경

[root@key ~]# /usr/bin/mysqladmin -u root password
New password:
Confirm new password:

 

10. 포트와 데몬 확인

[root@key ~]# netstat -anp | grep 3306
tcp6       0      0 :::3306                 :::*                    LISTEN      3442/mysqld

 

11. MariaDB 접속 & DB 확인

[root@key ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.28-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.



MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.002 sec)

MariaDB [(none)]>
// root 계정 접속
$ yum -y install epel-release
$ yum list install rlwrap
$ yum -y install rlwrap
 
// oracle 설치 계정 접속
$ vi .bashrc

alias sqlplus="rlwrap sqlplus" <- 추가
 
 
$ source .bashrc

'Database > Oracle' 카테고리의 다른 글

[Oracle] 자주 쓰는 명령어  (0) 2023.11.10
[Oracle] 관리자 계정(system, sys) 비밀번호 변경  (0) 2023.03.16
[Oracle] Sequence  (0) 2023.03.13
[Oracle] Listener & Oracel DB  (0) 2023.03.12
[Oracle] SCN, Checkpoint  (0) 2023.03.12

1. MySQL 홈페이지 접속

https://www.mysql.com/products/community/

 

 

2. 'Download MySQL Community Edition' 클릭

 

 

3. yum 설치를 위해 Yum Repository 선택

 

 

4.  CentOS7 파일 'Download'

 

 

5. 'No thanks, just start my download' 마우스 오른쪽 버튼 ->  '링크 주소 복사'

 

 

6. (CentOS7 환경 / root 계정)

아래 yum~ command 입력으로 mysql 설치 진행

# yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
 
Loaded plugins: fastestmirror, langpacks
mysql80-community-release-el7-7.noarch.rpm                                                                                                                                                                            |  11 kB  00:00:00
Examining /var/tmp/yum-root-QZHkdH/mysql80-community-release-el7-7.noarch.rpm: mysql80-community-release-el7-7.noarch
Marking /var/tmp/yum-root-QZHkdH/mysql80-community-release-el7-7.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-7 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
=============================================================================================================================================================================================================================================
 Package                                                        Arch                                        Version                                       Repository                                                                    Size
=============================================================================================================================================================================================================================================
Installing:
 mysql80-community-release                                      noarch                                      el7-7                                         /mysql80-community-release-el7-7.noarch                                       10 k
 
Transaction Summary
=============================================================================================================================================================================================================================================
Install  1 Package
 
Total size: 10 k
Installed size: 10 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql80-community-release-el7-7.noarch                                                                                                                                                                                    1/1
  Verifying  : mysql80-community-release-el7-7.noarch                                                                                                                                                                                    1/1
 
Installed:
  mysql80-community-release.noarch 0:el7-7
 
Complete!

 

 

7. community 버전 Repository 설치 확인

# yum repolist enabled | grep "mysql.*"
 
mysql-connectors-community/x86_64       MySQL Connectors Community           213
mysql-tools-community/x86_64            MySQL Tools Community                 96
mysql80-community/x86_64                MySQL 8.0 Community Server           386

 

+ 진행 중 Trying other mirror. 에러 발생 시 

# yum clean all로 캐시 지운 후 command 재입력

 

8. 설치 가능한 MySQL 패키지 목록 조회

# yum search mysql

.
.
.

 

 

9. MySQL 설치

[root@kim ~]# yum install -y mysql-server

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-kr.misakamikoto.network
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
.
.
.

 

10. 설치 버전 확인

[root@kim ~]# mysqld -V
/usr/sbin/mysqld  Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)

[root@kim ~]# mysql --version
mysql  Ver 8.0.32 for Linux on x86_64 (MySQL Community Server - GPL)

 

11. MySQL 구동

[root@kim ~]# systemctl enable mysqld
[root@kim ~]# systemctl start mysqld
[root@kim ~]# systemctl status mysqld

● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since 목 2023-03-16 13:09:40 KST; 4s ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 19037 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 19116 (mysqld)
   Status: "Server is operational"
    Tasks: 39
   CGroup: /system.slice/mysqld.service
           └─19116 /usr/sbin/mysqld

 3월 16 13:09:36 kim systemd[1]: Starting MySQL Server...
 3월 16 13:09:40 kim systemd[1]: Started MySQL Server.

 

 

+ 아래와 같은 에러 발생 시 https://coco-space.tistory.com/16 참고하여 + MariaDB가 사용 했던 모든 로그까지 제거 (기존에 설치되어 있던 MariaDB 관련 에러)

[root@kim ~]# systemctl enable mysqld && systemctl start mysqld && systemctl status mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

이후 MariaDB에서 생성한 데이터파일과 로그 파일이 없는 것 확인

[root@kim ~]# ls -al /var/lib/mysql

합계 4
drwxr-x--x.  2 mysql mysql    6 12월 17 02:22 .
drwxr-xr-x. 64 root  root  4096  3월 16 13:04 ..

 

 

12. MySQL 초기 비밀번호 확인

[root@kim ~]# grep 'temporary password' /var/log/mysqld.log

 

13. MySQL 접속

[root@kim ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

14. 보안정책 조회 & 비밀번호 변경

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name                        | Value  |
+--------------------------------------+--------+
| validate_password.check_user_name    | ON     |
| validate_password.dictionary_file    |        |
| validate_password.length             | 8      |
| validate_password.mixed_case_count   | 1      |
| validate_password.number_count       | 1      |
| validate_password.policy             | MEDIUM |
| validate_password.special_char_count | 1      |
+--------------------------------------+--------+
7 rows in set (0.01 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Abcdef1234!@';

Query OK, 0 rows affected (0.01 sec)

 

15. Database 조회

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

 

 

+

14-1. 비밀번호 정책 변경

더보기

 

명령어 설명
validate_password.mixed_case_count 대소문자 필수 사용
validate_password.number_count 숫자 필수 사용
validate_password.special_char_count 특수문자 필수 사용
validate_password.length 패스워드 길이
validate_password.policy 패스워드 정책 레벨 .  LOW는 위의 정책들을 비활성화 시킴
validate_password.check_user_name 패스워드에 user id 사용 가능 여부
더보기
mysql> SET GLOBAL validate_password.policy=LOW;
Query OK, 0 rows affected (0.00 sec)

mysql> SET GLOBAL validate_password.length=4;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)
[root@kim ~]# vi /etc/my.cnf

아래 내용 추가 작성
validate_password.policy = LOW
validate_password.length = 4

 

[root@kim ~]# systemctl restart mysqld
[root@kim ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)


mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ark5815';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

[root@kim ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

 

[root@kim ~]# systemctl restart mysqld
[root@kim ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password.check_user_name    | ON    |
| validate_password.dictionary_file    |       |
| validate_password.length             | 4     |
| validate_password.mixed_case_count   | 1     |
| validate_password.number_count       | 1     |
| validate_password.policy             | LOW   |
| validate_password.special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.00 sec)


mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'ark5815';
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

[root@kim ~]# mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

[Oracle] Sequence

2023. 3. 13. 16:33

Sequence ?

자동으로 순차적으로 증가하는 순번을 반환하는 데이터베이스 객체

아래와 같은 방법으로 컬럼의 값을 증가 할 수 있음

1. MAX(컬럼) + 1

2. 시퀀스 =  DB에 ROW가 추가 될 때마다 자동으로 +1

 

1. Sequence 생성

CREAT SEQUENCE [스키마명].[시퀀스명]
INCREMENT BY [증감숫자] -- 양수 = 증가 / 음수 = 감소 / default 1
START WITH [시작번호] -- defalut 값은 증가일 때 Minvalue / 감소일 때 Maxvalue
[NOMINVALUE or MINVALUE] [최솟값] 
[NOMAXVALUE or MAXVALUE] [최대값]
-- NOMINVALUE : 디폴트값 설정, 증가일때 1, 감소일때 -1028 
-- MINVALUE : 최소값 설정, 시작숫자와 작거나 같아야하고 MAXVALUE보다 작아야함
-- NOMAXVALUE : 디폴트값 설정, 증가일때 1027, 감소일때 -1
-- MAXVALUE : 최대값 설정, 시작숫자와 같거나 커야하고 MINVALUE보다 커야함
[CYCLE or NOCYCLE] -- 최대값 도달 시 최솟값부터 시작 or not
[CACHE or NOCACHE] -- 메모리에 시퀀스 값을 미리 할당 or not
[ORDER or NOORDER] -- 요청 순으로 값 생성 or not

+ CACHE 설정 시 속도 빠름 / 동시 사용자가 많을 경우 유리

+ ORDER 설정 시 시스템 부하 있을 수 있음

 

--예) 1부터 1씩 증가하여 9999까지 부여
CREATE SEQUENCE TEST_SEQ --시퀀스이름 TEST_SEQ
INCREMENT BY 1 --증가 값 1
START WITH 1 --시작 1
MINVALUE 1 --최소값 1
MAXVALUE 9999 --최대값 9999
NOCYCLE --순환X
CACHE; --메모리에 시퀀스값 미리할당

--예) 1000부터 1씩 감소하여 1까지 부여
CREATE SEQUENCE TEST_SEQ
INCREMENT BY -1
START WITH 1000
MINVALUE 1
MAXVALUE 1000
NOCYCLE
NOCACHE;

 

 

2. Sequence 조회

--전체 sequence 조회
SELECT * FROM SEQ;
SELECT * FROM USER_SEQUENCES;

--현재 sequence 조회
SELECT TEST_SEQ.CURRVAL
  FROM dual;
  
--현재 sequence의 다음 값
--이때, 현 SELECT문으로 시퀀스 값 추가 증가 됨
SELECT TEST_SEQ.NEXTVAL
  FROM dual;
+ CURRVAL은 여러번 실행해도 순번은 증가 X
+ NEXTVAL을 한번 실행한 세션에서만 사용 가능하다. 위의 쿼리만 사용 시 아래 에러 발생
ORA-08002 : emp_seq.CURRVAL은 이 세션에서는 정의 되어있지않습니다

 

* NEXTVAL 및 CURRVAL을 사용할 수 있는 경우
 - 서브쿼리가 아닌 SELECT문
 - INSERT문의 SELECT절
 - INSERT문의 VALUE절
 - UPDATE문의 SET절


* NEXTVAL 및 CURRVAL을 사용할 수 없는 경우
 - VIEW의 SELECT절
 - DISTINCT 키워드가 있는 SELECT문
 - GROUP BY, HAVING, ORDER BY절이 있는 SELECT문
 - SELECT, DELETE, UPDATE의 서브쿼리
 - CREATE TABLE, ALTER TABLE 명령의 DEFAULT값

 

 

3. Sequence 수정

시퀀스는 DDL문으로, ALTER문으로 수정

ALTER SEQUENCE TEST_SEQ INCREMENT BY 2 --증가값을 2로 변경
ALTER SEQUENCE TEST_SEQ MAXVALUE 99999 --최대값을 9999에서 999로 변경

※ STARTWITH (시작값) 변경 불가

 

 

4. Sequence 삭제

DROP SEQUENCE TEST_SEQ

 

 

 

 

 

참고 https://mine-it-record.tistory.com/62 https://coding-factory.tistory.com/420 https://gent.tistory.com/393

'Database > Oracle' 카테고리의 다른 글

[Oracle] 관리자 계정(system, sys) 비밀번호 변경  (0) 2023.03.16
[Oracle] 이전 명령어 방향키로 출력  (0) 2023.03.15
[Oracle] Listener & Oracel DB  (0) 2023.03.12
[Oracle] SCN, Checkpoint  (0) 2023.03.12
[Oracle] 구조  (0) 2023.03.09

[SQL] SQL문 실행 원리

2023. 3. 13. 11:04

1. Parsing 파싱

  • SQL문에는 처리 방법이 적혀 있지 않기 때문에 처리 방법을 생성할 필요가 있음
  • 처리 방법을 공유 풀에 캐시 해두고 재활용 하기 위함
  • SQL문 처리 횟수와 처리 시간을 줄여 성능을 향상 시키기 위함
  • 오라클은 해시 알고리즘을 사용해 SQL문 마다 ID를 생성
  • SQL 문을 문자열로 해시 함수에 입력하고 출력된 해시 값을 SQL문의 ID로 사용
  • 문자열로 입력 받기 때문에 대문자와 소문자를 구별하여 해시 값이 달라짐

1. Syntax Check (문법 검사)

 : 키워드(SELECT, FROM, WHERE..) 검사

2. Semantic Check (의미 검사)

 : 테이블, 컬럼등의 사용자마다 다른 부분 검사 

 -> 다른 부분이 없다면 오류

3. Shared Pool Check (lib. 캐시 확인)

  : SQL 또는 PL/SQL 문장 결과가 Lib. cache* 내에 있는지 조회

 -> 있으면 Soft Parse Execution, 없으면 Hard Parse Optimization

 3.1 Optimization (≒ 네비)

   : Data Dictionary 등을 참조해서 실행계획 생성

 3.2 Row Source Generation

   : 3.1 단계에서 가장 좋은 계획 선택

4. Execution (수행)

 

+ Optimizer

= Parser(파서) / SQL문을 분석하고 최적의 '실행계획' 을 생성하는 기능

조인에서 어느 테이블을 먼저 읽어야 하는지, 어떤 인덱스를 실행시켜야 좋은지 등을 판별 (척도 RBO(Rule Base Optimizer) / CBO(Cost Based Optimizer*)

*RBO - Server Process가 실행 계획을 세워달라고 요청이 오면 미리 정해놓은 규칙 사용

  CBO - Data Dictionary 내용 참고하여 판별 / 10g 하위 버전은 Data Dictionary 자동으로 업데이트 X

 

* Library Cache
- 해시구조로 관리
- SQL 쿼리마다 해시값을 매핑해서 저장

 

 

2. 처리 단계

- Parse(구문 분석) : 실행계획을 세우고 가장 좋은 실행계획을 선택하기 위한 과정

- Bind(값 치환) : 같은 쿼리문을 줄이는 과정

 Hard Parse를 줄여주어서 성능 향상에 도움

 cf) PGA에서 Bind 변수 저장 하는 곳 = Persistent Area

- Execute(실행) : Data File에서 원하는 데이터를 Buffer Cache로 복사해오는 과정 (∵ Server Process가 데이터 조회 가능)

- Fetch(인출) : Block 단위로 복사된 데이터에서 원하는 데이터만 뽑아 가는 과정

 

+ DML - UPDATE (SELECT 제외한 DML)

Parse -> Bind → Redo Log Buffer에 기록 Undo Segment에 기록 DB Buffer Cache의 실제 데이터 변경

1. Execute 과정에서 서버프로세스는 데이터의 변경 내역을 Redo Log Buff.에 기록

2. Undo Segment에 이전 데이터 기록

3. Data Buffer Cache의 내용 변경

 

 

 

 

참고 https://notemusic.tistory.com/17

'Database > SQL' 카테고리의 다른 글

[SQL] 명령어  (0) 2023.03.17
[SQL] DDL / DML / DCL  (0) 2023.03.10

+ Recent posts