mysqldump 오류? 버그?

MySQL 5.7 mysqldump 오류? 버그?

mysql 버전 확인

$ mysql --version
mysql  Ver 14.14 Distrib 5.7.31, for Linux (x86_64) using  EditLine wrapper

mysqldump 명령으로 데이타베이스 백업을 할 때, 아래와 같은 오류메시지가 나왔다.

$ mysqldump -Q -u boxcorea -p boxcorea > boxcorea20201019.sql
Enter password:
mysqldump: Error: 'Access denied; you need (at least one of) the PROCESS privilege(s) for this operation' when trying to dump tablespaces

Continue reading

django Mongodb connector 설정하기

Django mongodb connector 설정하기

참고문서: https://nesdis.github.io/djongo/get-started/

사전작업: mongodb 설치, django3.1 설치.

1. django-mongodb connector(djongo) 설치.
pip 로 django를 설치하면 아래처럼 몇몇 패키지들은 제거되고 django3.0.5가 설치된다. django 3.1버전이 지원되지 않아서 그런듯 하다.

pip install django
Collecting django
  Using cached https://files.pythonhosted.org/packages/2b/5a/4bd5624546912082a1bd2709d0edc0685f5c7827a278d806a20cf6adea28/Django-3.1-py3-none-any.whl
Collecting pytz (from django)
  Using cached https://files.pythonhosted.org/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl
Collecting sqlparse>=0.2.2 (from django)
  Using cached https://files.pythonhosted.org/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl
Collecting asgiref~=3.2.10 (from django)
  Using cached https://files.pythonhosted.org/packages/d5/eb/64725b25f991010307fd18a9e0c1f0e6dff2f03622fc4bcbcdb2244f60d6/asgiref-3.2.10-py3-none-any.whl
Installing collected packages: pytz, sqlparse, asgiref, django
Successfully installed asgiref-3.2.10 django-3.1 pytz-2020.1 sqlparse-0.3.1
...

Requirement already satisfied: asgiref~=3.2 in d:\python_project\bctools\venv\lib\site-packages (from django<=3.0.5,>=2.1->djongo) (3.2.10)
Requirement already satisfied: pytz in d:\python_project\bctools\venv\lib\site-packages (from django<=3.0.5,>=2.1->djongo) (2020.1)
Installing collected packages: sqlparse, pymongo, django, djongo
  Found existing installation: sqlparse 0.3.1
    Uninstalling sqlparse-0.3.1:
      Successfully uninstalled sqlparse-0.3.1
  Found existing installation: Django 3.1
    Uninstalling Django-3.1:
      Successfully uninstalled Django-3.1
  Running setup.py install for djongo ... done
Successfully installed django-3.0.5 djongo-1.3.3 pymongo-3.11.0 sqlparse-0.2.4

Continue reading

Python Tibero odbc

현 시점에, Django가 티베로 odbc를 지원하지 않기때문에, 프로그래밍할때 ORM 사용은 불가능하다. 때문에, 아래와 같은 클래스를 만들어서 사용했다.

티베로 ODBC설정은 Ubuntu+Tibero+Python3+ODBC 연결하기를 참고하면 된다.

insert, delete 문은 execute 메소드를 사용하면되며, 결과값이 있는 쿼리는 query나 fetchone, fetchall 메소드를 사용하면된다. 윈도우 환경에서는 setdecoding 관련 부분이 필요 없지만, 리눅스 환경에서는 꼭 필요하다.

# Use to Tibero database from ODBC.
# if has return query then use query, else execute...

import pyodbc


class Tibero:
    def __init__(self):
        dbuser = 'tibero_user'
        dbpass = 'tibero_password'
        dsn = 'ODBC_DSN'
        self.coninfo = 'DSN=%s;UID=%s;PWD=%s' % (dsn, dbuser, dbpass)
        self._conn = pyodbc.connect(self.coninfo)

        # setdecoding not need to windows, but need to linux
        self._conn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
        self._conn.setdecoding(pyodbc.SQL_WCHAR, encoding='utf-8')
        self._conn.setdecoding(pyodbc.SQL_WMETADATA, encoding='utf-32le')
        self._conn.setencoding(encoding='utf-8')
        self._cursor = self._conn.cursor()

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):
        self.close()

    @property
    def connect(self):
        return self._conn

    @property
    def cursor(self):
        return self._cursor

    def commit(self):
        self.connect.commit()

    def close(self, commit=True):
        if commit:
            self.commit()
        self.connect.close()

    def execute(self, sql, params=None):
        self.cursor.execute(sql, params or ())

    def fetchall(self):
        return self.cursor.fetchall()

    def fetchone(self):
        return self.cursor.fetchone()

    def query(self, sql, params=None):
        self.cursor.execute(sql, params or ())
        return self.fetchall()

