[] CentOS 7 installation environment to build Redis

1, the compiler is installed

yum -y install gcc

2, compiled and start

wget http://download.redis.io/releases/redis-4.0.6.tar.gz
tar -xf redis-4.0.6.tar.gz
cd redis-4.0.6
make MALLOC=libc
cd src && make install
src/redis-server # 启动redis

3, the configuration file

redis.conf
  daemonize yes # yes为后台进程,no为前台进程
  requirepass 123456 # 修改密码
  bind 0.0.0.0 # 任意IP访问

Start the specified configuration file src / redis-server /root/redis-4.0.6/redis.conf

2, runs
1 to start the server

src/redis-server redis.conf # 启动指定配置文件

2, shut down

ps -aux | grep redis
kill -9 redis的PID

3, connection configuration
3.1 Firewall Settings

firewall-cmd --zone=public --add-port=6378/tcp --permanent
firewall-cmd --zone=public --add-port=6379/tcp --permanent

3.2 client connections

src/redis-cli -h 127.0.0.1 -p 6379 -a '123456'
127.0.0.1:6379> ping
PONG # 返回值PONG,连接成功
127.0.0.1:6379> set a b # 设置key value
OK
127.0.0.1:6379> get a # 获取key的value
"b"
127.0.0.1:6379> exit # 退出服务端

3.3 windows client connections

C:\Users\RoseC>redis-cli -h 192.168.35.110 -p 6379
192.168.35.110:6379> auth "123456"
OK
192.168.35.110:6379> ping
PONG
192.168.35.110:6379> get aa
"bb"
192.168.35.110:6379> exit

4, python connected
4.1 installer

pip install redis
pip install redis-py-cluster

4.2 Code

He published 192 original articles · won praise 18 · views 80000 +

Guess you like

Origin blog.csdn.net/luolinll1212/article/details/103955484