728x90

출처

List Bluetooth Adaptors

pi@raspberrypi:~$ hciconfig
hci0:   Type: Primary  Bus: UART
        BD Address: D8:3A:DD:BA:79:78  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING 
        RX bytes:3771 acl:0 sco:0 events:398 errors:0
        TX bytes:68389 acl:0 sco:0 commands:398 errors:

Scan for Bluetooth devices

pi@raspberrypi:~$ hcitool scan
Scanning ...
        C4:47:4E:BE:57:FC       n/a
        F8:63:3F:0B:D3:3E       LAPTOP-Q2A61D9E

Scan for BLE devices

pi@raspberrypi:~$ sudo hcitool lescan | grep BBL_SHUTTER
20:6E:F1:47:9D:76 BBL_SHUTTER
20:6E:F1:47:9D:76 BBL_SHUTTER

gatttool을 사용하여 장치에 연결

pi@raspberrypi:~$ sudo gatttool -b 20:6E:F1:47:9D:76 -t random --interactive
[20:6E:F1:47:9D:76][LE]>

라즈베리파이 환경 준비

pi@raspberrypi:~$ sudo apt update
pi@raspberrypi:~$ sudo apt install bluetooth bluez python3-bluez python3-dbus

실행 오류

pi@raspberrypi:~$ python3 RPi_BLE_Shutter_Client.py 
Traceback (most recent call last):
  File "/home/pi/RPi_BLE_Shutter_Client.py", line 2, in 
    from bleak import BleakClient, BleakScanner
ModuleNotFoundError: No module named 'bleak'

bleak 설치 오류

pi@raspberrypi:~$ sudo pip3 install bleak
error: externally-managed-environment
 
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    For more information visit http://rptl.io/venv
 
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

pip에 설치 권한 부여

pi@raspberrypi:~$ python -m pip config set global.break-system-packages true
Writing to /home/pi/.config/pip/pip.conf

bleak 설치

pi@raspberrypi:~$ pip3 install bleak
Collecting bleak
  Downloading bleak-1.1.1-py3-none-any.whl.metadata (5.1 kB)
Collecting dbus-fast>=1.83.0 (from bleak)
  Downloading dbus_fast-2.44.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.metadata (10 kB)
