728x90

출처

Docker 설치

pi@NanoPi-M4v2:~$ wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/arm64/containerd.io_1.2.6-3_arm64.deb
pi@NanoPi-M4v2:~$ wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/arm64/docker-ce-cli_19.03.2~3-0~ubuntu-bionic_arm64.deb
pi@NanoPi-M4v2:~$ wget https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/arm64/docker-ce_19.03.2~3-0~ubuntu-bionic_arm64.deb
pi@NanoPi-M4v2:~$ sudo dpkg -i containerd.io_1.2.6-3_arm64.deb
Selecting previously unselected package containerd.io.
(Reading database ... 155441 files and directories currently installed.)
Preparing to unpack containerd.io_1.2.6-3_arm64.deb ...
Unpacking containerd.io (1.2.6-3) ...
Setting up containerd.io (1.2.6-3) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
pi@NanoPi-M4v2:~$ sudo dpkg -i docker-ce-cli_19.03.2~3-0~ubuntu-bionic_arm64.deb
pi@NanoPi-M4v2:~$ sudo dpkg -i docker-ce_19.03.2~3-0~ubuntu-bionic_arm64.deb
Selecting previously unselected package docker-ce.
(Reading database ... 155656 files and directories currently installed.)
Preparing to unpack docker-ce_19.03.2~3-0~ubuntu-bionic_arm64.deb ...
Unpacking docker-ce (5:19.03.2~3-0~ubuntu-bionic) ...
Setting up docker-ce (5:19.03.2~3-0~ubuntu-bionic) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for systemd (237-3ubuntu10.52) ...

Test Docker installation

pi@NanoPi-M4v2:~$ git clone https://github.com/friendlyarm/debian-jessie-arm-docker
pi@NanoPi-M4v2:~/debian-jessie-arm-docker$ sudo ./rebuild-image.sh

Sending build context to Docker daemon  3.072kB
Step 1/6 : FROM armhf/debian
Step 2/6 : COPY ./sources.list /etc/apt/sources.list
Step 3/6 : RUN apt-get update
Step 4/6 : RUN echo "root:fa" | chpasswd
Step 5/6 : USER root
Step 6/6 : RUN echo "all done."
pi@NanoPi-M4v2:~/debian-jessie-arm-docker$ sudo ./run.sh
root@6bd5e8aec566:/# ls
bin  boot  dev  etc  home  lib  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@6bd5e8aec566:/usr# exit
exit
pi@NanoPi-M4v2:~/debian-jessie-arm-docker$ 
728x90
728x90

