1、安装tcl8.6
tcl官网:http://www.linuxfromscratch.org/blfs/view/cvs/general/tcl.html
可以从官网获取tcl的最新版本,官网也有详细的安装步骤
- # wget http://downloads.sourceforge.net/tcl/tcl8.6.0-src.tar.gz
- # tar xf tcl8.6.0-src.tar.gz
- # cd tcl8.6.0/unix/
- # ./configure --prefix=/usr \
- --mandir=/usr/share/man \
- $([ $(uname -m) = x86_64 ] && echo --enable-64bit) &&
- make &&
- sed -e "s@^\(TCL_SRC_DIR='\).*@\1/usr/include'@" \
- -e "/TCL_B/s@='\(-L\)\?.*unix@='\1/usr/lib@" \
- -i tclConfig.sh
- # make test
- # make install && make install-private-headers && ln -v -sf tclsh8.6 /usr/bin/tclsh && chmod -v 755 /usr/lib/libtcl8.6.so
- # tclsh8.6 //有这个命令表示安装成功
2、安装redis
redis官网:http://redis.io/
- # tar xf redis-2.6.2.tar.gz
- # cd redis-2.6.2
- # make
- # make test
- # make install
- # cp redis.conf /etc/
- # vi /etc/sysctl.conf //如果已经配置过这里了,可以忽略,如果没有,一定要配置 vm.overcommit_memory = 1
- # redis-server /etc/redis.conf
- # netstat -nutlp | grep 6379 | grep -v grep //看到以下表示redis启动成功
- 6379 0.0.0.0:* LISTEN 14845/xinetd
3、编写Redis的服务管理脚本
# vi /etc/init.d/redis
- #!/bin/bash
- # Init file for redis
- # chkconfig: - 80 12
- # description: redis daemon
- # processname: redis
- # TITLE END
- # Source function library.
- . /etc/rc.d/init.d/functions
- BIN="/usr/local/bin"
- CONFIG="/etc/redis.conf"
- PIDFILE="/var/run/redis.pid"
- prog="redis-server"
- desc="Redis Server"
- start() {
- if [ -e $PIDFILE ];then
- echo "$desc already running...."
- exit 1
- fi
- echo -n $"Starting $desc: "
- daemon $BIN/$prog $CONFIG
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
- return $RETVAL
- }
- stop() {
- echo -n $"Stop $desc: "
- killproc $prog
- RETVAL=$?
- echo
- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog $PIDFILE
- return $RETVAL
- }
- restart() {
- stop
- start
- }
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart)
- restart
- ;;
- status)
- status $prog
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|condrestart|status}"
- RETVAL=1
- esac
- exit $RETVAL
4、设置Redis开机启动
- # chmod 755 /etc/init.d/redis
- # chkconfig --add redis
- # chkconfig --level 345 redis on
- # chkconfig --list redis
5、Redis的日志配置
redis默认会把日志打印到屏幕上,并且不是以daemon的模式运行,可以改下配置文件
- # vi /etc/redis.conf
- #daemonize no //默认为no,注释掉,新增一行改为yes
- daemonize yes
- # Set server verbosity to 'debug'
- # it can be one of:
- # debug (a lot of information, useful for development/testing)
- # verbose (many rarely useful info, but not a mess like the debug level)
- # notice (moderately verbose, what you want in production probably)
- # warning (only very important / critical messages are logged)
- loglevel notice //这里定义日志的级别,默认为notice
- #logfile stdout //这里指定Redis的日志文件位置
- logfile /var/log/redis.log
配置完成后,重启下Redis,看一下Redis的日志吧
- [root@node3 ~]# cat /var/log/redis.log
- [3779] 07 Apr 12:23:42.340 * Max number of open files set to 10032
- _._
- _.-``__ ''-._
- _.-`` `. `_. ''-._ Redis 2.6.2 (00000000/0) 64 bit
- .-`` .-```. ```\/ _.,_ ''-._
- ( ' , .-` | `, ) Running in stand alone mode
- |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
- | `-._ `._ / _.-' | PID: 3779
- `-._ `-._ `-./ _.-' _.-'
- |`-._`-._ `-.__.-' _.-'_.-'|
- | `-._`-._ _.-'_.-' | http://redis.io
- `-._ `-._`-.__.-'_.-' _.-'
- |`-._`-._ `-.__.-' _.-'_.-'|
- | `-._`-._ _.-'_.-' |
- `-._ `-._`-.__.-'_.-' _.-'
- `-._ `-.__.-' _.-'
- `-._ _.-'
- `-.__.-'
- [3779] 07 Apr 12:23:42.344 # Server started, Redis version 2.6.2
- [3779] 07 Apr 12:23:42.344 * The server is now ready to accept connections on port 6379
OK,到此基本配置已经配置完成
6、Redis的状态信息
Redis有一个命令,可以查看当前redis的状态信息,非常的全面
运行redis-cli info
- [root@node3 ~]# redis-cli info
- # Server
- redis_version:2.6.2
- redis_git_sha1:00000000
- redis_git_dirty:0
- redis_mode:standalone
- os:Linux 2.6.32-358.el6.x86_64 x86_64
- arch_bits:64
- multiplexing_api:epoll
- gcc_version:4.4.7
- process_id:4034
- run_id:f9500377d415b0a5912c45e12100c074768d5c41
- tcp_port:6379
- uptime_in_seconds:5
- uptime_in_days:0
- lru_clock:216250
- # Clients
- connected_clients:1
- client_longest_output_list:0
- client_biggest_input_buf:0
- blocked_clients:0
- # Memory
- used_memory:846336
- used_memory_human:826.50K
- used_memory_rss:2015232
- used_memory_peak:787864
- used_memory_peak_human:769.40K
- used_memory_lua:31744
- mem_fragmentation_ratio:2.38
- mem_allocator:jemalloc-3.0.0
- # Persistence
- loading:0
- rdb_changes_since_last_save:0
- rdb_bgsave_in_progress:0
- rdb_last_save_time:1365311304
- rdb_last_bgsave_status:ok
- rdb_last_bgsave_time_sec:-1
- rdb_current_bgsave_time_sec:-1
- aof_enabled:0
- aof_rewrite_in_progress:0
- aof_rewrite_scheduled:0
- aof_last_rewrite_time_sec:-1
- aof_current_rewrite_time_sec:-1
- aof_last_bgrewrite_status:ok
- # Stats
- total_connections_received:1
- total_commands_processed:0
- instantaneous_ops_per_sec:0
- rejected_connections:0
- expired_keys:0
- evicted_keys:0
- keyspace_hits:0
- keyspace_misses:0
- pubsub_channels:0
- pubsub_patterns:0
- latest_fork_usec:0
- # Replication
- role:master
- connected_slaves:0
- # CPU
- used_cpu_sys:0.01
- used_cpu_user:0.01
- used_cpu_sys_children:0.00
- used_cpu_user_children:0.00
- # Keyspace
详细的先不解释了, 等有空再解释吧。
7、安装Redis的WEB管理工具phpRedisAdmin
- # yum install git
- # git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
- # cd phpRedisAdmin
- # git submodule init
- # git submodule update
然后访问
http://youip/phpRedisAdmin