Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Suse11 installation Test redis

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Suse11 installation Test redis

First, download and install the latest source package of redis

Wget http://redis.googlecode.com/files/redis-2.6.13.tar.gz

-- 2013-05-12 18 09 Fran 57-http://redis.googlecode.com/files/redis-2.6.13.tar.gz

Resolving redis.googlecode.com... 173.194.72.82, 2404:6800:4008:c00::52

Connecting to redis.googlecode.com | 173.194.72.82 |: 80. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 994331 (971K) [application/x-gzip]

Saving to: `redis-2.6.13.tar.gz'

994331 3.26M/s in 0.3s

2013-05-12 18:09:57 (3.26 MB/s)-`994331 [994331 MB/s]

SLES11-108:~/nosql # tar zxvf redis-2.6.13.tar.gz

SLES11-108:~/nosql # cd redis-2.6.13/

Make

CC sentinel.o

LINK redis-server

INSTALL redis-sentinel

CC redis-cli.o

LINK redis-cli

CC redis-benchmark.o

LINK redis-benchmark

CC redis-check-dump.o

LINK redis-check-dump

CC redis-check-aof.o

LINK redis-check-aof

Hint: To run 'make test' is a good idea;)

SLES11-108:~/nosql/redis-2.6.13/src # cp redis-server / usr/local/bin/

SLES11-108:~/nosql/redis-2.6.13/src # cp redis-cli / usr/local/bin/

SLES11-108:~/nosql/redis-2.6.13/src # cp.. / redis.conf / etc/

SLES11-108:~/nosql/redis-2.6.13/src #

Daemonize yesSLES11-108:/etc # cat / etc/redis.conf | grep-Ev "^ # | ^ $"

Pidfile / var/run/redis.pid

Port 6379

Timeout 0

Tcp-keepalive 0

Loglevel notice

Logfile stdout

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error yes

Rdbcompression yes

Rdbchecksum yes

Dbfilename dump.rdb

Dir. /

Slave-serve-stale-data yes

Slave-read-only yes

Repl-disable-tcp-nodelay no

Slave-priority 100

Appendonly no

Appendfsync everysec

No-appendfsync-on-rewrite no

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64mb

Lua-time-limit 5000

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-entries 512

List-max-ziplist-value 64

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Activerehashing yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 256mb 64mb 60

Client-output-buffer-limit pubsub 32mb 8mb 60

Hz 10

Aof-rewrite-incremental-fsync yes

Second, start redis

SLES11-108:/etc # ps-ef | grep redis

Root 23801 1 0 18:16? 00:00:00 redis-server / etc/redis.conf

Root 23805 21983 0 18:17 pts/0 00:00:00 grep redis

SLES11-108:/etc # netstat-tplun | grep 6379

Tcp 0 0 0.0.0.0 6379 0.0.0.015 * LISTEN 23801/redis-server

SLES11-108:/etc #

Third, test redis (test list type data)

SLES11-108 ~ # redis-cli

Redis 127.0.0.1 purl 6379 >

Redis 127.0.0.1 help 6379 > help set # View the help parameters and precede the command with help

SET key value

Summary: Set the string value of a key

Since: 1.0.0

Group: string

Redis 127.0.0.1 set 6379 > help @ set # if you want to see all commands of one type plus @

SADD key member [member...]

Summary: Add one or more members to a set

Since: 1.0.0

SCARD key

Summary: Get the number of members in a set

Since: 1.0.0

SDIFF key [key...]

Summary: Subtract multiple sets

Since: 1.0.0

...

Subsequent omission

Redis 127.0.1 List 6379 > lpush test a b c # this command creates the key and the List associated with it, and then inserts the values in the parameter from left to right.

(integer) 3

Redis 127.0.0.1 6379 > lrange test 0-1 # fetches all the elements in the linked list, where 0 represents the first element and-1 represents the last element.

1) "c"

2) "b"

3) "a"

The key value is not found in the redis 127.0.0.1 6379 > lpushx test1 d # library and is shown as 0.

(integer) 0

This key value is available in the redis 127.0.0.1 6379 > lpushx test d # library and the d just added is added.

(integer) 4

Redis 127.0.0.1 6379 > lrange test1

(error) ERR wrong number of arguments for 'lrange' command

Redis 127.0.0.1 6379 > lrange test1 0-1

(empty list or set)

Redis 127.0.0.1 6379 > lrange test 0-1

1) "d"

2) "c"

3) "b"

4) "a"

Redis 127.0.0.1 purl 6379 >

Fourth, download and install the python connection redis module

SLES11-108:~/nosql # wget https://pypi.python.org/packages/source/r/redis/redis-2.7.4.tar.gz

-- 2013-05-12 18-18-18-18-- 18

Resolving pypi.python.org... 140.211.10.69

Connecting to pypi.python.org | 140.211.10.69 |: 443. Connected.

HTTP request sent, awaiting response... 200 OK

Length: 79715 (78K) [application/octet-stream]

Saving to: `redis-2.7.4.tar.gz'

79715 183K/s in 0.4s

-05-12 18:18:59 (2013 KB/s)-`redis-2.7.4.tar.gz' saved [79715ax 79715]

SLES11-108:~/nosql/redis-2.7.4 # python setup.py install

/ usr/lib64/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'test_suite'

Warnings.warn (msg)

Running install

Running build

Running build_py

Creating build

Creating build/lib

Creating build/lib/redis

Copying redis/exceptions.py-> build/lib/redis

Copying redis/_compat.py-> build/lib/redis

Copying redis/connection.py-> build/lib/redis

Copying redis/client.py-> build/lib/redis

Copying redis/__init__.py-> build/lib/redis

Copying redis/utils.py-> build/lib/redis

Running install_lib

Creating / usr/local/lib64/python2.6

Creating / usr/local/lib64/python2.6/site-packages

Creating / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/exceptions.py-> / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/_compat.py-> / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/connection.py-> / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/client.py-> / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/__init__.py-> / usr/local/lib64/python2.6/site-packages/redis

Copying build/lib/redis/utils.py-> / usr/local/lib64/python2.6/site-packages/redis

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/exceptions.py to exceptions.pyc

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/_compat.py to _ compat.pyc

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/connection.py to connection.pyc

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/client.py to client.pyc

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/__init__.py to _ _ init__.pyc

Byte-compiling / usr/local/lib64/python2.6/site-packages/redis/utils.py to utils.pyc

Running install_egg_info

Writing / usr/local/lib64/python2.6/site-packages/redis-2.7.4-py2.6.egg-info

Fifth, simply test python to connect to redis

SLES11-108:~/nosql/redis-2.7.4 # python

Python 2.6 (r26 66714, Feb 2 2012, 16:59:44)

[GCC 4.3.4 [gcc-4_3-branch revision 152973]] on linux2

Type "help", "copyright", "credits" or "license" for more information.

> > >

> import redis

> a = redis.testredis (host='localhost',port=6379,db=0)

Traceback (most recent call last):

File "", line 1, in

AttributeError: 'module' object has no attribute' testredis'

> a = redis.Redis (host='localhost',port=6379,db=0)

> a.set ('test','abc') # sets a key of string type named test, and the content is abc

True

> a.get ('test') # displays the contents of the test

'abc'

> a.dbsize () # check how much data is in the database

1L

> a.get ('test1') # get is empty if it is not in a library.

> a.delete ('test') # delete

True

>

0L

> a.exists ('test') # determines whether the key of this name exists, because it has just been deleted and is empty

False

> a.set ('mykey','cde') # add a new key with mykey name

True

>

True

> a.keys () # View the list of key in Curry

['mykey']

> quit () # exit

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report