node.js (https://nodejs.org/ko/download/)

압축파일 node-v14.17.3-win-x64.zip 다운 받아서 C:\usr\local\node-v14.17.3-win-x64 폴더에 압축 풀기

경로 추가 : C:\usr\local\node-v14.17.3-win-x64

npm 버전 확인

C:\Users\bluesanta>npm -v
6.14.13

yarn 설치

C:\Users\bluesanta>npm install -g yarn

> yarn@1.22.10 preinstall C:\usr\local\node-v14.17.3-win-x64\node_modules\yarn
> :; (node ./preinstall.js > /dev/null 2>&1 || true)

C:\usr\local\node-v14.17.3-win-x64\yarn -> C:\usr\local\node-v14.17.3-win-x64\node_modules\yarn\bin\yarn.js
C:\usr\local\node-v14.17.3-win-x64\yarnpkg -> C:\usr\local\node-v14.17.3-win-x64\node_modules\yarn\bin\yarn.js
+ yarn@1.22.10
added 1 package in 0.603s

pm2 설치

C:\Users\bluesanta>npm install -g pm2
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
C:\usr\local\node-v14.17.3-win-x64\pm2-dev -> C:\usr\local\node-v14.17.3-win-x64\node_modules\pm2\bin\pm2-dev
C:\usr\local\node-v14.17.3-win-x64\pm2-docker -> C:\usr\local\node-v14.17.3-win-x64\node_modules\pm2\bin\pm2-docker
C:\usr\local\node-v14.17.3-win-x64\pm2 -> C:\usr\local\node-v14.17.3-win-x64\node_modules\pm2\bin\pm2
C:\usr\local\node-v14.17.3-win-x64\pm2-runtime -> C:\usr\local\node-v14.17.3-win-x64\node_modules\pm2\bin\pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\pm2\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ pm2@5.1.0
added 180 packages from 203 contributors in 13.736s

pdf-markup 설치

C:\usr\local\pdf-markup\app>yarn install
yarn install v1.22.10
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 31.97s.

서버 구동

일반적인 구동

C:\usr\local\pdf-markup\app>yarn start
yarn run v1.22.10
$ node .
Example app listening at http://localhost:8080

디버깅 구동 (--inspect)

C:\usr\local\pdf-markup\app>yarn debug
yarn run v1.22.10
$ node --inspect .
Debugger listening on ws://127.0.0.1:9229/ea7a5c4e-bc3e-49f7-af03-8eef874d4281
For help, see: https://nodejs.org/en/docs/inspector
Example app listening at http://localhost:8080

pm2 를 이용한 무중단 서비스 구동

C:\usr\local\pdf-markup\app>pm2 start .

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

__/\\\\\\\\\\\\\____/\\\\____________/\\\\____/\\\\\\\\\_____
 _\/\\\/////////\\\_\/\\\\\\________/\\\\\\__/\\\///////\\\___
  _\/\\\_______\/\\\_\/\\\//\\\____/\\\//\\\_\///______\//\\\__
   _\/\\\\\\\\\\\\\/__\/\\\\///\\\/\\\/_\/\\\___________/\\\/___
    _\/\\\/////////____\/\\\__\///\\\/___\/\\\________/\\\//_____
     _\/\\\_____________\/\\\____\///_____\/\\\_____/\\\//________
      _\/\\\_____________\/\\\_____________\/\\\___/\\\/___________
       _\/\\\_____________\/\\\_____________\/\\\__/\\\\\\\\\\\\\\\_
        _\///______________\///______________\///__\///////////////__


                          Runtime Edition

        PM2 is a Production Process Manager for Node.js applications
                     with a built-in Load Balancer.

                Start and Daemonize any application:
                $ pm2 start app.js

                Load Balance 4 instances of api.js:
                $ pm2 start api.js -i 4

                Monitor in production:
                $ pm2 monitor

                Make pm2 auto-boot at server restart:
                $ pm2 startup

                To go further checkout:
                http://pm2.io/


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

[PM2] Spawning PM2 daemon with pm2_home=C:\Users\bluesanta\.pm2
[PM2] PM2 Successfully daemonized
[PM2] Starting C:\usr\local\cmx_home\pdf-markup\app in fork_mode (1 instance)
[PM2] Done.
┌─────┬──────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
│ id  │ name │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
├─────┼──────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
│ 0   │ .    │ default     │ 1.0.0   │ fork    │ 12320    │ 0s     │ 0    │ online    │ 0%       │ 50.2mb   │ blu… │ disabled │
└─────┴──────┴─────────────┴─────────┴─────────┴──────────┴────────┴──────┴───────────┴──────────┴──────────┴──────────┴──────────┘

C:\usr\local\cmx_home\pdf-markup\app>pm2 start .
728x90
728x90

본 체험 제품은 아이씨뱅큐㈜ 에서 진행하는 무상 체험단 활동으로 작성한 것입니다.

Raspbot (라즈봇)의 간단한 개봉기와 조립 과정을 정리해보았습니다.

조립과정은 유튜브를 보면서 조립 할 수 있어서 조립이 어렵지는 않았지만,
모터 고정 프레임 조립시 프레임의 방향을 잘 못 조립해서 몇 번을 분해, 조립했습니다.

부품별로 작은 봉투에 번호가 표시 되어 있어 조립시 필요한 부품을 찾기는 쉬웠습니다.

배송받은 박스

박스개봉

본체 보드와 각각의 부품이 작은 봉투로 나누어져 있고, 조립에 필요한 드라이버가 포함되어 있어 별도의 드라이버가 필요하지 않습니다. 한가지 아쉬운 것은 전원이 110v인데 돼지코는 별도로 구입해셔야 합니다.

모터 고정 프레임 조립

오른쪽 상단에 잘 못 조립한 예입니다.
저와 같은 실수하지 마세요.

카메라 브라켓 조립

카메라 케이블이 짧아서 동본된 케이블를 사용하셔야 합니다.

팬 틸트 브라켓 조립

팬 틸트 브라켓 지지대 조립

라인트레이서 지지대 조립

팬 틸트 브라켓 지지대에 조립

라인트레이서 지지대에 조립

찍찍이 테이프로 베터리 고정

라즈베리파이 지지대 조립

GPIO 케이블 RC카 본체에 조립

라즈베리파이 지지대에 고정, GPIO 케이블 라즈베리파이에 연결

라즈베리파이까지 조립하면 조립은 완성입니다.

다음 강좌에는 App를 이용해서 Raspbot (라즈봇)를 연결해보겠습니다.

 

마이크로비트 마퀸 공식 구입처 : 아이씨뱅큐 https://www.icbanq.com/

 

전자부품쇼핑몰 아이씨뱅큐 - 전자부품, 오픈소스 하드웨어의 모든 것

국내 최대 전자부품 쇼핑몰. 아두이노/마이크로비트/라즈베리파이 등 오픈 H/W , LCD,리튬배터리, 반도체 부품, 코딩교육키트 등 판매 및 PCB/SMT/아트웍 임가공 서비스 제공. 다양한 마케팅 채널(블

www.icbanq.com

아이씨뱅큐 공식 카페 : https://cafe.naver.com/icbanq

 

No.1 전자엔지니어 전문몰 아이씨뱅큐 : 네이버 카페

체험단, 무상체험단, DIY 체험, 경품, 리뷰, 파워블로거,이벤트, 전자제품체험단, 후기 공모, 로봇체험

cafe.naver.com

아이씨뱅큐 공식 블로그 : https://blog.naver.com/icbanq

 

No.1 전자엔지니어 전문몰 아이씨뱅큐 : 네이버 블로그

♡전자 엔지니어와 메이커 DIY 매니아를 위한 다양한 정보 상시 업데이트!♡ - 마이크로비트/아두이노/라즈베리파이/라떼판다/젯슨나노 등 다양한 오픈소스 하드웨어 정보 가득! - 유튜브 '나도

blog.naver.com

마이크로비트 공식 카페 : https://cafe.naver.com/bbcmicro

 

코딩교육을 위한 BBC 마이크로비트... : 네이버 카페

코딩교육을위한 BBC microbit(micro:bit) 한국 총판인 element14 공식 후원 사용자모임 카페입니다.

cafe.naver.com

나도메이커 유튜브 채널 : https://www.youtube.com/user/ICbanQ

 

나도메이커

안녕하세요! 나도메이커입니다! 저희 채널은 전자엔지니어와 Maker, DIY 매니아들을 위한 다양한 정보를 제공합니다! 또한 반도체 전자부품, 로봇, 오픈소스하드웨어, 아두이노, 라즈베리파이, AVR,

www.youtube.com

 

728x90
728x90

출처

CPU

Amlogic S905X3 quad core Cortex-A55 (2.0xxGHz)

eMMC

pi@bananapi:~$ lsblk
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0          7:0    0 48.8M  1 loop /snap/core18/1936
loop1          7:8    0   27M  1 loop /snap/snapd/10494
loop2          7:16   0 15.2M  1 loop /snap/ubuntu-mate-welcome/627
loop3          7:24   0   16K  1 loop /snap/software-boutique/56
loop4          7:32   0    8K  1 loop /snap/ubuntu-mate-pi/11
loop5          7:40   0 14.9M  1 loop /snap/ubuntu-mate-welcome/578
loop6          7:48   0 27.9M  1 loop /snap/snapd/11843
loop7          7:56   0 48.9M  1 loop /snap/core18/2068
mmcblk0      179:0    0 14.6G  0 disk 
mmcblk0boot0 179:32   0    4M  0 disk 
mmcblk0boot1 179:64   0    4M  0 disk 
mmcblk0rpmb  179:96   0    4M  0 disk 
mmcblk1      179:128  0 14.9G  0 disk 
├─mmcblk1p1  179:129  0  256M  0 part /boot
└─mmcblk1p2  179:130  0  6.8G  0 part /

SM 확장

디스크 확인

pi@bananapi:~$ sudo fdisk -l | grep '^Disk'
Disk /dev/loop0: 48.85 MiB, 51200000 bytes, 100000 sectors
Disk /dev/loop1: 26.10 MiB, 28286976 bytes, 55248 sectors
Disk /dev/loop2: 15.17 MiB, 15900672 bytes, 31056 sectors
Disk /dev/loop3: 16 KiB, 16384 bytes, 32 sectors
Disk /dev/loop4: 8 KiB, 8192 bytes, 16 sectors
Disk /dev/loop5: 14.87 MiB, 15572992 bytes, 30416 sectors
Disk /dev/loop6: 27.9 MiB, 29237248 bytes, 57104 sectors
Disk /dev/loop7: 48.9 MiB, 51257344 bytes, 100112 sectors
Disk /dev/mmcblk0: 14.57 GiB, 15634268160 bytes, 30535680 sectors
Disk /dev/mmcblk0boot1: 4 MiB, 4194304 bytes, 8192 sectors
Disk /dev/mmcblk0boot0: 4 MiB, 4194304 bytes, 8192 sectors
Disk /dev/mmcblk1: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Disklabel type: dos
Disk identifier: 0x5e283d7d

기존 파티션을 삭제하고 새로 파티션 생성

pi@bananapi:~$ sudo fdisk /dev/mmcblk1
 
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): p
Disk /dev/mmcblk1: 14.86 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5e283d7d
 
Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk1p1      204800   729087   524288  256M  c W95 FAT32 (LBA)
/dev/mmcblk1p2      729088 14940159 14211072  6.8G 83 Linux
 
Command (m for help): d
Partition number (1,2, default 2): 2
 
Partition 2 has been deleted.
 
Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31116287, default 2048): 729088
Last sector, +/-sectors or +/-size{K,M,G,T,P} (729088-31116287, default 31116287): 
 
