티스토리 뷰

와 진짜 내가 컴맹은 컴맹인가보다

Python에서 그냥 import redis 하고 쓰면 그냥 써지는건줄 알았다.

근데 아니었다. redis server를 설치해야했다 ㅡㅡ

일단 삽질기를 기록해보겠다.

 

일단 기본적인 튜토리얼은 아래 사이트를 참고했다.

http://www.bogotobogo.com/python/python_redis_with_python.php

 

열라 간단하다.

pip install redis

prompt에서 위 명령어로 일단 redis를 설치해주자.

그리고 코드는 아래와 같이 간단히 써보았다.

import redis
r = redis.Redis(host='localhost', port=6379, db=0) #인자는 생략해도 됨
r.set('foo','bar')
r.get('foo')

오메~ 간단하다..

근데 에러가 주루루루루 뜨더라.

PS D:\Program\Python\test> python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import redis
>>> r = redis.Redis(db = 0)
>>> r.set('foo',8)
Traceback (most recent call last):
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 484, in connect
    sock = self._connect()
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 541, in _connect
    raise err
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 529, in _connect
    sock.connect(socket_address)
ConnectionRefusedError: [WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\client.py", line 667, in execute_command
    connection.send_command(*args)
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 610, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 585, in send_packed_command
    self.connect()
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 489, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 10061 connecting to localhost:6379. 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 484, in connect
    sock = self._connect()
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 541, in _connect
    raise err
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 529, in _connect
    sock.connect(socket_address)
ConnectionRefusedError: [WinError 10061] 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\client.py", line 1171, in set
    return self.execute_command('SET', *pieces)
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\client.py", line 673, in execute_command
    connection.send_command(*args)
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 610, in send_command
    self.send_packed_command(self.pack_command(*args))
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 585, in send_packed_command
    self.connect()
  File "C:\Users\domino\AppData\Local\Programs\Python\Python36-32\lib\site-packages\redis\connection.py", line 489, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 10061 connecting to localhost:6379. 대상 컴퓨터에서 연결을 거부했으므로 연결하지 못했습니다.

아놔 뭐지.. 알고보니 redis server 프로그램을 설치해야했다.

그래서 https://redis.io/download 여기로 가봤더니... linux용 server 파일밖에 없더라.

열심히 구글링을 해보니

https://github.com/MSOpenTech/redis/releases

위 사이트를 알 수 있었다.

Redis 는 공식적으로 Windows를 지원하지 않지만, Microsoft Open Tech 그룹에서 64비트 기반으로 포팅하여 개발 및 유지보수를 진행하고 있습니다.
64 비트만 지원하는 이유는 32 비트는 지원 가능한 메모리가 4G로 제한이 있으므로 메모리에 데이터를 저장하는 인 메모리 데이터베이스에는 부적합하기 때문일 겁니다.

출처: http://hwigyeom.ntils.com/entry/Windows-에-Redis-설치하기-1 [Hwigyeom's Web Development]

위 사이트에서 Redis-x64-3.2.100.msi 를 다운 받아서 설치완료.

그리고 나서 처음에 안됐던 코드를 실행했더니 잘 된다!

우와~ 나중에 linux 환경으로 다시 deploy 할거 생각하면 걍 처음부터 리눅스로 할걸.. 아니 docker를 써볼껄.. 하는 생각도 들지만..

차근차근 합시다요~~!!

 

 

 

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함