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

CentOS_6.5 install Redis_3.0.2

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

1. Install dependency packages and development tools:

Yum install vim vim-enhanced wget zip unzip telnet ntsysv compat* apr* nasm* gcc gcc* gcc-c++ ntp make imake cmake automake autoconf zlib zlib-devel glibc glibc-devel glib2 libxml glib2-devel libxml2 libxml2-devel bzip2 bzip2-devel libXpm libXpm-devel libidn libidn-devel libtool libtool-ltdl-devel* libmcrypt libmcrypt-devel libevent-devel libmcrypt* curl curl-devel perl perl-Net-SSLeay pcre pcre-devel ncurses ncurses-devel openssl openssl-devel openldap openldap-devel openldap-clients openldap-servers krb5 krb5-devel e2fsprogs e2fsprogs-devel libjpeg libpng libjpeg-devel libjpeg -6b libjpeg-devel-6b libpng-devel libtiff-devel freetype freetype-devel fontconfig-devel gd gd-devel kernel screen sysstat flex bison nss_ldap pam-devel compat-libstdc++-33

two。

3. Download wget http://download.redis.io/releases/redis-3.0.2.tar.gz

two。 Extract, compile, and install redis-3.0:

Tar zxvf redis-3.0.2.tar.gz-C / usr/src/

Cd / usr/src/redis-3.0.2/

Make & & make install

3. Create redis related directories:

Mkdir-p / home/redis/log

Mkdir-p / home/redis/pid

Mkdir-p / home/redis/db

4. Edit the redis.conf configuration file:

Cp redis.conf / etc/redis.conf

Vim / etc/redis.conf

Daemonize yes

Pidfile / home/redis/pid/redis.pid

Port 6379

Tcp-backlog 511

Timeout 600

Tcp-keepalive 0

Loglevel notice

Logfile / home/redis/log/redis.log

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Rdbcompression yes

Dbfilename dump.rdb

Dir / home/redis/db

Slave-serve-stale-data yes

Appendonly yes

Appendfilename "appendonly.aof"

Appendfsync everysec

No-appendfsync-on-rewrite no

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64mb

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Latency-monitor-threshold 0

Notify-keyspace-events ""

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

Hll-sparse-max-bytes 3000

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

5. Create a redis service script and grant permissions:

Vim / etc/init.d/redis

#! / bin/sh

# chkconfig: 2345 60 40

# Description: Start and Stop redis

# Provides: redis

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

PATH=/usr/local/bin:/sbin:/usr/bin:/bin

REDISPORT=6379

EXEC=/usr/local/bin/redis-server

REDIS_CLI=/usr/local/bin/redis-cli

PIDFILE=/home/redis/pid/redis.pid

CONF= "/ etc/redis.conf"

Case "$1" in

Start)

If [- f $PIDFILE]

Then

Echo "$PIDFILE exists, process is already running or crashed"

Else

Echo "Starting Redis server..."

$EXEC $CONF

Fi

If ["$?" = "0"]

Then

Echo "Redis is running..."

Fi

Stop)

If [!-f $PIDFILE]

Then

Echo "$PIDFILE does not exist, process is not running"

Else

PID=$ (cat $PIDFILE)

Echo "Stopping Redis server..."

$REDIS_CLI-p $REDISPORT SHUTDOWN

While [- x ${PIDFILE}]

Do

Echo "Waiting for Redis to shutdown..."

Sleep 1

Done

Echo "Redis is stopped"

Fi

Restart | force-reload)

${0} stop

${0} start

*)

Echo "Usage: / etc/init.d/redis {start | stop | restart | force-reload}" > & 2

Exit 1

Esac

6. Add redis service boot startup:

Chmod axix / etc/init.d/redis

Chkconfig-add redis

Chkconfig-level 2345 redis on

Chkconfig-- list | grep redis

7. Start the redis service:

Service redis start

Ps-aux | grep redis

Netstat-anptu | grep 6379

8. Firewall enables port 6379:

Iptables-An INPUT-p tcp-- dport 6379-j ACCEPT

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

Network Security

Wechat

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

12
Report