Created a new partition 2 of type 'Linux' and of size 14.5 GiB.
Partition #2 contains a ext4 signature.
 
Do you want to remove the signature? [Y]es/[N]o: Y
 
The signature will be removed by a write command.
 
Command (m for help): w
The partition table has been altered.
Syncing disks.
 
pi@bananapi:~$ sudo shutdown -r now

bpi-tool 설치

pi@bananapi:~$ sudo apt-get install pv
pi@bananapi:~$ curl -sL https://github.com/BPI-SINOVOIP/bpi-tools/raw/master/bpi-tools | sudo -E bash
 
bpi files:
/usr/bin/bpi-tools      v1.3.1(github)
/usr/bin/bpi-bootsel    v1.3.4(github)
/usr/bin/bpi-copy       v1.3.4(github)
/usr/bin/bpi-get        v1.3.7b(github)
/usr/bin/bpi-migrate    v1.3.11(github)
/usr/bin/bpi-hw v1.3.3(github)
/usr/bin/bpi-update     v1.3.8(github)

eMMC에 OS 설치

pi@bananapi:~$ sudo bpi-copy 2021-01-21-ubuntu-20.04-mate-desktop-bpi-m5-aarch64-sd-emmc.img.zip /dev/mmcblk0
SRC=2021-01-21-ubuntu-20.04-mate-desktop-bpi-m5-aarch64-sd-emmc.img.zip
DST=/dev/mmcblk0
COPYMODE=imagetodisk
imagetodisk
bpi-copy(v1.3.4(github)), bananapi image & disk tools
 