Downloading bleak-1.1.1-py3-none-any.whl (136 kB)
Downloading dbus_fast-2.44.5-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (868 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 868.4/868.4 kB 2.7 MB/s eta 0:00:00
Installing collected packages: dbus-fast, bleak
Successfully installed bleak-1.1.1 dbus-fast-2.44.5
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.

RPi_BLE_Shutter_Client.py (최종적으로 실패)

import asyncio
from bleak import BleakClient, BleakScanner
from bleak.backends.device import BLEDevice
from bleak.backends.scanner import AdvertisementData

# BLE HID 서비스 및 특성 UUID
# HID Service: 00001812-0000-1000-8000-00805f9b34fb
HID_SERVICE_UUID = "00001812-0000-1000-8000-00805f9b34fb" 
# Report Characteristic: 00002a4d-0000-1000-8000-00805f9b34fb (일반적인 HID Report UUID)
REPORT_CHAR_UUID = "00002a4d-0000-1000-8000-00805f9b34fb" 

# 찾고자 하는 셔터 장치의 이름 (예시: 실제 장치 이름으로 변경 필요)
TARGET_DEVICE_NAME = "BBL_SHUTTER"

def hid_report_handler(characteristic: int, data: bytearray):
    """
    셔터 장치로부터 HID Report를 수신할 때 호출되는 콜백 함수.
    
    셔터 이벤트(볼륨 업/다운)는 보통 6~8바이트 길이의 HID Report로 전송됩니다.
    볼륨 업(셔터) 키는 보통 Report의 두 번째 바이트에 특정 값으로 표시됩니다.
    """
    print(f"[{characteristic}]: Received HID Report: {data.hex()}")
    
    # 셔터 버튼 이벤트 감지 (HID 키보드 보고서 형식의 일반적인 패턴)
    # 볼륨 업(셔터)은 보통 두 번째 바이트(인덱스 1)가 0x80 또는 0x0E 등으로 설정됩니다.
    if len(data) >= 2:
        # 0xE9는 일반적으로 볼륨 업 키를 나타내는 HID Usage ID입니다.
        if data[1] == 0xE9:
            print("🚀 **셔터 버튼 (볼륨 업) 눌림 감지!**")
        elif data[1] == 0x00:
            print("셔터 버튼 떼짐 감지.")
        else:
            # 기타 키 또는 HID 이벤트
            pass


async def scan_and_connect():
    """타겟 장치를 스캔하고 연결을 시도하는 메인 함수"""
    print(f"Scanning for BLE device named '{TARGET_DEVICE_NAME}'...")

    # 스캔을 통해 장치를 찾습니다.
    scanner = BleakScanner()
    # 10초 동안 스캔
    devices = await scanner.discover(timeout=10.0)
    
    target_device = None
    for device in devices:
        if device.name and TARGET_DEVICE_NAME in device.name:
            target_device = device
            break
            
    if not target_device:
        print(f"Error: Could not find device with name '{TARGET_DEVICE_NAME}'.")
        print("Please ensure the device is discoverable and check the name.")
        return

    address = target_device.address
    print(f"Found target device at address: {address}. Connecting...")

    # 연결 시도
    async with BleakClient(address) as client:
        if not client.is_connected:
            print("Failed to connect.")
            return

        print("Connection successful! Discovering services...")
        
        # HID Report Characteristic 찾기
        report_char = None
        
        # 연결된 장치의 모든 서비스를 검색합니다.
        for service in client.services:
            print(f"\n[Service] UUID: {service.uuid} (Handle: {service.handle})")
            # HID 서비스 UUID 확인
            if service.uuid == HID_SERVICE_UUID:
                print(f"Found HID Service: {service.uuid}")
                for char in service.characteristics:
                    # Report Characteristic UUID 확인
                    print(f"uuid = {char.uuid}")
                    if char.uuid == REPORT_CHAR_UUID:
                        report_char = char
                        print(f"Found Report Characteristic: {char.uuid}")
                        break
                if report_char:
                    break

        if not report_char:
            print(f"Error: Could not find Report Characteristic ({REPORT_CHAR_UUID}).")
            return
            
        # Notification 구독 시작 (셔터 이벤트 수신)
        print("---> Notification 구독 시작 (셔터 이벤트 수신)")
        try:
            await client.start_notify(REPORT_CHAR_UUID, hid_report_handler)
            print("Subscribed to Report Characteristic notifications. Waiting for shutter events...")

            # 연결 유지 및 이벤트 수신 대기
            # 사용자가 Ctrl+C를 누를 때까지 무한정 대기
            while client.is_connected:
                await asyncio.sleep(1)

        except Exception as e:
            print(f"An error occurred during notification: {e}")
        finally:
            print("Stopping notifications and disconnecting...")
            await client.stop_notify(REPORT_CHAR_UUID)

if __name__ == "__main__":
    # Bleak는 비동기 함수(async)를 사용하므로 asyncio.run()으로 실행
    try:
        asyncio.run(scan_and_connect())
    except KeyboardInterrupt:
        print("\nClient stopped by user (KeyboardInterrupt).")
    except Exception as e:
        print(f"An unhandled error occurred: {e}")
728x90
728x90

출처

리눅스 버전 확인

pi@raspberrypi:~$ uname -a
Linux raspberrypi 6.6.20+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.6.20-1+rpt1 (2024-03-07) aarch64 GNU/Linux

도커 설치

pi@raspberrypi:~$ curl -sSL https://get.docker.com | sh

도커 버전 확인

pi@raspberrypi:~$ sudo docker version
Client: Docker Engine - Community
 Version:           26.0.0
 API version:       1.45

도커 허브에서 Oracle 데이터베이스용 이미지 다운로드

pi@raspberrypi:~$ sudo docker pull bluexmas/aarch64_oracle_db_19
Using default tag: latest
latest: Pulling from bluexmas/aarch64_oracle_db_19
ea4e27ae0b4c: Pull complete 
60e14e4a36dc: Pull complete 
2459d70df083: Pull complete 
43588f5a3c30: Pull complete 
fd59129c6b98: Pull complete 
f4347f997964: Pull complete 
b1a1518d1ad3: Pull complete 
051a9330efaf: Pull complete 
7145497f1832: Pull complete 
4f4fb700ef54: Pull complete 
Digest: sha256:276c6358c179efab39be868b6a8368df57c29210f0370c2e2cec9017f7b54dc2
Status: Downloaded newer image for bluexmas/aarch64_oracle_db_19:latest
docker.io/bluexmas/aarch64_oracle_db_19:latest

이미지 조회

pi@raspberrypi:~$ sudo docker images
REPOSITORY                      TAG       IMAGE ID       CREATED       SIZE
bluexmas/aarch64_oracle_db_19   latest    73ebf0277483   2 hours ago   5.89GB

환경변수 추가

pi@raspberrypi:~$ vi ~/.profile
CONTAINER_NAME=ORCL
ORADATA=~/oracle-docker/oradata

환경변수 적용

pi@raspberrypi:~$ source ~/.profile

데이터 디렉터리 및 Docker 볼륨 만들기

 for dir in audit data diag reco
  do mkdir -p $ORADATA/${CONTAINER_NAME}/${dir}
     rm -fr $ORADATA/${CONTAINER_NAME}/${dir}/*
     sudo docker volume rm ${CONTAINER_NAME}_${dir} 2>/dev/null
     sudo docker volume create --opt type=none --opt o=bind \
            --opt device=$ORADATA/${CONTAINER_NAME}/${dir} \
            ${CONTAINER_NAME}_${dir}
done
pi@raspberrypi:~$  for dir in audit data diag reco
>   do mkdir -p $ORADATA/${CONTAINER_NAME}/${dir}
>      rm -fr $ORADATA/${CONTAINER_NAME}/${dir}/*
>      sudo docker volume rm ${CONTAINER_NAME}_${dir} 2>/dev/null
>      sudo docker volume create --opt type=none --opt o=bind \
>             --opt device=$ORADATA/${CONTAINER_NAME}/${dir} \
>             ${CONTAINER_NAME}_${dir}
> done
ORCL_audit
ORCL_data
ORCL_diag
ORCL_reco

도커 이미지에서 디렉토리 권한이 없으므로 디렉토리 권한 해제

pi@raspberrypi:~$ cd oracle-docker/oradata/
pi@raspberrypi:~/oracle-docker/oradata$ sudo chmod 777 -Rf ORCL
pi@raspberrypi:~/oracle-docker/oradata$ cd ORCL
pi@raspberrypi:~/oracle-docker/oradata/ORCL$ ls -al
합계 24
drwxrwxrwx 6 pi pi 4096  3월 23일  21:58 .
drwxr-xr-x 3 pi pi 4096  3월 23일  21:58 ..
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 audit
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 data
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 diag
drwxrwxrwx 2 pi pi 4096  3월 23일  21:58 reco

Oracle Docker 이미지 실행

sudo docker run -d \
    --name ${CONTAINER_NAME} \
    --volume ${CONTAINER_NAME}_data:/u02/app/oracle/oradata \
    --volume ${CONTAINER_NAME}_diag:/u01/app/oracle/diag \
    --volume ${CONTAINER_NAME}_audit:/u01/app/oracle/admin \
    --volume ${CONTAINER_NAME}_reco:/u03/app/oracle \
    --volume $ORADATA/scripts:/scripts \
    -e ORACLE_SID=${CONTAINER_NAME} \
    -e ORACLE_PDB=${CONTAINER_NAME}PDB1 \
    -p 8080:8080 \
    -p 1521:1521 \
    bluexmas/aarch64_oracle_db_19
pi@raspberrypi:~$ sudo docker run -d \
>     --name ${CONTAINER_NAME} \
>     --volume ${CONTAINER_NAME}_data:/u02/app/oracle/oradata \
>     --volume ${CONTAINER_NAME}_diag:/u01/app/oracle/diag \
>     --volume ${CONTAINER_NAME}_audit:/u01/app/oracle/admin \
>     --volume ${CONTAINER_NAME}_reco:/u03/app/oracle \
>     --volume $ORADATA/scripts:/scripts \
>     -e ORACLE_SID=${CONTAINER_NAME} \
>     -e ORACLE_PDB=${CONTAINER_NAME}PDB1 \
>     -p 8080:8080 \
>     -p 1521:1521 \
>     bluexmas/aarch64_oracle_db_19
cb12a2d9068bdb4ccf34ab033bfcc5ea9a9222f6d397a783995a1fb9da9393af

도커 실행 로그 확인

pi@raspberrypi:~$ sudo docker logs -f $CONTAINER_NAME
cat: /sys/fs/cgroup/memory.max: No such file or directory
ERROR: There was a problem getting the cgroups memory limit on the system
Exiting...
 
## ----------------------------------------------------------------------------------------------- #
  Oracle password for SYS, SYSTEM and PDBADMIN: muPGi2X9#b6J_7 
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: Running DBCA for database ORCL at 2024-03-23 12:59:41
## ----------------------------------------------------------------------------------------------- #
 
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 23-MAR-2024 12:59:41
 
Copyright (c) 1991, 2023, Oracle.  All rights reserved.
 
Starting /u01/app/oracle/product/19.19/dbhome_1/bin/tnslsnr: please wait...
 
TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /u01/app/oracle/product/19.19/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/cb12a2d9068b/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                23-MAR-2024 12:59:41
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/19.19/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/cb12a2d9068b/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s).
  Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: Creating container database ORCL and 1 pluggable database(s) with name ORCLPDB1 at 2024-03-23 12:59:41
## ----------------------------------------------------------------------------------------------- #
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/ORCL.
Database Information:
Global Database Name:ORCL
System Identifier(SID):ORCL
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/ORCL/ORCL.log" for further details.
 
Pluggable database altered.
 
 
Pluggable database altered.
 
 
## ----------------------------------------------------------------------------------------------- #
  runDBCA: DBCA complete at 2024-03-23 13:09:10
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  Database ORCL with unique name ORCL is open and available. 
## ----------------------------------------------------------------------------------------------- #
 
## ----------------------------------------------------------------------------------------------- #
  Tailing alert_ORCL.log: 
2024-03-23T13:09:09.405148+00:00
ORCLPDB1(3):CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  SIZE 5M AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
ORCLPDB1(3):Completed: CREATE SMALLFILE TABLESPACE "USERS" LOGGING  DATAFILE  SIZE 5M AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED  EXTENT MANAGEMENT LOCAL  SEGMENT SPACE MANAGEMENT  AUTO
ORCLPDB1(3):ALTER DATABASE DEFAULT TABLESPACE "USERS"
ORCLPDB1(3):Completed: ALTER DATABASE DEFAULT TABLESPACE "USERS"
2024-03-23T13:09:10.226142+00:00
alter pluggable database all open
Completed: alter pluggable database all open
alter pluggable database all save state
Completed: alter pluggable database all save state

컨테이너 ID 확인

pi@raspberrypi:~$ sudo docker ps 
CONTAINER ID   IMAGE                           COMMAND                   CREATED          STATUS                    PORTS                                                                                            NAMES
cb12a2d9068b   bluexmas/aarch64_oracle_db_19   "/bin/sh -c 'exec $D…"   10 minutes ago   Up 10 minutes (healthy)   0.0.0.0:1521->1521/tcp, :::1521->1521/tcp, 0.0.0.0:8080->8080/tcp, :::8080->8080/tcp, 5500/tcp   ORCL

SQLPlus 접속

pi@raspberrypi:~$ sudo docker exec -it cb12a2d9068b sqlplus
 
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 23 13:11:36 2024
Version 19.19.0.0.0
 
Copyright (c) 1982, 2023, Oracle.  All rights reserved.
 
Enter user-name: SYSTEM
Enter password: 
Last Successful login time: Sat Mar 23 2024 13:05:14 +00:00
 
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.19.0.0.0
 
SQL> select TABLESPACE_NAME from DBA_TABLESPACES;
 
TABLESPACE_NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
 
SQL> 
728x90
728x90

출처

카메라 모듈 연결 확인

pi@raspberrypi:~$ vcgencmd get_camera
supported=1 detected=1, libcamera interfaces=0

사진 찍기

pi@raspberrypi:~$ raspistill -o picture1.jpg

Python으로 사진 찍기

Python 소스 코드 작성

pi@raspberrypi:~$ vi camera_capture.py

camera_capture.py

import picamera
import time

camera = picamera.PiCamera()
camera.resolution = (2592, 1944) # (64, 64) ~ (2592, 1944) px

time.sleep(3)
camera.capture('snapshot.jpg')

실행

pi@raspberrypi:~$ python camera_capture.py

 

 

728x90
728x90

출처

WiFi 상태 확인

pi@raspberrypi:~$ iwconfig
lo        no wireless extensions.
 
eth0      no wireless extensions.
 
wlan0     IEEE 802.11  ESSID:"bluexmas"  
          Mode:Managed  Frequency:2.452 GHz  Access Point: 88:36:6C:45:F7:B0   
          Bit Rate=58.5 Mb/s   Tx-Power=31 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          Link Quality=62/70  Signal level=-48 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:1  Invalid misc:0   Missed beacon:0

SSID 목록 조회

pi@raspberrypi:~$ sudo iwlist wlan0 scan | grep SSID
                    ESSID:"U+Net7CCC"
                    ESSID:"bluexmas"
                    ESSID:"U+Net6519_5G"
                    ESSID:"Robin"
                    ESSID:"U+Net6519"
                    ESSID:"SK_WiFiGIGA71B1"
                    ESSID:"SK_WiFiGIGA71B1_2.4G"
                    ESSID:"\x00\x00\x00\x00\x00\x00\x00"
                    ESSID:"U+Net7CCC_5G"
                    ESSID:"\x00\x00\x00\x00\x00\x00\x00"

숨겨진 SSID 연결

scan_ssid값이 1인 경우 숨겨진 SSID 연결 설정

pi@raspberrypi:~$ cat /etc/wpa_supplicant/wpa_supplicant.conf 
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
 
network={
       ssid="bluexmas5G"
       scan_ssid=1
       psk="test1234" 
}

Network Manager 변경

pi@raspberrypi:~$ sudo raspi-config

NetworkManager 실행 상태 확인

pi@raspberrypi:~$ sudo systemctl status NetworkManager 
● NetworkManager.service - Network Manager
     Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
    Drop-In: /usr/lib/systemd/system/NetworkManager.service.d
             └─10-dhcpcd.conf
     Active: active (running) since Sat 2024-01-27 01:57:21 GMT; 4min 3s ago
       Docs: man:NetworkManager(8)
   Main PID: 496 (NetworkManager)
      Tasks: 3 (limit: 4088)
        CPU: 681ms
     CGroup: /system.slice/NetworkManager.service
             └─496 /usr/sbin/NetworkManager --no-daemon
 
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3284] device (wlan0): state change: ip-config -> ip-check (r>
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3382] device (wlan0): state change: ip-check -> secondaries >
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3390] device (wlan0): state change: secondaries -> activated>
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3405] manager: NetworkManager state is now CONNECTED_LOCAL
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3541] manager: NetworkManager state is now CONNECTED_SITE
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3547] policy: set 'bluexmas' (wlan0) as default for IPv4 routing>
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.3557] dns-mgr: Writing DNS information to /sbin/resolvconf
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.4547] device (wlan0): Activation: successful, device activat>
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.4568] manager: NetworkManager state is now CONNECTED_GLOBAL
Jan 27 01:57:31 raspberrypi NetworkManager[496]:   [1706320651.4589] manager: startup complete

NetworkManager 연결 정보 확인

pi@raspberrypi:~$ cd /etc/NetworkManager/system-connections
pi@raspberrypi:/etc/NetworkManager/system-connections$ ls
bluexmas.nmconnection
pi@raspberrypi:/etc/NetworkManager/system-connections$ sudo cat bluexmas.nmconnection 
[connection]
id=bluexmas
uuid=db18715a-410e-4c57-8fc3-475a7391faec
type=wifi
interface-name=wlan0
permissions=
timestamp=1706314246
 
[wifi]
mac-address-blacklist=
mode=infrastructure
seen-bssids=88:36:6C:45:F7:B0;
ssid=bluexmas
 
[wifi-security]
auth-alg=open
key-mgmt=wpa-psk
psk=s2u2n4g6
 
[ipv4]
dns-search=
method=auto
 
[ipv6]
addr-gen-mode=stable-privacy
dns-search=
method=auto
 
[proxy]
728x90
728x90

출처

Raspberry PI 시스템 업그레이드

pi@raspberrypi:~$ sudo apt update
pi@raspberrypi:~$ sudo apt upgrade

MongoDB 설치

빌드 도구 맟 관련 패키지 설치

pi@raspberrypi:~$ sudo apt-get install gcc-8 g++-8
pi@raspberrypi:~$ sudo apt-get install libssl-dev libcurl4-openssl-dev

Mongo DB 소스 다운로드

pi@raspberrypi:~$ git clone -b r4.4.0 https://github.com/mongodb/mongo.git
pi@raspberrypi:~$ cd mongo/

MongoDB GPG 서명 키 추가

pi@raspberrypi:~$ wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

MongoDB에 대한 스토리지 엔진 및 복제를 구성한 다음 MongoDB 서비스를 시작

$ sudo sed -i "s/^#  engine:/  engine: wiredTiger/"  /etc/mongod.conf
$ sudo sed -i "s/^#replication:/replication:\n  replSetName: rs01/" /etc/mongod.conf

MongoDB 서비스 시작 및 활성화

bluesanta@Kubuntu:~$ sudo systemctl daemon-reload
bluesanta@Kubuntu:~$ sudo systemctl enable mongod
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service.
bluesanta@Kubuntu:~$ sudo systemctl restart mongod

MongoDB 서비스 확인

bluesanta@Kubuntu:~$ systemctl status mongod
● mongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-05-24 01:28:11 KST; 5s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 287216 (mongod)
     Memory: 65.2M
     CGroup: /system.slice/mongod.service
             └─287216 /usr/bin/mongod --config /etc/mongod.conf
 
 5월 24 01:28:11 Kubuntu systemd[1]: Started MongoDB Database Server.
 5월 24 01:28:11 Kubuntu mongod[287216]: /usr/bin/mongod: /usr/local/lib/libcurl.so.4: no version information available (required by >

MongoDB 테스트

bluesanta@Kubuntu:~$ mongo --eval "printjson(rs.initiate())"
MongoDB shell version v5.0.8
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("63537e3c-d3f1-42df-8158-043e7a759f3c") }
MongoDB server version: 5.0.8
{
        "info2" : "no configuration specified. Using a default configuration for the set",
        "me" : "127.0.0.1:27017",
        "ok" : 1
}

MongoDB 로그 확인

bluesanta@Kubuntu:~$ sudo tail -f /var/log/mongodb/mongod.log

 

 

 

빌드오류

Creating 'build/opt/mongo/resmoke/resmoke.py'
Creating 'build/opt/mongo/config.h'
/usr/bin/python3 src/mongo/base/generate_error_codes.py src/mongo/base/error_codes.yml src/mongo/base/error_codes.tpl.h build/opt/mongo/base/error_codes.h
Install file: "build/opt/mongo/resmoke/resmoke.py" as "build/install/bin/resmoke.py"
Chmod("build/install/bin/resmoke.py", "u+x")
Compiling build/opt/third_party/mozjs-60/extract/mozglue/misc/ConditionVariable_posix.o
cc1plus: fatal error: js-confdefs.h: No such file or directory
compilation terminated.
scons: *** [build/opt/third_party/mozjs-60/extract/mozglue/misc/ConditionVariable_posix.o] Error 1
Generating build/opt/mongo/db/logical_session_id_gen.cpp
/usr/bin/python3 src/mongo/base/generate_error_codes.py src/mongo/base/error_codes.yml src/mongo/base/error_codes.tpl.cpp build/opt/mongo/base/error_codes.cpp
scons: building terminated because of errors.
build/opt/third_party/mozjs-60/extract/mozglue/misc/ConditionVariable_posix.o failed: Error 1

몽고 DB 삭제 방법

bluesanta@Kubuntu:~$ sudo apt-get remove mongodb-org
bluesanta@Kubuntu:~$ sudo apt-get purge mongodb-org*
bluesanta@Kubuntu:~$ sudo rm -rf /var/log/mongodb
bluesanta@Kubuntu:~$ sudo rm -rf /var/lib/mongodb
728x90
728x90

출처

리눅스 정보 조회

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

pi@raspberrypi:~$ cat /etc/*-release | uniq
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

리눅스 비트 확인

출처 : 리눅스 32비트 64비트 확인 - 제타위키

pi@raspberrypi:~$ getconf LONG_BIT
32

관련패키지 설치

pi@raspberrypi:~$ sudo apt install gcc g++ libncurses5-dev libxml2-dev openssl libssl-dev curl libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev libsasl2-dev autoconf libncurses5-dev

MySQL 계정 만들기

pi@raspberrypi:~$ sudo groupadd mysql
pi@raspberrypi:~$ sudo useradd -g mysql -s /bin/bash -m mysql

cmake 설치

pi@raspberrypi:~$ sudo apt-get install cmake

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

pi@raspberrypi:~$ wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.35.tar.gz 
pi@raspberrypi:~$ tar xvf mysql-boost-5.7.35.tar.gz 
pi@raspberrypi:~$ cd mysql-5.7.35
pi@raspberrypi:~/mysql-5.7.35$ sudo 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=3306 \
-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
pi@raspberrypi:~/mysql-5.7.35$ sudo make 
pi@raspberrypi:~/mysql-5.7.35$ sudo make install

환경설정

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

my.cnf

[mysqld]
port=8017
# 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

skip_ssl
# disable_ssl

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

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

pi@raspberrypi:~/mysql-5.7.35$ sudo chown -R mysql:mysql /usr/local/mysql57

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

pi@raspberrypi:~/mysql-5.7.35$ su mysql
Password: 
mysql@raspberrypi:/home/pi/mysql-5.7.35$ whoami
mysql
mysql@raspberrypi:/home/pi/mysql-5.7.35$ cd /usr/local/mysql57
mysql@raspberrypi:/usr/local/mysql57$ bin/mysql_install_db --no-defaults --user=mysql --datadir=/usr/local/mysql57/data --basedir=/usr/local/mysql57 -v
2021-12-19 09:54:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2021-12-19 09:54:25 [NOTE]    Creating data directory /usr/local/mysql57/data
2021-12-19 09:54:25 [NOTE]    Generating random password to /home/mysql/.mysql_secret...done.
2021-12-19 09:54:25 [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-12-19 09:54:55 [NOTE]    Creating system tables...done.
2021-12-19 09:54:55 [NOTE]    Filling system tables with data...done.
2021-12-19 09:55:00 [NOTE]    Filling help table with data...done.
2021-12-19 09:55:00 [NOTE]    Creating user for internal session service...done.
2021-12-19 09:55:00 [NOTE]    Creating default user root@localhost
2021-12-19 09:55:00 [NOTE]    Creating default proxy root@localhost
2021-12-19 09:55:00 [NOTE]    Creating sys schema
2021-12-19 09:55:02 [NOTE]    done.
2021-12-19 09:55:03 [WARNING] The bootstrap log isn't empty:
2021-12-19 09:55:03 [WARNING] 2021-12-19T00:54:25.228532Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead

MySQL 서비스 등록

서비스 mysqld 파일 복사

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

mysqld 수정

mysql@raspberrypi:/usr/local/mysql57$ sudo vi /etc/init.d/mysqld57

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

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

mysqld 서비스 등록

mysql@raspberrypi:/usr/local/mysql57$ sudo update-rc.d mysqld57 defaults

mysqld 서비스 실행

mysql@raspberrypi:/usr/local/mysql57$ sudo systemctl start mysqld57.service
mysql@raspberrypi:/usr/local/mysql57$ sudo systemctl status mysqld57.service
● mysqld57.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/init.d/mysqld57; generated)
   Active: active (running) since Sun 2021-12-19 10:27:04 KST; 12s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 15063 ExecStart=/etc/init.d/mysqld57 start (code=exited, status=0/SUCCESS)
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mysqld57.service
           ├─15071 /bin/sh /usr/local/mysql57/bin/mysqld_safe --datadir=/usr/local/mysql57/data --pid-file=/usr/local/mysql57/data/raspb
           └─15419 /usr/local/mysql57/bin/mysqld --basedir=/usr/local/mysql57 --datadir=/usr/local/mysql57/data --plugin-dir=/usr/local/
 
Dec 19 10:27:01 raspberrypi systemd[1]: Starting LSB: start and stop MySQL...
Dec 19 10:27:01 raspberrypi mysqld57[15063]: Starting MySQL
Dec 19 10:27:02 raspberrypi mysqld57[15063]: .Logging to '/usr/local/mysql57/data/raspberrypi.err'.
Dec 19 10:27:04 raspberrypi mysqld57[15063]: ...
Dec 19 10:27:04 raspberrypi systemd[1]: Started LSB: start and stop MySQL.
mysql@raspberrypi:/usr/local/mysql57$ sudo systemctl stop mysqld57.service

root 암호 초기화

권한을 무시하고 mysql 서버 실행

mysql@raspberrypi:/usr/local/mysql57$ bin/mysqld_safe --skip-grant-tables &
[1] 15759
mysql@raspberrypi:/usr/local/mysql57$ 2021-12-19T01:32:53.052394Z mysqld_safe Logging to '/usr/local/mysql57/data/raspberrypi.err'.
2021-12-19T01:32:53.127375Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql57/data

root 암호 설정

mysql@raspberrypi:/usr/local/mysql57$ 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.35-log Source distribution
 
Copyright (c) 2000, 2021, 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> 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('manager01!') where user = 'root';
Query OK, 1 row affected, 1 warning (0.01 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('sql');
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> create user 'user1'@'%' identified by 'userpw'; 
mysql> grant all privileges on *.* to 'user1'@'%' with grant option; 
mysql> flush privileges;

사용자 추가

mysql> create user 'terecal'@'%' identified by '****';
mysql> GRANT ALL privileges ON terecal_db.* TO 'terecal'@'%';
mysql> flush privileges;
728x90
728x90

출처

Tomcat 다운로드

pi@raspberrypi:~$ wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.72/bin/apache-tomcat-8.5.72.tar.gz

Tomcat 압축풀기

pi@raspberrypi:~$ sudo tar xvf apache-tomcat-8.5.72.tar.gz -C /usr/local
pi@raspberrypi:~$ cd /usr/local/apache-tomcat-8.5.72/
pi@raspberrypi:/usr/local/apache-tomcat-8.5.72$ 

Tomcat 서비스 등록

tomcat.service 파일 생성

pi@raspberrypi:~$ sudo vi /etc/systemd/system/tomcat.service

tomcat.service 파일

[UNIT]
Description=tomcat8
After=syslog.target network.target

[Service]
Type=forking

Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_202/"
Environment="CATALINA_HOME=/usr/local/apache-tomcat-8.5.72"
Environment="CATALINA_BASE=/usr/local/apache-tomcat-8.5.72"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"

ExecStart=/usr/local/apache-tomcat-8.5.72/bin/startup.sh
ExecStop=/usr/local/apache-tomcat-8.5.72/bin/shutdown.sh

User=root
Group=root
UMask=0007
RestartSec=10

[Install]
WantedBy=multi-user.target

Tomcat 서비스 등록

pi@raspberrypi:~$ sudo systemctl enable tomcat.service Created symlink /etc/systemd/system/multi-user.target.wants/tomcat.service → /etc/systemd/system/tomcat.service.

Tomcat 서비스 시작

pi@raspberrypi:~$ sudo systemctl start tomcat.service

Tomcat 서비스 종료

pi@raspberrypi:~$ sudo systemctl start tomcat.service

Tomcat 서비스 재시작

pi@raspberrypi:~$ sudo systemctl restart tomcat.service

Tomcat 서비스 싱태 확인

pi@raspberrypi:~$ sudo systemctl status tomcat.service
● tomcat.service
   Loaded: loaded (/etc/systemd/system/tomcat.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2021-10-23 22:32:44 KST; 8s ago
  Process: 18200 ExecStart=/usr/local/apache-tomcat-8.5.72/bin/startup.sh (code=exited, status=0/SUCCESS
 Main PID: 18207 (java)
    Tasks: 24 (limit: 4915)
   CGroup: /system.slice/tomcat.service
           └─18207 /usr/local/java/jdk1.8.0_202//bin/java -Djava.util.logging.config.file=/usr/local/apa
 
Oct 23 22:32:44 raspberrypi systemd[1]: Starting tomcat.service...
Oct 23 22:32:44 raspberrypi startup.sh[18200]: Tomcat started.
Oct 23 22:32:44 raspberrypi systemd[1]: Started tomcat.service.
728x90
728x90

출처

압축풀기

pi@raspberrypi:~$ tar xvf jdk-8u202-linux-arm32-vfp-hflt.tar.gz

jdk 디렉토리 이동

pi@raspberrypi:~$ sudo mkdir /usr/local/java
pi@raspberrypi:~$ sudo mv jdk1.8.0_202/ /usr/local/java/

java를 기본 명령어로 등록

pi@raspberrypi:~$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_202/bin/java" 1;
update-alternatives: using /usr/local/java/jdk1.8.0_202/bin/java to provide /usr/bin/java (java) in auto mode
pi@raspberrypi:~$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_202/bin/javac" 1;
update-alternatives: using /usr/local/java/jdk1.8.0_202/bin/javac to provide /usr/bin/javac (javac) in auto mode
pi@raspberrypi:~$ ls -al /usr/bin/java
lrwxrwxrwx 1 root root 22 Oct 23 22:04 /usr/bin/java -> /etc/alternatives/java

pi@raspberrypi:~$ sudo update-alternatives --set java /usr/local/java/jdk1.8.0_202/bin/java;
pi@raspberrypi:~$ sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_202/bin/javac;

설치확인

pi@raspberrypi:~$ java -version
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) Server VM (build 25.202-b08, mixed mode)
728x90

+ Recent posts