django make migrations error. – table doesn’t exist

django app 에서 makemigrations 했을때, 테이블이 없다는 오류메시지가 나올때 처리방법.

(venv) D:\Python_Project\ipchaser\ipchaser>manage.py makemigrations chaser
Traceback (most recent call last):
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\mysql\base.py", line 74, in execute
    return self.cursor.execute(query, args)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
    res = self._query(query)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 315, in _query
    db.query(q)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\connections.py", line 239, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'ipchaser.tools_macvendors' doesn't exist")

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "D:\Python_Project\ipchaser\ipchaser\manage.py", line 21, in <module>
    main()
  File "D:\Python_Project\ipchaser\ipchaser\manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 366, in execute
    self.check()
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 395, in check
    include_deployment_checks=include_deployment_checks,
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 407, in check
    for pattern in self.url_patterns:
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\Works\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Python_Project\ipchaser\ipchaser\ipchaser\urls.py", line 20, in <module>
    path('tools/', include('tools.urls')),
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\Works\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Python_Project\ipchaser\ipchaser\tools\urls.py", line 2, in <module>
    from .views import DiffView, MacVenrorsView, WhoisSearch, DNSLookup
  File "D:\Python_Project\ipchaser\ipchaser\tools\views.py", line 23, in <module>
    class MacVenrorsView(View):
  File "D:\Python_Project\ipchaser\ipchaser\tools\views.py", line 26, in MacVenrorsView
    total = MacVendors.objects.count()
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\query.py", line 397, in count
    return self.query.get_count(using=self.db)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\query.py", line 517, in get_count
    number = obj.get_aggregation(using, ['__count'])['__count']
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\query.py", line 502, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\models\sql\compiler.py", line 1144, in execute_sql
    cursor.execute(sql, params)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 100, in execute
    return super().execute(sql, params)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\django\db\backends\mysql\base.py", line 74, in execute
    return self.cursor.execute(query, args)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
    res = self._query(query)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\cursors.py", line 315, in _query
    db.query(q)
  File "D:\Python_Project\ipchaser\venv\lib\site-packages\MySQLdb\connections.py", line 239, in query
    _mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1146, "Table 'ipchaser.tools_macvendors' doesn't exist")

Continue reading

Extreme switch stack 구성 – 수동(?) 설정.

익스트림 스위치 스택 구성 – 수동 구성

스위치 모델: x440-24p 2대.

이전 글에서는 익스트림 스위치의 스택을 easysetup 을 사용하여 구성했다.

스택 케이블 연결후, 모든 스위치에서

* X440-24p.2 # configure stacking protocol standard
This command will take effect at the next reboot of the specified node(s).

enable stacking 명령을 내린후, easy setup 에서 No를 선택한다.(기본값임)

* X440-24p.3 # enable stacking
You have not yet configured all required stacking parameters.
Would you like to perform an easy setup for stacking operation? (y/N)

Stacking has been enabled as requested.
This command will take effect at the next reboot of the specified node(s).

Continue reading

extreme switch 스택 구성 – EasySetup 사용.

extreme switch stack 구성 – EasySetup 사용.

* 작업 스위치 모델: x440-24p
* 공장초기화 상태에서 진행함.

1. 스택 케이블 연결전 확인사항.

Stack 구성을 하면 설정이 삭제되므로, 명령을 내리기 전에 설정을 백업 받아둔다.