Usage: bpi-copy [OPTIONS]...
       bpi-copy [ --help | -v | --version ]
       bpi-copy IMGFILE
       bpi-copy IMGDIR
       bpi-copy IMGFILE DEVICE
       bpi-copy DEVICE IMGFILE
 
Warning: Try to write 2021-01-21-ubuntu-20.04-mate-desktop-bpi-m5-aarch64-sd-emmc.img.zip to BOOTDISK /dev/mmcblk0
==============================================================
Sat 12 Jun 2021 06:01:17 PM IST
*** start COPY (blue led on ) .....
INFO: /dev/mmcblk0 : SD/eMMC !!
umount device: /dev/mmcblk0
==============================================================
IMGFILE=2021-01-21-ubuntu-20.04-mate-desktop-bpi-m5-aarch64-sd-emmc.img.zip
==============================================================
zip
7.12GiB 0:02:12 [55.0MiB/s] [                                                          <=>                              ]
0+113169 records in
0+113169 records out
***  end  COPY (blue led off) .....
Sat 12 Jun 2021 06:03:35 PM IST
==============================================================
RUNTIME 2:18
OK!! You can remove the BOOTDISK /dev/mmcblk0 now!!

WiringPi

pi@bananapi:~$ git clone https://github.com/BPI-SINOVOIP/amlogic-wiringPi
pi@bananapi:~$ cd amlogic-wiringPi
pi@bananapi:~/amlogic-wiringPi$ chmod a+x build
pi@bananapi:~/amlogic-wiringPi$ sudo ./build

