# TEST Page

{% hint style="info" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**무료**</mark>**&#x20;교육일정** : <https://doc.skill.or.kr/2022-NHN-Cloud-Education>
{% endhint %}

{% hint style="warning" %}
**2022년 NHN Cloud&#x20;**<mark style="color:red;">**행사/프로모션**</mark>**&#x20;정보 공유** : <https://doc.skill.or.kr/2022-NHN-Cloud-Event-Promotion>
{% endhint %}

<https://getbootstrap.com/docs/5.0/utilities/spacing/>

<https://tcpschool.com/css/intro>

<https://developer.mozilla.org/ko/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout>

<https://www.colorzilla.com/gradient-editor/>

> sudo apt-get install mariadb-server
>
> CREATE DATABASE redmine CHARACTER SET utf8mb4;
>
> GRANT ALL PRIVILEGES ON redmine.\* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine-123'; FLUSH PRIVILEGES;
>
> sudo apt-get install apache2 libapache2-mod-passenger
>
> sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev libsqlite3-dev
>
> sudo apt-get install redmine redmine-mysql
>
> PassengerDefaultUser www-data PassengerRoot /usr/lib/ruby/vendor\_ruby/phusion\_passenger/locations.ini PassengerDefaultRuby /usr/bin/ruby
>
> rvm use ruby-2.6.0\@rails5.2.2 --create
>
> sudo ln -s /usr/share/redmine/public /var/www/html/redmine
>
> vi /etc/apache2/sites-available/redmine.conf
>
> vi /etc/apache2/sites-available/000-default.conf CustomLog ${APACHE\_LOG\_DIR}/access.log combined  RailsBaseURI /redmine PassengerResolveSymlinksInDocumentRoot on
>
> $ sudo touch /usr/share/redmine/Gemfile.lock
>
> $ sudo chown www-data:www-data /usr/share/redmine/Gemfile.lock
>
> sudo apt-get install graphicsmagick-libmagick-dev-compat libmagickcore-dev libmagickwand-dev
>
> sudo apt-get install libmagickwand-dev imagemagick
>
> > CREATE DATABASE redmine CHARACTER SET utf8mb4;
> >
> > GRANT ALL PRIVILEGES ON redmine.\* TO 'redmine'@'localhost' IDENTIFIED BY 'redmine-123';
> >
> > FLUSH PRIVILEGES;
> >
> > apt-get install ruby ruby-dev gem
> >
> > sudo apt-get install apache2 libapache2-mod-passenger
> >
> > sudo vi /etc/apache2/mods-available/passenger.conf
> >
> > PassengerDefaultUser www-data
> >
> > sudo ln -s /usr/share/redmine/public /var/www/html/redmine
> >
> > sudo vi /etc/apache2/sites-available/redmine.conf
> >
> > apt-get install libmysqlclient-dev gem install mysql2 -v '0.5.3'
> >
> > /usr/local/lib/ruby/gems/2.6.0/gems/passenger-6.0.10/bin/passenger
>
> \*\* plugin 추가 :&#x20;
>
> ```
> bundle exec rake redmine:plugins:migrate RAILS_ENV=production
> ```

> ">\<svg/onload=alert(1)>
>
> ">\<svg/onload=alert(document.cookie)>
>
> ">\<svg/onload=alert(document.session)>
>
> ">\<svg/onload=alert(window\.cookie)>
>
> ">\<svg/onload=alert(document.domain)>
>
> ">\<svg/onload=alert(document.origin)>
>
> ">\<iframe id="result" sandbox="allow-scriopts allow-modals"\</iframe>
>
> \<script>console.log("xsstest:"+window\.origin)\</script>
>
> test"/>
>
> test"/>alert(document.cookie)
>
> \="" onmouseover="alert('moitest')
>
> \="" onMouseOver="alert('moitest')
>
> \<P onmouseover=alert(document.cookie);moitest\</P>
>
> ">\</a> ![](http://test.go.kr)

> docker run -p 80:9000 -d --name some-mariadb -e MARIADB\_ROOT\_PASSWORD=project-admin123 -e MARIADB\_DATABASE=yona -e MARIADB\_USER=yona -e MARIADB\_PASSWORD=yonadan mariadb:10.3
>
> docker run -p 80:9000 -d --name yona -e MARIADB\_ROOT\_PASSWORD=project-admin123 mariadb:10.3
>
> apt update apt install -y git vim wget openjdk-8-jdk unzip
>
> mysql -u root -p create user 'yona'@'localhost' IDENTIFIED BY 'project-yona123'; create database yona DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4\_bin ; GRANT ALL ON yona. *to 'yona'@'localhost'; GRANT ALL ON yona.* to 'yona'@'127.0.0.1'; GRANT ALL PRIVILEGES ON *.* TO 'yona'@'localhost' WITH GRANT OPTION; FLUSH privileges;
>
> mysql -u yona -p'yonadan' use yona
>
> 사용자 권한 확인 ---- 확인 할것....

##

##

##

## Amazon Web Service Simple monthly Calculator&#x20;

* <https://calculator.s3.amazonaws.com/index.html>

![](/files/-Me93rIF1S5DoqrITc_U)

## AWS 모든 서비스 리전에 대한 왕복 시간을 표시

* <https://clients.amazonworkspaces.com>

![](/files/-MeOSVgclOQ-MTgGeOwm)

## NHN Cloud Calculator&#x20;

* <https://www.toast.com/kr/pricing/calculator>

![](/files/-Me94TDxlYyW71VkXmRB)

* 접속 시간 TEST Site
  * <https://www.dotcom-tools.com/website-speed-test>

![](/files/-Me9-DatWXCdJ8eVBTut)

![](/files/-Me8zziesvKVr8P1GZy4)

* 성능 테스트
  * apache2-utils 를 설치
    * ab -n 10000 -c 10 <http://google.com/>

{% code title="Apache Bench 사용법" %}

```
# ab -n 1000 -c 10 http://doc.skill.or.kr/
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking doc.skill.or.kr (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests


Server Software:        cloudflare
Server Hostname:        doc.skill.or.kr
Server Port:            80

Document Path:          /
Document Length:        0 bytes

Concurrency Level:      10
Time taken for tests:   2.515 seconds
Complete requests:      1000
Failed requests:        351
   (Connect: 0, Receive: 0, Length: 351, Exceptions: 0)
Non-2xx responses:      1000
Total transferred:      277068 bytes
HTML transferred:       5616 bytes
Requests per second:    397.66 [#/sec] (mean)
Time per request:       25.147 [ms] (mean)
Time per request:       2.515 [ms] (mean, across all concurrent requests)
Transfer rate:          107.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        5    8   1.6      8      18
Processing:     9   17   5.5     15      55
Waiting:        9   16   5.4     15      54
Total:         16   25   5.5     23      62

Percentage of the requests served within a certain time (ms)
  50%     23
  66%     26
  75%     27
  80%     28
  90%     31
  95%     35
  98%     40
  99%     43
 100%     62 (longest request)
```

{% endcode %}

{% code title="Apache Bench 옵션 " %}

```bash
# ab
ab: wrong number of arguments
Usage: ab [options] [http[s]://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make at a time
    -t timelimit    Seconds to max. to spend on benchmarking
                    This implies -n 50000
    -s timeout      Seconds to max. wait for each response
                    Default is 30 seconds
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -B address      Address to bind to when making outgoing connections
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header to use for POST/PUT data, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234'. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -q              Do not show progress when doing more than 150 requests
    -l              Accept variable document length (use this for dynamic pages)
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -m method       Method name
    -h              Display usage information (this message)
    -I              Disable TLS Server Name Indication (SNI) extension
    -Z ciphersuite  Specify SSL/TLS cipher suite (See openssl ciphers)
    -f protocol     Specify SSL/TLS protocol
                    (SSL2, TLS1, TLS1.1, TLS1.2 or ALL)
    -E certfile     Specify optional client certificate chain and private key
```

{% endcode %}

kubectl create namespace test

kubectl create deployment nginx --image nginx --namespace test kubectl create deployment httpd --image httpd --namespace test

kubectl expose deployment nginx --port 80 --target-port 80 --type LoadBalancer --namespace test --load-balancer-ip 133.186.153.62

kubectl delete service nginx --namespace test

supported values: "ClusterIP", "ExternalName", "LoadBalancer", "NodePortㄱ 시"

```
apiVersion: apps/v1
kind: Deployment
metadata:
  name: http-echo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: http-echo
  template:
    metadata:
      labels:
        app: http-echo
    spec:
      containers:
      - name: http-echo
        image: hashicorp/http-echo
        args: ["-text", "hello-world"]
        ports:
        - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  name: http-echo
  annotations:
    loadbalancer.openstack.org/keep-floatingip: "true"
spec:
  ports:
  - port: 5678
    protocol: TCP
    targetPort: 5678
  selector:
    app: http-echo
  loadBalancerIP: 133.186.215.195
  type: LoadBalancer



#####  annotations:    ## 오브젝트 선언형 관리 
#####    loadbalancer.openstack.org/keep-floatingip: "true"    ## 구성    
#####  loadBalancerIP: 133.186.215.195
#####  type: LoadBalancer
```

참고 : <https://kubernetes.io/ko/docs/tasks/manage-kubernetes-objects/declarative-config/>

#### 4. 명령어를 이용하여 간단하게 등록 해 보자.

> nginx 서비스를 LoadBalancer 의 공인IP 설

```
# test namespace create
$ kubectl create namespace test
namespace/test created

# test namespace nginx deployment create
$ kubectl create deployment nginx --image nginx --namespace test
deployment.apps/nginx created

# nginx deployment 외부에서 접속 가능한 네트워크 생성 (LoadBalancer Service:80, IP:133.186.153.62)
$ kubectl expose deployment nginx --port 80 --target-port 80 --type LoadBalancer --namespace test --load-balancer-ip 133.186.153.62
service/nginx exposed

# nginx LoadBalancer service 확인 
# 웹 브라우저에서 해당 EXTERNAL -IP 접속     
ubuntu@kube-manager:~$ kubectl get service --namespace test
NAME    TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)        AGE
nginx   LoadBalancer   10.254.249.48   133.186.153.62   80:30905/TCP   6m28s
```

nginx (<https://hub.docker.com/_/nginx>) + tomcat (<https://hub.docker.com/_/tomcat>) + mariadb (<https://hub.docker.com/_/mariadb>) or cubrid (<https://hub.docker.com/r/cubrid/cubrid>)

#### nginx

```
web:
  image: nginx
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
  command: [nginx-debug, '-g', 'daemon off;']
```

#### nginx docker&#x20;

```
$ docker run --name nginx -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -v /some/content:/usr/share/nginx/html:ro -d -p 8080:80 -p 443:443 nginx
===================================================
$ docker run --name tmp-nginx-container -d nginx
$ docker cp tmp-nginx-container:/etc/nginx/nginx.conf /host/path/nginx.conf
$ docker rm -f tmp-nginx-container
====================================================
```

#### nginx docker-compose.yml

```
web:
  image: nginx
  volumes:
   - ./templates:/etc/nginx/templates
  ports:
   - "8080:80"
  environment:
   - NGINX_HOST=foobar.com
   - NGINX_PORT=80
```

#### Tomcat

```
$ docker run -it --rm tomcat:9.0
$ docker run -it --rm -p 8888:8080 tomcat:9.0
```

#### tomcat docker-compose.yml

```
  tomcat:
    image: tomcat:10.0.5-jdk8-openjdk
    container_name: tomcat
    restart: always
    # volumes:
    #   - "./tomcat_src_conf/conf/catalina.properties:/usr/local/tomcat/conf/catalina.properties"
    #   - "./tomcat_src_conf/conf/logging.properties:/usr/local/tomcat/conf/logging.properties"
    #   - "./tomcat_src_conf/conf/server.xml:/usr/local/tomcat/conf/server.xml"
    #   - "./tomcat_src_conf/conf/web.xml:/usr/local/tomcat/conf/web.xml"
    #   - "./tomcat_src_conf/webapps:/usr/local/tomcat/webapps"
    links:
      - mariadb
    ports:
      - 8080:8080
```

#### mariadb

```
$ docker run -p 127.0.0.1:3306:3306  --name some-mariadb -e MARIADB_ROOT_PASSWORD=my-secret-pw -d mariadb:tag

$ docker network create some-network # Create the network
$ docker run --net some-network --name some-mariadb -e MARIADB_ROOT_PASSWORD=my-secret-pw -d mariadb:tag

$ docker run --name some-mariadb -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:tag --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

```

#### mariadb docker-compose.yml

```
# Use root/example as user/password credentials (https://hub.docker.com/_/mariadb)
version: '3.1'

services:

  mariadb:
    image: mariadb:10.4.18
    container_name: mariadb
    restart: always
#    command: mysqld --innodb-buffer-pool-size=20M
#    volumes:
#      - "./mariadb:/var/lib/mysql:rw"
#      - "./conf:/etc/mysql"
    environment:
      - "MYSQL_DATABASE=wp"
      - "MYSQL_USER=wp"
      - "MYSQL_PASSWORD=wp123"
      - "MYSQL_ROOT_PASSWORD=wordpress123"
#      - "WSREP_CLUSTER_ADDRESS=gcomm://192.168.11.253,192.168.11.7,192.168.11.26"
#      - "WSREP_PROVIDER_OPTIONS=ist.recv_addr=192.168.11.253"
#      - "WSREP_NODE_NAME=db1"
#      - "WSREP_NODE_ADDRESS=192.168.11.253"
#      - "WSREP_SST_AUTH"
#      - "WSREP_SST_METHOD=xtrabackup-v2"
    ports:
      - "3306:3306"
      - "4567:4567"
      - "4568:4568"
      - "4444:4444"
#    mem_limit: 3g
#    cpuset: 0,1
```

#### cubrid

{% code title="Start Containers for Broker and DB Server" %}

```
#Start a Server instance as follows:
docker run -d -e 'CUBRID_COMPONENTS=SERVER' --name server-container-name cubrid:tag

#And Start a Broker instance as follows:
docker run -d -e 'CUBRID_COMPONENTS=BROKER' -e 'CUBRID_DB_HOST=cubrid_server' -e 'CUBRID_DB=dbname' --name broker-container-name --link cubrid_server:server-container-name cubrid:tag
```

{% endcode %}

```
#Create a isolated network for HA
docker network create --driver bridge cubrid_ha_net

#Start a Master instance (with Broker) as follows:
docker run -d --net=cubrid_ha_net -e 'CUBRID_COMPONENTS=HA' -e 'CUBRID_DB_HOST=master:slave' -e 'CUBRID_DATABASE=db' --hostname master --name master cubridkr/cubrid:10.2.0.8797

#Start a Slave instance (with Broker) as follows:
docker run -d --net=cubrid_ha_net -e 'CUBRID_COMPONENTS=HA' -e 'CUBRID_DB_HOST=master:slave' -e 'CUBRID_DATABASE=db' --hostname slave --name slave cubridkr/cubrid:10.2.0.8797

#The following command runs a cubrid command inside an existing master container instance:
docker exec -it master
su cubrid 
cubrid hb status
```

{% code title="CUBRID HA 시작 및 확인" %}

```
# CUBRID HA 시작(마스터 노드)
[master]$ cubrid heartbeat start

# CUBRID HA 시작(슬레이브 노드)
[slave]$ cubrid heartbeat start

# CUBRID HA 상태 확인(각 노드)
[master]$ cubrid heartbeat status
[slave]$ cubrid heartbeat status

# CUBRID HA 상태 확인(각 노드)

[master]$ cubrid changemode db@localhost
The server 'db@localhost''s current HA running mode is active.
[slave]$ cubrid changemode db@localhost
The server 'db@localhost''s current HA running mode is standby.
```

{% endcode %}

{% code title="CUBRID HA 동작 여부 확인" %}

```
# 마스터 노트
[master]$ csql -u dba db@localhost -c "create table abc(a int, b int, c int, primary key(a));"
[master]$ csql -u dba db@localhost -c "insert into abc values (1,1,1);"

# 슬래이브 노
[slave]$ csql -u dba db@localhost -l -c "select * from abc;"
=== <Result of SELECT Command in Line 1> ===
<00001> a: 1
        b: 1
        c: 1
```

{% endcode %}

{% code title="브로커 설정, 시작 및 확인" %}

```
[master]$ cubrid broker start
@ cubrid broker start
++ cubrid broker start: success

[master]$ cubrid broker status
@ cubrid broker status
% testdb_RWbroker
---------------------------------------------------------
ID   PID   QPS   LQS PSIZE STATUS
---------------------------------------------------------
 1  9532     0     0  48120  IDLE
```

{% endcode %}

3tier 구성하기

httpd + tomcat + mysql 설정

#### httpd 설

apt update && apt install httpd && systemctl start httpd.service

web root : /var/www/html        &#x20;

httpd log Directory : /var/log/httpd

\--- httpd.conf 설정

```
Includ conf.modules.d/*.conf
LoadModule Proxy_module modules/mod_proxy.so
LoadModule Proxy_connect_module modules/mod_proxy_connect.so
LoadModule Proxy_http_moduel modules/mod_proxy_http.so

.....

<VirtualHost *:80>
    ProxyRequests On
    ProxyPreserveHost On
    
    <Proxy *>
        Order deny,allow
        Allow from all
        SerEnv force-proxy-request-1.0.1
        SetEne proxy-nokeepalive 1
        SetEnv Proxy-initial-not-pooled 1
    </Proxy>
    
    ProxyPass "/servlet/" "http://이동할서버IP:Port/" ttl=60
    ProxyPassMatch "^/.*\.(jsp|do)$" "http://이동할서버IP:Port/"
    
    Timeout 120
</VirtualHost>
```

httpd log : tail -f access\_log

/var/www/html/default.html

\----- web1 server

```
<html>
<head>
<title> test httpd 01 server </title>
<body> httpd start (web1) </body>
</html>
```

\---- web2 server&#x20;

```
<html>
<head>
<title> test httpd 02 server </title>
<body> httpd start (web2) </body>
</html>
```

\--- db 연결 페이지 (web1/2 포함)

```
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%
<%@ page import="java.sql.*"%>
<h2> jdbc driver test 1 </h2>

<%
    Connection conn=null;
    try{
        String jdbUrl="jdbc:mysql://testdb-dns-name/database-name>";
        String dbId="user-name";
        String dbPass="user-password";
        
        Class.forName("com.mysql.jdbc.Driver");
        conn=DriverManager.getConnection(jdbcUrl,dbId,dbPass);
        out.println("was01-db connect sussess");
    }catch(Exception e){
        e.printStackTrace();
    }
%>
```

apache 재시작&#x20;

systemctl restart httpd.service

#### tomcat 설

apt update && apt install openjdk && apt install tomcat

service tomcat start

tomcat log Directory : /usr/local/tomcat/logs

web root : /usr/local/tomcat/webapps/ROOT/default.jsp

\--- tomcat1 server

```
<%@ page contentType="text/html; chareset=UTF-8"%>
<html>
<head>
<title> Test Tomcat 01 </title>
<body>
    tomcat test(was1)
    now_time : <%= new java.util.Date()%>
</body>
</html>
```

\--- tomcat2 server

```
<%@ page contentType="text/html; chareset=UTF-8"%>
<html>
<head>
<title> Test Tomcat 02 </title>
<body>
    tomcat test(was2)
    now_time : <%= new java.util.Date()%>
</body>
</html>
```

service tomcat restart

#### mysql

apt update && apt install mysql


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.skill.or.kr/test-page.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