연결전 모든 스위치의 라이센스, OS 버전이 동일해야 한다.
OS 버전이 다르다면 동일하게 맞추어준다.(OS 업그레이드는 https://blog.boxcorea.com/wp/archives/2585 를 참고)
각각의 스위치에서 아래 명령으로 확인 한다.

라이센스 확인

* X440-24p.1 # show license
Enabled License Level:
        Edge
Enabled Feature Packs:
        None

OS버전확인

* X440-24p.2 # show version images
Card  Partition     Installation Date        Version     Name      Branch
------------------------------------------------------------------------------
Switch primary   Thu Dec 15 15:04:34 UTC 2016 16.2.2.4 summitX-16.2.2.4.xos 16.2.2.4
Switch secondary Thu Dec 15 15:04:34 UTC 2016 16.2.2.4 summitX-16.2.2.4.xos 16.2.2.4

* X440-24p.3 # show switch
..

Current State:    OPERATIONAL
Image Selected:   primary
Image Booted:     primary
Primary ver:      16.2.2.4
Secondary ver:    16.2.2.4

Config Selected:  NONE
Config Booted:    Factory Default

Continue reading

Django 다국어 사용

django 3.1 다국어 사용

* 확인사항:
django에서 다국어지원을 위해서는 os에 gettext가 설치되어 있어야 한다.

django에서 다국어 지원을 위해 settings.py에 아래 내용을 추가해야 한다.

cat project/settins.py

from django.utils.translation import ugettext_lazy as _

...


MIDDLEWARE = [
    ...
    'django.middleware.locale.LocaleMiddleware',
    ...
]

# adding for i18n
LANGUAGES =[
    ('ko', _('Korean')),
    ('en', _('English')),
    # ('zh-CN', _('Simplified Chinese')),
]

LOCALE_PATHS = (
    os.path.join(BASE_DIR, 'locale'),
)

Continue reading

CentOS 8, Nagios core 설치

CentOS 8 , Nagios 설치하기.

설치환경
OS: CentOS8, selinux disabled
firewalld: 사용안함.
IP 주소: 192.168.0.3

1. Nagios 설치에 필요한 패키지를 설치한다.

컴파일러 설치

# yum group install "development tools"

Nagios 설치에 필요한 패키지를 설치.

# yum install httpd php php-cli net-snmp net-snmp-utils epel-release postfix

2. Nagios 다운로드
글쓰는 시점의 최신버전은 4.4.6이며, 이 버전의 소스코드를 다운로드한다.

# wget https://github.com/NagiosEnterprises/nagioscore/releases/download/nagios-4.4.6/nagios-4.4.6.tar.gz

Continue reading

리눅스 HA (pacemaker, corosync, iscsi shared storage) – part 3

리눅스 HA(Pacemaker, corosync, iscsi shared storage, lvm2) – part 3

작업환경:
CentOS 8
node1 : wolf1, 192.158.0.31
node2 : wolf2, 192.168.0.32
Virtual IP: 192.168.0.30
shared storage: wolfstorage, 192.168.0.33

참고:
리눅스 HA(corosync, pacemaker) – Part 1
리눅스 HA(corosync, pacemaker, DRBD) – Part 2
리눅스 HA(corosync, pacemaker, shared disk)에 zabbix 모니터링 서버 구성 – part 4
CentOS에서 iscsi 사용하기

1. iscsi 서버로 shared storage 준비한다. ip 주소는 192.168.0.33으로 설정되어 있다.
빈 디스크를 iscsi shard disk로 사용할 것이다. parted -l 명령어로 확인해보면 아래와 같은 화면을 볼 수 있다.
/dev/sdb 를 사용한다.

# parted -l
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  8590MB  8589MB  primary  xfs          boot


Error: /dev/sdb: unrecognised disk label
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 8590MB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

Continue reading

Ubuntu+Tibero+Python3+ODBC 연결하기

Ubuntu 18.04에서 python3과 tibero 데이타베이스 연동하기

Tibero는 python 드라이버를 지원하지 않으므로, ODBC를 통해서 연결해야한다.

우분투리눅스에 ODBC를 아래 명령어로 설치한다.

# sudo apt install build-essential
# sudo apt install libssl-dev python3-dev
# sudo apt install unixodbc unixodbc-dev

tibero odbc 드라이버를 설치하려면 tibero client를 설치해야하지만, 티베로 데이타베이스서버에서 아래 파일만 복사하여 사용할 수도 있다.
여기서는 tibero 서버에서 libtbodbc.so 파일을 가져와서 /home/tibero/client/ 에 설치했다.

$ ls -l
-rwxr-xr-x 1 tibero dba  32171678 Aug 12 13:38 libtbodbc.so

Continue reading