WiringPi 핀 배열

pi@bananapi:~/amlogic-wiringPi$ gpio readall
 +-----+-----+---------+------+---+--- M5 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 493 |   8 |   SDA.2 | ALT1 | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 494 |   9 |   SCL.2 | ALT1 | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 481 |   7 |  IO.481 |   IN | 1 |  7 || 8  | 1 | ALT1 | TxD1    | 15  | 488 |
 |     |     |      0V |      |   |  9 || 10 | 1 | ALT1 | RxD1    | 16  | 489 |
 | 479 |   0 |  IO.479 |   IN | 1 | 11 || 12 | 1 | IN   | IO.504  | 1   | 504 |
 | 480 |   2 |  IO.480 |   IN | 1 | 13 || 14 |   |      | 0V      |     |     |
 | 483 |   3 |  IO.483 |   IN | 1 | 15 || 16 | 1 | IN   | IO.476  | 4   | 476 |
 |     |     |    3.3V |      |   | 17 || 18 | 1 | IN   | IO.477  | 5   | 477 |
 | 484 |  12 |    MOSI | ALT4 | 1 | 19 || 20 |   |      | 0V      |     |     |
 | 485 |  13 |    MISO | ALT4 | 1 | 21 || 22 | 1 | IN   | IO.478  | 6   | 478 |
 | 487 |  14 |    SLCK | ALT4 | 1 | 23 || 24 | 1 | OUT  | SS      | 10  | 486 |
 |     |     |      0V |      |   | 25 || 26 | 1 | IN   | IO.492  | 11  | 492 |
 | 474 |  30 |   SDA.3 |   IN | 1 | 27 || 28 | 1 | IN   | SCL.3   | 31  | 475 |
 | 490 |  21 |  IO.490 |   IN | 1 | 29 || 30 |   |      | 0V      |     |     |
 | 491 |  22 |  IO.491 |   IN | 1 | 31 || 32 | 0 | IN   | IO.495  | 26  | 495 |
 | 482 |  23 |  IO.482 |   IN | 0 | 33 || 34 |   |      | 0V      |     |     |
 | 503 |  24 |  IO.503 |   IN | 1 | 35 || 36 | 0 | IN   | IO.432  | 27  | 432 |
 | 505 |  25 |  IO.505 |   IN | 0 | 37 || 38 | 1 | ALT4 | IO.506  | 28  | 506 |
 |     |     |      0V |      |   | 39 || 40 | 0 | IN   | IO.500  | 29  | 500 |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- M5 ---+---+------+---------+-----+-----+
728x90
728x90

평소에 라즈베리파이를 가지고 여러가지 시도 해보았는데,
아이씨뱅규에서 라즈베리파이를 이용한 무상체험단 모집을 하고 있어서 소개합니다.

최근에 OpenCV를 배우면서 무엇을 해볼까 고민중이었는데, 라즈베리파이, 파이카메라, RC카가 하나로 만들어진 제품을 찾고 있었는데, 초음파 센서에 라인트레이서 모듈까지 RC로 구현하고 싶은 모든게 다 있는것 같습니다.

OpenCV를 이용한 라이트레이싱이나 손가락 인식을 이용한 RC카 제어를 해봐야겠습니다.

[체험단 56기] AI RC카 라즈봇(RASPBOT) 무상체험단 10명 모집 YAHBOOM

https://www.youtube.com/watch?v=MX2p7SqF3iY

★무상체험단★신제품! 라즈베리파이 AI RC카 '라즈봇(Raspbot)' 소개!
728x90
728x90

출처

pom.xml

		<dependency>
			<groupId>org.springframework.amqp</groupId>
			<artifactId>spring-amqp</artifactId>
			<version>2.1.12.RELEASE</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.amqp</groupId>
			<artifactId>spring-rabbit</artifactId>
			<version>2.1.12.RELEASE</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-core</artifactId>
			<version>2.12.3</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-databind</artifactId>
			<version>2.12.3</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
		<dependency>
			<groupId>com.fasterxml.jackson.core</groupId>
			<artifactId>jackson-annotations</artifactId>
			<version>2.12.3</version>
		</dependency>

		<!-- RabbitMQ Client -->
		<dependency>
			<groupId>com.rabbitmq</groupId>
			<artifactId>amqp-client</artifactId>
			<version>5.8.0</version>
		</dependency>

