Day14

2023. 3. 23. 19:14AWS 기반 데이터분석 처리 고급 SW 클라우드 개발자 양성과정

###VNC (원격터미널을 봄, GUI가 없어서 봄=> ftp)

[root@centos /work]# rpm -qa | grep vnc
tigervnc-license-1.12.0-9.el8.noarch
gtk-vnc2-0.9.0-2.el8.x86_64
tigervnc-server-minimal-1.12.0-9.el8.x86_64
gvnc-0.9.0-2.el8.x86_64
libvncserver-0.9.11-17.el8.x86_64

 

[root@centos /work]# yum -y install tigervnc-server

 

[root@centos /work]# rpm -qa | grep vnc
tigervnc-server-1.12.0-9.el8.x86_64
tigervnc-license-1.12.0-9.el8.noarch
gtk-vnc2-0.9.0-2.el8.x86_64
tigervnc-server-minimal-1.12.0-9.el8.x86_64
tigervnc-selinux-1.12.0-9.el8.noarch
gvnc-0.9.0-2.el8.x86_64
libvncserver-0.9.11-17.el8.x86_64

 

[root@centos /work]# cd

 

[root@centos ~]# vncpasswd
Password: abc123
Verify:abc123
Would you like to enter a view-only password (y/n)? y

Password: abc123
Verify:abc123

 

[root@centos ~]# vncserver :1  (server1을 무조건 띄어줘야함)

WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
xauth:  file /root/.Xauthority does not exist

New 'centos:1 (root)' desktop is centos:1

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/centos:1.log

 

[root@centos ~]# cat .vnc/xstartup
#!/bin/sh

unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
/etc/X11/xinit/xinitrc
# Assume either Gnome will be started by default when installed
# We want to kill the session automatically in this case when user logs out. In case you modify
# /etc/X11/xinit/Xclients or ~/.Xclients yourself to achieve a different result, then you should
# be responsible to modify below code to avoid that your session will be automatically killed
if [ -e /usr/bin/gnome-session ]; then
    vncserver -kill $DISPLAY
fi
[root@centos ~]# vncserver -kill :1 (무조건 한 번 죽여줘야함)

WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
Killing Xvnc process ID 6983
[root@centos ~]# vncserver :1 -geometry 1024x768 -depth 32 (설정값)

WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.

New 'centos:1 (root)' desktop is centos:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/centos:1.log

 

[root@centos ~]# firewall-cmd --add-port=5901/udp
success
[root@centos ~]# firewall-cmd --add-port=5901/tcp
success

[root@centos ~]# firewall-cmd --add-port=5902/udp
success

[root@centos ~]# firewall-cmd --add-port=5902/tcp
success

tcp : transmission control protocol하는 포로토콜 (속도를 천천히) 신뢰성이 있음 못알아먹겠어 nack / 알아듣겠어 ack (4개중 3개만 받으면 ack)

udp: user diagrm protocol(나 혼자 떠드는 것, 나는 보냈음, 상대방은 상관없음, broadcast) 신뢰성이 없지만,  실시간성으로 함. (실시간성)

 

[root@centos ~]# firewall-cmd --list-ports 
5901/tcp 5902/tcp 5901/udp 5902/udp

[root@centos ~]# vncserver- kill :1

 

###호스트컴터에서###

VNC Viewer 다운 받아서 1)192.168..1.145  3) do not want체크  3) password  abc123 4) remeber 체크

 

### cut command

-c 

-b

-d

-f

-z

 

# cd work

 

[root@centos /work]# vi test-data
[root@centos /work]# cat -n test-data
     1  UNIX is great os. unix is opensource. unix is free os.
     2  learn operating system.
     3  unix linux which one you choose.
     4  user is easy to learn. unix is a multiuser os. learn unix. unix is powerful.
[root@centos /work]# cut -c 2-4 test-data (2에서 4번째 글자)
NIX
ear
nix
ser

[root@centos /work]# cut -c 10- test-data   (test-dat에서 10에서부터 나머지)
reat os. unix is opensource. unix is free os.
rating system.
x which one you choose.
asy to learn. unix is a multiuser os. learn unix. unix is powerful.

[root@centos /work]# cut -c -6 test-data
UNIX i
learn
unix l
user i
[root@centos /work]# cut -c 2,5,7 test-data  (공백을 무시하지 않고 다 count 함)

