티스토리 뷰

Server

CentOS Redis 7 설치

터프남 2022. 6. 21. 00:08
728x90

빠르게 레디스 설치 명령어 적용

yum install epel-release

redis 설치 7버전(최신) 설치할 때

yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

그냥 설치하려면

yum -y install redis

그런데 이렇게 설치하려면 yum list | grep redis 로 설치될 버전을 확인할 수 있음.

설치한 패키지 확인

rpm -qi redis

레디스 설정 변경

  • 원격접속 설정
vi /etc/redis/redis.conf  
# bind 127.0.0.1 =>주석
bind 0.0.0.0  =>설정해줘야함 

서비스 시작

systemctl enable --now redis

#재부팅 시 자동 시작 되도록하려면
systemctl enable redis

방화벽 추가

firewall-cmd --permanent --add-service=redis
firewall-cmd --reload

다른 블로그에는 이렇게도 한다..
#서비스 명으로 등록
firewall-cmd --zone=public --add-service=redis --permanent
#포트로 등록
firewall-cmd --add-port=6379/tcp --permanent

firewall-cmd --reload

레디스 재시작 & 상태 체크

systemctl restart redis

systemctl status redis

확인

redis-cli -h {호스트} -p {포트} ping

명령어 치면 
PONG으로 리턴옴

5버전 이후 cli 접속 시

(error) DENIED Redis is running in protected mode because protected mode is enabled and no password is set for the default user. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a an authentication password for the default user. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

이런 오류시
아까 설정파일 /etc/redis/redis.conf 에서
protected-mode가 yes로 되어 있는걸 no로 바꾸면된다.. 근데 보안적인건데 일단 임시로 바꾸고 좀 알아봐야 할듯

# protected-mode yes 주석
protected-mode no
728x90
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
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 31
글 보관함