Spring AMQP 큐 메시지 송신

bluexmas-mq-rabbitmq.xml

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:rabbit="http://www.springframework.org/schema/rabbit"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="http://www.springframework.org/schema/rabbit    https://www.springframework.org/schema/rabbit/spring-rabbit.xsd
	                    http://www.springframework.org/schema/beans     https://www.springframework.org/schema/beans/spring-beans.xsd
	                    http://www.springframework.org/schema/context   http://www.springframework.org/schema/context/spring-context-2.5.xsd">

	<!-- RabbitMQ 연결 설정 -->
	<rabbit:connection-factory id="rabbitConnectionFactory" 
		virtual-host="/" 
		host="lastxmas.iptime.org" 
		port="5672"
		channel-cache-size="10" 
		username="admin" 
		password="passwd"/>
		
	<rabbit:admin connection-factory="rabbitConnectionFactory"/>
	
	<!-- Queue 등록 -->
	<rabbit:queue auto-declare="true" name="myQueue" />
	
	<rabbit:direct-exchange name="amq.direct">
		<rabbit:bindings>
			<rabbit:binding key="foo.bar" queue="myQueue"/>
		</rabbit:bindings>
	</rabbit:direct-exchange>
	
	<!-- 생산자와 소비자 모두에게 필요한 메시지 변환 -->
	<bean id="amqpMessageConverter" class="org.springframework.amqp.support.converter.Jackson2JsonMessageConverter"/>

	<!-- 메시지 리스너 설정 -->
	<rabbit:listener-container connection-factory="rabbitConnectionFactory" message-converter="amqpMessageConverter">
		<!-- 큐 myQueue 메시지는 bean id consumer의 method handleMessage가 처리한다 -->
		<rabbit:listener queues="myQueue" ref="MQConsumer" method="handleMessage"/>
	</rabbit:listener-container>
	
	<bean id="MQConsumer" class="com.bluexmas.mq.MQConsumer"/>
	
</beans>

메시지 수신 클래스 ( MQConsumer.java )

package com.bluexmas.mq;

import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.amqp.core.Message;
import org.springframework.stereotype.Component;

import com.bluexmas.dao.domain.CustomMessage;
import com.bluexmas.dao.domain.MPSMessage;

@Component
public class MQConsumer {
	
	//메시지를 처리한다.
	public void handleMessage(Message message) {
		//do Something
		System.out.println(message);		
	}
	
	//메시지를 처리한다.
	public void handleMessage(CustomMessage message) {
		//do Something
		System.out.println("--1> " +  message);
	}
	
}

Spring AMQP 큐 수동으로 전달

메시지 큐 전달 객체 ( CustomMessage.java )

package com.bluexmas.dao.domain;

public class CustomMessage {
	
	private String text;

	private int priority;

	private boolean secret;

	protected CustomMessage() {
	}

	public CustomMessage(String text, int priority, boolean secret) {
		this.text = text;
		this.priority = priority;
		this.secret = secret;
	}

	public String getText() {
		return text;
	}

	public int getPriority() {
		return priority;
	}

	public boolean isSecret() {
		return secret;
	}

	@Override
	public String toString() {
		return "CustomMessage{" + "text='" + text + '\'' + ", priority=" + priority + ", secret=" + secret + '}';
	}

}

메시지 전달 객체 ( ProducerJSon2.java )

package com.bluexmas.test;

import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;

import com.bluexmas.dao.domain.CustomMessage;
import com.fasterxml.jackson.core.JsonProcessingException;

public class ProducerJSon2 {
	public static void main(final String[] args) throws JsonProcessingException {
		// RabbitMQ 연결
		CachingConnectionFactory cf = new CachingConnectionFactory("lastxmas.iptime.org", 5672);
		cf.setUsername("admin");
		cf.setPassword("passwd");

		// 메시지 보내기
		RabbitTemplate template = new RabbitTemplate(cf);
		template.setExchange("amq.direct");
		template.setQueue("myQueue");
		template.setMessageConverter(new Jackson2JsonMessageConverter());
		
		CustomMessage customMessage = new CustomMessage("Hello Message!", 1, true);
		template.convertAndSend("foo.bar", customMessage);
		cf.destroy();
	}
}