N s
eno
n i
s s

[root@centos /work]# cut -d ":" -f 1 passwd   (user를 정보를 가져옴, 1 필드 1번)
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
operator
games
ftp
nobody
dbus
systemd-coredump
systemd-resolve
tss
polkitd
geoclue
unbound
rtkit
pipewire
clevis
usbmuxd
gluster
rpc
avahi
chrony
dnsmasq
saslauth
libstoragemgmt
sssd
qemu
cockpit-ws
cockpit-wsinstance
colord
rpcuser
pulse
setroubleshoot
flatpak
gdm
gnome-initial-setup
sshd
tcpdump
centos
pesign
vboxadd
user1
user2
user3

 

[root@centos /work]# cut -d ":" -f 7 passwd  (shell을 가져옴)
/bin/bash
/sbin/nologin

 

[root@centos /work]# cut -d ":" -f 1,7 passwd (user와 shell을 가져옴)
root:/bin/bash
bin:/sbin/nologin

 

##paste command

 

# vi names

# vi numbers

 

[root@centos /work]# paste names numbers (합치는 것)
Mark Smith      555-1234
Bobby Brown     555-9876
Sue Miler       555-6743
Jenny lgotit    867-5309

 

[root@centos /work]# paste -s names numbers (행과 열을 바꿈)   (-s serial 한 번에 한줄의 파일을 표시함)
Mark Smith      Bobby Brown     Sue Miler       Jenny lgotit
555-1234        555-9876        555-6743        867-5309

 

[root@centos /work]# paste -d. names numbers (.으로 붙임)
Mark Smith.555-1234
Bobby Brown.555-9876
Sue Miler.555-6743
Jenny lgotit.867-5309

 

[root@centos /work]# paste -s -d '\t\n' names (\t 는 tab을 준거고 \n은 띄어쓰기 한 것임 , -s 는 한 줄에 표)
Mark Smith      Bobby Brown
Sue Miler       Jenny lgotit

 

[root@centos /work]# paste -s -d ',\n' names numbers  (delimeter = 첫번째 공백은 ,  두번째는  (\n))
Mark Smith,Bobby Brown
Sue Miler,Jenny lgotit
555-1234,555-9876
555-6743,867-5309

 

[root@centos /work]# paste -d ',\n' names numbers (첫번째는(,) 두번째는 (\n) )
Mark Smith,555-1234
Bobby Brown,555-9876
Sue Miler,555-6743
Jenny lgotit,867-5309

 

[root@centos /work]# paste -s -d '\t\n' names
Mark Smith      Bobby Brown (-d '첫번쨰 공백 tab' , 두번째는 ' \n')
Sue Miler       Jenny lgotit
[root@centos /work]# paste -s -d 'n' names
Mark SmithnBobby BrownnSue MilernJenny lgotit (단어 끝 공백에만 n을 붙임, -s 한줄에 -  'n'을 붙임)

[root@centos /work]# paste -s -d ',\n' names numbers
Mark Smith,Bobby Brown
Sue Miler,Jenny lgotit
555-1234,555-9876
555-6743,867-5309
[root@centos /work]# paste -d ',\n' names numbers
Mark Smith,555-1234
Bobby Brown,555-9876
Sue Miler,555-6743
Jenny lgotit,867-5309
[root@centos /work]# paste -d , -s names (-d 다음에 콤마 안줘도 상관없음)
Mark Smith,Bobby Brown,Sue Miler,Jenny lgotit
[root@centos /work]# paste - < names
Mark Smith
Bobby Brown
Sue Miler
Jenny lgotit

[root@centos /work]# paste - < names (한행에 찍히는 열의 갯수:1개)
Mark Smith
Bobby Brown
Sue Miler
Jenny lgotit
[root@centos /work]# paste - - < names (한행에 찍히는 열의 갯수:2개)
Mark Smith      Bobby Brown
Sue Miler       Jenny lgotit
[root@centos /work]# paste - - - < names (한행에 찍히는 열의 갯수:3개)
Mark Smith      Bobby Brown     Sue Miler
Jenny lgotit

[root@centos /work]# cat numbers | paste -d ":" names - (출력의 위치를 설정할 수 있음 - 위치에 따라)
Mark Smith:555-1234
Bobby Brown:555-9876
Sue Miler:555-6743
Jenny lgotit:867-5309
[root@centos /work]# cat numbers | paste -d ":" - numbers
555-1234:555-1234
555-9876:555-9876
555-6743:555-6743
867-5309:867-5309

