1.설치
1 2 3 |
yum -y install redis |
2.실행, 중지, 재시작
1 2 3 4 5 |
# systemctl start redis # systemctl stop redis # systemctl restart redis |
3.상태확인
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# systemctl status redis ● redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2022-07-07 12:02:31 UTC; 5s ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 1363 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Main PID: 1379 (redis-server) Tasks: 4 (limit: 2274) Memory: 1.8M CGroup: /system.slice/redis-server.service └─1379 /usr/bin/redis-server 127.0.0.1:6379 |
4.설정파일
1 2 3 |
# vi /etc/redis.conf |
4.1모든 아이피 허용
1 2 3 4 |
#bind 127.0.0.1 bind 0.0.0.0 |
4.2포트변경
1 2 3 4 |
#port 6379 port 19876 |
4.3접속Password 설정
1 2 3 |
requirepass pas232332 |
4.4잘되는지 확인
1 2 3 4 |
redis-cli ping PONG |
4.5 redis-server 기타 정보 확인
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 |
[root@localhost ~]# redis-server 1786:C 09 Aug 2022 16:33:53.917 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 1786:C 09 Aug 2022 16:33:53.917 # Redis version=7.0.2, bits=64, commit=00000000, modified=0, pid=1786, just started 1786:C 09 Aug 2022 16:33:53.917 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 1786:M 09 Aug 2022 16:33:53.918 * Increased maximum number of open files to 10032 (it was originally set to 1024). 1786:M 09 Aug 2022 16:33:53.918 * monotonic clock: POSIX clock_gettime _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 7.0.2 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 1786 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | https://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 1786:M 09 Aug 2022 16:33:53.920 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 1786:M 09 Aug 2022 16:33:53.920 # Server initialized 1786:M 09 Aug 2022 16:33:53.920 * Ready to accept connections |
4.6 redis-server 낮은버전으로 설치된 경우
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# redis-server 21785:C 11 Aug 15:24:56.659 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 21785:M 11 Aug 15:24:56.660 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 3.2.12 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 21785 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' |
4.7 EPEL 및 YUM Utilities 패키지 설치 후 redis 다시 설치
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# yum remove redis # yum install -y epel-release yum-utils # yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm # yum-config-manager --enable remi # yum info redis | egrep 'Name|Arch|Version' Name : redis Arch : x86_64 Version : 7.0.4 # yum install redis |
5. 로컬에 접속
1 2 3 4 |
# redis-cli 127.0.0.1:6379> |
5.0 호스트, 포트, 비빈으로 접속
1 2 3 4 5 |
[root@localhost ~]# redis-cli -h 127.0.0.1 -p 19876 -a pas232332 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:19876> |
5.2 한글 안깨지게 호스트, 포트, 비빈으로 접속
1 2 3 4 5 |
[root@localhost ~]# redis-cli --raw -h 127.0.0.1 -p 19876 -a pas232332 Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe. 127.0.0.1:19876> |
5.3 데이타 넣기
1 2 3 |
127.0.0.1:6379> set 5 "five" |
5.4 데이타 보기
1 2 3 4 |
127.0.0.1:6379> get 5 "five" |
6. Command 에서 바로 넣고 보기
1 2 3 4 5 6 |
[root@localhost ~]# redis-cli --raw set "KR" "한글" OK [root@localhost ~]# redis-cli --raw get "KR" 한글 |