로그

00:29:34.276 [pool-1-thread-4] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Storing delivery for consumerTag: 'amq.ctag-5t1nRdDJwg8A-H8jTH6DqQ' with deliveryTag: '1' in Consumer@1e292e89: tags=[[amq.ctag-5t1nRdDJwg8A-H8jTH6DqQ]], channel=Cached Rabbit Channel: AMQChannel(amqp://admin@1.229.109.140:5672/,1), conn: Proxy@eefafec Shared Rabbit Connection: SimpleConnection@3680d2bb [delegate=amqp://admin@1.229.109.140:5672/, localPort= 4263], acknowledgeMode=AUTO local queue size=0

00:29:34.293 [org.springframework.amqp.rabbit.config.ListenerContainerFactoryBean#0-1] DEBUG org.springframework.amqp.rabbit.listener.BlockingQueueConsumer - Received message: (Body:'{"text":"Hello Message!","priority":1,"secret":true}' MessageProperties [headers={__TypeId__=com.bluexmas.dao.domain.CustomMessage}, contentType=application/json, contentEncoding=UTF-8, contentLength=0, receivedDeliveryMode=PERSISTENT, priority=0, redelivered=false, receivedExchange=amq.direct, receivedRoutingKey=foo.bar, deliveryTag=1, consumerTag=amq.ctag-5t1nRdDJwg8A-H8jTH6DqQ, consumerQueue=myQueue])

--1> CustomMessage{text='Hello Message!', priority=1, secret=true}
728x90
728x90

출처

사용자추가

Admin 탭으로 이동

사용자 정보를 입력하고 [Add user] 버튼 선택

가상호스트 추가

가상호스트를 추가할 사용자 선택

[Virtual Host] 선택하고 [Set permission] 버튼 선택

확인

728x90
728x90

출처

리눅스 정보 조회

출처 : 리눅스 종류 확인, 리눅스 버전 확인 - 제타위키

$ cat /etc/*-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
Amazon Linux release 2 (Karoo)

관련패키지 설치

$ sudo yum update
$ sudo yum install gcc gcc-c++ openssl curl autoconf ncurses-devel bison zlib curl libtermcap-devel bzip2-devel

MySQL 계정 만들기

$ sudo groupadd mysql 
$ sudo useradd -g mysql -s /bin/bash -m mysql

cmake 설치

$ sudo yum install cmake

MySQL 소스 다운로드, 압축해제, 컴파일, 설치

$ wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.23.tar.gz 
$ tar xvf mysql-boost-5.7.23.tar.gz 
$ cd mysql-5.7.23 
$ cmake \ 
  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 \ 
  -DMYSQL_DATADIR=/usr/local/mysql57/data \ 
  -DMYSQL_UNIX_ADDR=/usr/local/mysql57/mysql.sock \ 
  -DSYSCONFDIR=/usr/local/mysql57 \ 
  -DMYSQL_TCP_PORT=5723 \ 
  -DMYSQL_USER=mysql \ 
  -DDEFAULT_CHARSET=utf8 \ 
  -DDEFAULT_COLLATION=utf8_general_ci \ 
  -DWITH_EXTRA_CHARSETS=all \ 
  -DENABLED_LOCAL_INFILE=1 \ 
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \ 
  -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ 
  -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ 
  -DDOWNLOAD_BOOST=0 \
  -DWITH_BOOST=./boost 
$ make 
$ sudo make install

환경설정

$ sudo vi /usr/local/mysql57/my.cnf

[mysqld]
# port=3306
# basedir=/usr/local/mysql57
# datadir=/usr/local/mysql57/data
# pid-file=/usr/local/mysql57/mysqld.pid
# log_error=/usr/local/mysql57/mysql_error.log
# lc-messages-dir=/usr/local/mysql57/share

init_connect=SET collation_connection = utf8_general_ci
init_connect=SET NAMES utf8
character-set-server=utf8
collation-server=utf8_general_ci
# table_cache=1024
max_connections=2048
max_user_connections=500
max_connect_errors=10000
wait_timeout=300
query_cache_type = 1
query_cache_size = 128M
query_cache_limit = 5M
slow_query_log
long_query_time=3
max_allowed_packet=16M
sort_buffer_size = 2M
# skip-innodb
skip-name-resolve
sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

MySQL 설치 디렉토리 mysql 계정으로 권한 수정

$ sudo chown -R mysql:mysql /usr/local/mysql57

MySQL 데이터베이스 초기화 (mysql 계정으로 실행)

$ cd /usr/local/mysql57
$ bin/mysql_install_db --no-defaults --user=mysql --datadir=/usr/local/mysql57/data --basedir=/usr/local/mysql57 -v
2021-05-08 08:15:24 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2021-05-08 08:15:24 [NOTE]    Creating data directory /usr/local/mysql57/data
2021-05-08 08:15:24 [NOTE]    Generating random password to /root/.mysql_secret...done.
2021-05-08 08:15:24 [NOTE]    Setting file ownership to mysql
2021-05-08 08:15:24 [NOTE]    Executing /usr/local/mysql57/bin/mysqld --no-defaults --bootstrap --datadir=/usr/local/mysql57/data --lc-messages-dir=/usr/local/mysql57/share --lc-messages=en_US --basedir=/usr/local/mysql57
2021-05-08 08:15:24 [NOTE]    Creating system tables...done.
2021-05-08 08:15:24 [NOTE]    Filling system tables with data...done.
2021-05-08 08:15:25 [NOTE]    Filling help table with data...done.
2021-05-08 08:15:25 [NOTE]    Creating user for internal session service...done.
2021-05-08 08:15:25 [NOTE]    Creating default user root@localhost
2021-05-08 08:15:25 [NOTE]    Creating default proxy root@localhost
2021-05-08 08:15:25 [NOTE]    Creating sys schema
2021-05-08 08:15:25 [NOTE]    done.
2021-05-08 08:15:26 [WARNING] The bootstrap log isn't empty:
2021-05-08 08:15:26 [WARNING] 2021-05-08T08:15:24.294574Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead
2021-05-08T08:15:24.299965Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2021-05-08T08:15:24.299974Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
 
2021-05-08 08:15:26 [NOTE]    Generating SSL Certificates

MySQL 서비스 등록

서비스 mysqld 파일 복사

$ sudo cp /usr/local/mysql57/support-files/mysql.server /etc/init.d/mysqld57

mysqld 수정

$ sudo vi /etc/init.d/mysqld57

mysqld파일을 열어서 basedir에 mysql이 설치된 디렉토리와 데이터 디렉토리(datadir)를 설정한다.

basedir=/usr/local/mysql57
datadir=/usr/local/mysql57/data

mysqld 서비스 등록

$ sudo chkconfig --add mysqld57
$ sudo chmod +x /etc/init.d/mysqld57
$ chkconfig --list
 
Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.
 
mysqld57        0:off   1:off   2:on    3:on    4:on    5:on    6:off
netconsole      0:off   1:off   2:off   3:off   4:off   5:off   6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
tomcat          0:off   1:off   2:off   3:on    4:on    5:on    6:off
$ sudo chkconfig --level 345 mysqld57 on

mysqld 서비스 실행

$ sudo service mysqld57 start
Starting MySQL. SUCCESS!

root 암호 초기화

mysqld 실행

$ sudo bin/mysqld_safe --skip-grant-tables &
[1] 11505
2021-05-08T08:56:04.765371Z mysqld_safe Logging to '/var/log/mysqld.log'.
2021-05-08T08:56:04.792894Z mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

root 암호 설정

$ bin/mysql -u root -p 
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23-log Source distribution
 
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 
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> 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
mysql> update user set authentication_string = password('manager') where user = 'root';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> quit
Bye

ERROR 1820 (HY000) 오류 해결

mysql> use mysql
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('soY&Be9p/4ed!!!'); 
Query OK, 0 rows affected, 1 warning (0.00 sec)
 
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
mysql> 

사용자 추가

mysql> create user 'user1'@'%' identified by 'userpw';
Query OK, 0 rows affected (0.00 sec)
 
mysql> grant all privileges on *.* to 'user1'@'%' with grant option; 
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

사용자 추가 - 특정 DB에 권한 부여

mysql> create user 'terecal'@'%' identified by '****'; 
Query OK, 0 rows affected (0.00 sec)
 
mysql> grant all privileges ON terecal_db.* TO 'terecal'@'%'; 
Query OK, 0 rows affected (0.00 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
728x90

+ Recent posts