[root@centos /work]# paste -d '\n' names numbers (한줄씩 교차로)
Mark Smith
555-1234
Bobby Brown
555-9876
Sue Miler
555-6743
Jenny lgotit
867-5309

[root@centos /allnew/shells]# vi string1.sh

      1 #!/bin/bash
      2
      3 str="Hello, World, CentOS!"
      4 echo "${str:0:5}"  (0부터 5개)
[root@centos /allnew/shells]# chmod +x *.sh
[root@centos /allnew/shells]# ./string1.sh 
World, CentOS!

[root@centos /allnew/shells]# vi string1.sh

      1 #!/bin/bash
      2
      3 str="Hello, World, CentOS!"
      4 echo "${str:7}"  (7번에서 시작)
[root@centos /allnew/shells]# chmod +x *.sh
[root@centos /allnew/shells]# ./string1.sh 
World, CentOS!

[root@centos /allnew/shells]# vi string3.sh  

1 #!/bin/bash
      2
      3 str="Hello, World, CentOS!"
      4 echo "${str:(-7)}"

[root@centos /allnew/shells]# ./string3.sh
CentOS!

[root@centos /allnew/shells]# vi string4.sh

      1 #!/bin/bash
      2
      3 str="Hello, World, CentOS!"
      4 echo "${str:(-7):4}"

[root@centos /allnew/shells]# ./string4.sh
Cent

[root@centos /allnew/shells]# vi string5.sh

      1 #!/bin/bash
      2
      3 str="Hello, World, CentOS!"
      4 echo $str | cut -c 8-12

[root@centos /allnew/shells]# ./string5.sh
World

 

pattern1,sh 

 

 

 

### split command

# cd /work

 

[root@centos /work]# for i in {1..100};do printf "%03d %s\n" $i $(openssl rand -hex 12);done > split-test

001 3fe038e8d1a870d33a9a1b13  (rand -sed 12번째)
002 52983a695a316b5d203f1bbe

 

[root@centos /work]# split -l 10 split-test
[root@centos /work]# ls
./   names    passwd      test-data  xab  xad  xaf  xah  xaj
../  numbers  split-test  xaa        xac  xae  xag  xai
[root@centos /work]# ll xa* | wc -l
10

 

split을 사용하면 xa 가 기본 값임

 

root@centos /work]# diff catText diffText

1c1 (1번째에 차이가 있다)
< Hello! (왼쪽은 Hello! 인데)
---
> Hi! (오른쪽은 Hi!임)
2a3  (2번째 줄은 공동사항)
> How are you? (2번째 파일에 3번째만 How are you 만 있다)

 

[root@centos /work]# comm catText diffText
Hello! (catText)
        Hi!  (diffText)
                Nice to meet you. (공동사항)
comm: file 2 is not in sorted order (파일 2번에는 없음)
        How are you? (2번에만 있는 사항)

 

### diff /patch command

# mkdir a b

[root@centos /work]# diff -Naur a b

diff -Naur a/main.c b/main.c
--- a/main.c    2023-03-23 14:37:45.470727063 +0900
+++ b/main.c    2023-03-23 14:36:03.462747520 +0900  (b라인이 뭐가 더 많음 ###이 붙은이유)
@@ -1,6 +1,7 @@
 #include <stdio.h>

 int main() {
+       printf("Hello World~!!");
        return 0;
 }

 

[root@centos /work]# diff -Naur a b > main.patch   (a 와 b 사이에는 차이점임, patch)

 

[root@centos /work]# patch -p0 < main.patch (a를 patch 해줌)

 

[root@centos /work]# diff -Naur a b (같은 상태가 됨)

 

[root@centos /work]# patch -p0 -R < main.patch   (p0 은 patch파일이 같은 경로에 있다)
patching file a/main.c

 

[root@centos /work]# cd a
[root@centos /work/a]# patch -p1 < ../main.patch   (-p1은 patch파일이 같은 경로에 있지 않다)

patching file main.c
[root@centos /work/a]# diff -Naur main.c ../b/main.c
[root@centos /work/a]# patch -p1 -R <../main.patch  (-R reverse)
patching file main.c
[root@centos /work/a]# cd ..
[root@centos /work]# diff -Naur a b
diff -Naur a/main.c b/main.c
--- a/main.c    2023-03-23 14:43:17.667849096 +0900
+++ b/main.c    2023-03-23 14:36:03.462747520 +0900
@@ -1,6 +1,7 @@
 #include <stdio.h>

 int main() {
+       printf("Hello World~!!");
        return 0;
 }

[root@centos /work]# ls
./   0   b/       diffText    names    passwd      test-data  xab
../  a/  catText  main.patch  numbers  split-test  xaa        xac
[root@centos /work]# file main.patch
main.patch: unified diff output, ASCII text
[root@centos /work]# cat -n main.patch
     1  diff -Naur a/main.c b/main.c
     2  --- a/main.c    2023-03-23 14:37:45.470727063 +0900
     3  +++ b/main.c    2023-03-23 14:36:03.462747520 +0900
     4  @@ -1,6 +1,7 @@
     5   #include <stdio.h>
     6
     7   int main() {
     8  +       printf("Hello World~!!");
     9          return 0;
    10   }
    11

 

Workbench = 

enable = autostart option 

 

demo = maria db 인데 mysql 은 

 

create database st_db; (; 끝내는 의미, " ; " 세미콜론으로 무조건 끝내)

 

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

 

MariaDB [st_db]> show tables;
Empty set (0.000 sec)

 

MariaDB [st_db]> create table st_info (ST_ID int, NAME varchar(20), DEPT varchar(25)) default charset_utf (utf는 한글을 위해서 넣음)

 

MariaDB [st_db]> show tables;
+-----------------+
| Tables_in_st_db |
+-----------------+
| st_info         |
+-----------------+
1 row in set (0.002 sec)

MariaDB [st_db]> explain st_info;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ST_ID | int(11)     | YES  |     | NULL    |       |
| NAME  | varchar(20) | YES  |     | NULL    |       |
| DEPT  | varchar(25) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.003 sec)

 

MariaDB [st_db]> alter table st_info modify ST_ID int Not Null;
Query OK, 0 rows affected (0.097 sec)
Records: 0  Duplicates: 0  Warnings: 0

MariaDB [st_db]> explain st_info;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ST_ID | int(11)     | NO   |     | NULL    |       |
| NAME  | varchar(20) | YES  |     | NULL    |       |
| DEPT  | varchar(25) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.001 sec)

 

MariaDB [st_db]> alter table st_info add constraint pk_stinfo primary key(ST_ID);  (ST_ID를 PK로 사용하겠다)
Query OK, 0 rows affected, 1 warning (0.084 sec)
Records: 0  Duplicates: 0  Warnings: 1

MariaDB [st_db]> explain st_info;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ST_ID | int(11)     | NO   | PRI | NULL    |       |
| NAME  | varchar(20) | YES  |     | NULL    |       |
| DEPT  | varchar(25) | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.001 sec)

왜 ID만 Not null만 인가? 학번이 제일 우선순위 (

MariaDB [st_db]> create table st_grade (ST_ID int, Linux int, DB int);
Query OK, 0 rows affected (0.042 sec)

 

MariaDB [st_db]> show tables;
+-----------------+
| Tables_in_st_db |
+-----------------+
| st_grade        |
| st_info         |
+-----------------+
2 rows in set (0.002 sec)

 

MariaDB [st_db]> explain st_grade;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| ST_ID | int(11) | YES  |     | NULL    |       |  (not null이 허용되어있음)

| Linux | int(11) | YES  |     | NULL    |       |
| DB    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.001 sec)

 

MariaDB [st_db]> explain st_grade;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| ST_ID | int(11) | NO   |     | NULL    |       |
| Linux | int(11) | YES  |     | NULL    |       |
| DB    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
3 rows in set (0.003 sec)

 

MariaDB [st_db]> alter table st_grade add constraint pk_stgrade primary key (ST_ID);
Query OK, 0 rows affected, 1 warning (0.072 sec)
Records: 0  Duplicates: 0  Warnings: 1

MariaDB [st_db]> explain st_grade;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| ST_ID | int(11) | NO   | PRI | NULL    |       |
| Linux | int(11) | YES  |     | NULL    |       |
| DB    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+-

 

MariaDB [st_db]> insert into st_info values (202301, "LeeGilDong", "Game");
Query OK, 1 row affected (0.044 sec)

MariaDB [st_db]> insert into st_info values (202301, "KimGilDong", "Computer");
ERROR 1062 (23000): Duplicate entry '202301' for key 'PRIMARY'
MariaDB [st_db]> insert into st_info values (202302, "KimGilDong", "Computer");
Query OK, 1 row affected (0.010 sec)

MariaDB [st_db]> insert into st_info values (202303, "HongGilDong", "Computer");
Query OK, 1 row affected (0.007 sec)

MariaDB [st_db]> select * from st_info;
+--------+-------------+----------+
| ST_ID  | NAME        | DEPT     |
+--------+-------------+----------+
| 202301 | LeeGilDong  | Game     |
| 202302 | KimGilDong  | Computer |
| 202303 | HongGilDong | Computer |
+--------+-------------+----------+
3 rows in set (0.000 sec)

 

MariaDB [st_db]> insert into st_grade values (202301, 90, 80);
Query OK, 1 row affected (0.012 sec)

MariaDB [st_db]> insert into st_grade values (202302, 70, 95);
Query OK, 1 row affected (0.006 sec)

MariaDB [st_db]> insert into st_grade values (202303, 80, 65);
Query OK, 1 row affected (0.045 sec)

MariaDB [st_db]> select * from st_grade;
+--------+-------+------+
| ST_ID  | Linux | DB   |
+--------+-------+------+
| 202301 |    90 |   80 |
| 202302 |    70 |   95 |
| 202303 |    80 |   65 |
+--------+-------+------+
3 rows in set (0.001 sec)

MariaDB [st_db]> select NAME, DEPT from st_info where ST_ID=202301; (하나의 테이블에서 원하는 2개의 필드만 가져옴)
+------------+------+
| NAME       | DEPT |
+------------+------+
| LeeGilDong | Game |
+------------+------+
1 row in set (0.001 sec)

MariaDB [st_db]> select Linux from st_grade where ST_ID=202301;
+-------+
| Linux |
+-------+
|    90 |
+-------+
1 row in set (0.002 sec)

MariaDB [st_db]> select st_info.NAME, st_info.DEPT, st_grade.Linux, st_grade.DB from st_info, st_grade where st_info.ST_ID=202301 and st_grade.ST_ID=202301;
+------------+------+-------+------+
| NAME       | DEPT | Linux | DB   |
+------------+------+-------+------+
| LeeGilDong | Game |    90 |   80 |
+------------+------+-------+------+
1 row in set (0.001 sec)

MariaDB [st_db]> \q (나가기)
Bye

[root@centos /allnew/db]# mysqladmin version

[root@centos /allnew/db]# mysqladmin status
Uptime: 3059  Threads: 6  Questions: 60  Slow queries: 0  Opens: 24  Flush tables: 1  Open tables: 13  Queries per second avg: 0.019

[root@centos /allnew/db]# mysqladmin password '1234'

[root@centos /allnew/db]# mysql

[root@centos /allnew/db]# mysql -u root -p
Enter password: 1234 

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 15
Server version: 10.3.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)]> \q
Bye

 

[root@centos /allnew/db]# vi select_stgrade.sql

1. use st_db;

2. select st_info.NAME, st_info.DEPT, st_grade.Linux, st_grade.DB from st_info, st_grade where st_info.ST_ID=202301 and st_grade.ST_ID=202301;

 

[root@centos /allnew/db]# mysql -u root -p < select_stgrade.sql
Enter password: 1234

NAME    DEPT    Linux   DB
LeeGilDong      Game    90      80

Active Internet connections (only servers)

 

[root@centos /allnew/db]# mysql -u root -p
Enter password: 1234

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 17
Server version: 10.3.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)]> use mysql  (제어를 할 때 mysql에서 진행)

 

[root@centos /allnew/db]# vi /etc/my.cnf.d/mariadb-server.cnf
[root@centos /allnew/db]# systemctl restart mariadb
[root@centos /allnew/db]# systemctl status mariadb
● mariadb.service - MariaDB 10.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-03-23 16:18:50 KST; 5s ago
     Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
  Process: 17244 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 17174 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mariadb.service (code=exited, status=0>
  Process: 17149 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 17213 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 30 (limit: 23104)
   Memory: 69.8M
   CGroup: /system.slice/mariadb.service
           └─17213 /usr/libexec/mysqld --basedir=/usr

 3월 23 16:18:49 centos systemd[1]: Starting MariaDB 10.3 database server...
 3월 23 16:18:49 centos mysql-prepare-db-dir[17174]: Database MariaDB is probably initialized in /var/>
 3월 23 16:18:49 centos mysql-prepare-db-dir[17174]: If this is not the case, make sure the /var/lib/m>
 3월 23 16:18:49 centos mysqld[17213]: 2023-03-23 16:18:49 0 [Note] /usr/libexec/mysqld (mysqld 10.3.2>
 3월 23 16:18:50 centos systemd[1]: Started MariaDB 10.3 database server.
[root@centos /allnew/db]#
[root@centos /allnew/db]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN      5322/xinetd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1224/sshd
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1225/cupsd
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      17213/mysqld
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      7548/Xvnc
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd
tcp6       0      0 :::22                   :::*                    LISTEN      1224/sshd
tcp6       0      0 ::1:631                 :::*                    LISTEN      1225/cupsd
tcp6       0      0 :::5901                 :::*                    LISTEN      7548/Xvnc
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd
[root@centos /allnew/db]# firewall-cmd --add-port=3306/tcp
success
[root@centos /allnew/db]# firewall-cmd --add-port=3306/udp
success
[root@centos /allnew/db]# firewall-cmd --list-port
3306/tcp 5901/tcp 5902/tcp 3306/udp 5901/udp 5902/udp
[root@centos /allnew/db]# firewall-cmd --remove-port=3306/udp
success
[root@centos /allnew/db]# firewall-cmd --remove-port=3306/tcp
success
[root@centos /allnew/db]# firewall-cmd --list-port
5901/tcp 5902/tcp 5901/udp 5902/udp
[root@centos /allnew/db]# firewall-cmd --permanent --add-port=3306/tcp
success
[root@centos /allnew/db]# firewall-cmd --permanent --add-port=3306/udp
success

[root@centos /allnew/db]# firewall-cmd --list-port
5901/tcp 5902/tcp 5901/udp 5902/udp
[root@centos /allnew/db]# firewall-cmd --reload
success
[root@centos /allnew/db]# firewall-cmd --state
running
[root@centos /allnew/db]# firewall-cmd --list-port
3306/tcp 3306/udp
[root@centos /allnew/db]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s3
  sources:
  services: cockpit dhcpv6-client ssh
  ports: 3306/tcp 3306/udp
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

[root@centos ~]# systemctl start httpd
[root@centos ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-03-23 16:56:50 KST; 5s ago

[root@centos ~]# netstat -ntlp
Active Internet connections (only servers)

tcp6       0      0 :::80                   :::*                    LISTEN      18576/httpd

[root@centos ~]# firewall-cmd --add-service=http
success

[root@centos ~]# firewall-cmd --list-service
cockpit dhcpv6-client http ssh

[root@centos ~]# cd /var/www/html
[root@centos /var/www/html]# ls
./  ../
[root@centos /var/www/html]# vi index.html

    1 <html>
      2 <head>
      3 <title>Web Server</title>  (맨 위에 Web Server)
      4 </head>
      5 <body>
      6         <H1>Web Server Page~!!</H1>
      7 </head>
      8 </html>

[root@centos /var/www/html]# vi /etc/httpd/conf.d/userdir.conf

17     # UserDir disabled
18
19     #
 20     # To enable requests to /~user/ to serve the user's public_html
 21     # directory, remove the "UserDir disabled" line above, and uncomment
 22     # the following line instead:
 23     #
24     UserDir public_html

[root@centos /var/www/html]# systemctl restart httpd

[root@centos /var/www/html]# systemctl status httpd

● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2023-03-23 17:04:53 KST; 14s ago

[centos@centos ~]$ cd public_html/
[centos@centos ~/public_html]$ cp /var/www/html/index.html .

[centos@centos ~/public_html]$ vi index.html

  1 <html>
  2 <head>
  3 <title>Centos User's Homepage~!!</title>
  4 </head>
  5 <body>
  6         <H1>Welcome~!!</H1>
  7         <H3>Centos User's Page~!!</H3>
  8 </head>
  9 </html>

**chmod 701 user 읽기 쓰기

[centos@centos ~/public_html]$ cd ..
[centos@centos ~]$ chmod 701 .
[centos@centos ~]$ ll
합계 41012
drwx-----x. 16 centos centos     4096  3월 23 17:08 ./
drwxr-xr-x.  6 root   root         59  3월 22 12:20 ../
-rw-------.  1 centos centos      310  3월 16 17:07 .ICEauthority
-rw-------.  1 centos centos     1090  3월 23 10:32 .bash_history
-rw-r--r--.  1 centos centos       18  4월  8  2022 .bash_logout
-rw-r--r--.  1 centos centos      141  4월  8  2022 .bash_profile
-rw-r--r--.  1 centos centos      478  3월 16 18:27 .bashrc
drwxr-xr-x. 10 centos centos     4096  3월 16 17:09 .cache/
drwx------. 11 centos centos     4096  3월 16 17:09 .config/
-rw-------.  1 centos centos       16  3월 16 17:07 .esd_auth
-rw-r--r--.  1 centos centos       13  3월 16 18:27 .exrc
drwx------.  3 centos centos       19  3월 16 17:07 .local/
drwxr-xr-x.  4 centos centos       39  3월 16 16:51 .mozilla/
-rw-r--r--.  1 centos centos       16  3월 16 18:27 .nanorc
drwxrw----.  3 centos centos       19  3월 16 17:07 .pki/
-rw-r--r--.  1 root   root         65  3월 21 09:38 .plan
-rw-------.  1 centos centos     2032  3월 23 17:08 .viminfo
-rw-r--r--.  1 centos centos 10485760  3월 23 10:28 file1
-rw-r--r--.  1 centos centos 10485760  3월 23 10:29 file2
-rw-r--r--.  1 centos centos 10485760  3월 23 10:29 file3
-rw-r--r--.  1 centos centos 10485760  3월 23 10:29 file4
drwx-----x.  2 centos centos       24  3월 23 17:08 public_html/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 공개/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 다운로드/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 문서/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 바탕화면/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 비디오/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 사진/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 서식/
drwxr-xr-x.  2 centos centos        6  3월 16 17:07 음악/
[centos@centos ~]$ exit
logout
[root@centos /var/www/html]# setenforce 0

[root@centos /var/www/html]# yum -y install php php-gd (ODBC- 데이터 베이스와 Oracle을 연결해준다) 

[root@centos /var/www/html]# yum -y install php-mysqlnd (php와 mysql을 연결해줌)

[root@centos /var/www/html]# systemctl restart httpd

[root@centos /var/www/html]# systemctl restart mariadb

[root@centos /var/www/html]# cd /var/www/html (서버의 홈페이지 경로)

[root@centos /var/www/html]# cat > phpinfo.php

<?php phpinfo(); ?>

[root@centos /var/www/html]# cat phpinfo.php
<?php phpinfo(); ?>

phpinfo 연동 시켜준 것이 화면상 나

[root@centos /var/www/html]# ls
./  ../  gnuboard5/  gnuboard5.4.5.5.tar.gz  index.html  phpinfo.php
[root@centos /var/www/html]# cd ./gnuboard5/
[root@centos /var/www/html/gnuboard5]# ls

[root@centos /var/www/html]# ls
./  ../  gnuboard5/  gnuboard5.4.5.5.tar.gz  index.html  phpinfo.php
[root@centos /var/www/html]# cd ./gnuboard5/
[root@centos /var/www/html/gnuboard5]# ls
./           _head.php  common.php  g4_import.php      img/       lib/      skin/
../          _tail.php  config.php  g4_import_run.php  index.php  mobile/   tail.php
LICENSE.txt  adm/       css/        head.php           install/   perms.sh  tail.sub.php
_common.php  bbs/       extend/     head.sub.php       js/        plugin/   theme/
[root@centos /var/www/html/gnuboard5]# mysql -u root -p
Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 10.3.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)]> create database gnu;

Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> grant all privileges on gnu.* to gnuser@localhost identified by '1234';
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> \q
Bye
[root@centos /var/www/html/gnuboard5]# mkdir data

[root@centos /var/www/html/gnuboard5]# chmod 707 data

'AWS 기반 데이터분석 처리 고급 SW 클라우드 개발자 양성과정' 카테고리의 다른 글

node-js  (0) 2023.06.29
1일차  (0) 2023.06.07
0323 Review  (0) 2023.03.23
0323 정리  (0) 2023.03.23
d10  (0) 2023.03.21