六、验证
1、运行-cmd
Ping 10.25.174.200 看是否能够ping通
2、 运行-cmd
telnet 10.25.174.200 6379 是否能通
3、 使用sshclient连接至121或者122,使用root用户
cd /usr/local/ms40/redis/redis-2.6.14
src/redis-cli –h 10.25.174.200
set name “test”
get name
看看结果是否为test
如果是则 del test
六、安装Redis过程中涉及的一些问题 1、GCC的问题
make[2]: cc: Command not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/usr/local/redis-2.6.16/src'
make: *** [all] Error 2 原因:没安装gcc,执行命令安装:yum install gcc-c++ 2、内存分配器的问题(重视)
make[1]: Entering directory `/usr/local/redis-2.6.16/src'
CC adlist.o
In file included from adlist.c:34:
zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error "Newer version of jemalloc required"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/usr/local/redis-2.6.16/src'
make: *** [all] Error 2 原因:查看redis的源码 src/zmalloc.c可以看到如下代码: #if defined(USE_TCMALLOC) #define malloc(size) tc_malloc(size) #define calloc(count,size) tc_calloc(count,size) #define realloc(ptr,size) tc_realloc(ptr,size) #define free(ptr) tc_free(ptr) #elif defined(USE_JEMALLOC) #define malloc(size) je_malloc(size) #define calloc(count,size) je_calloc(count,size) #define realloc(ptr,size) je_realloc(ptr,size) #define free(ptr) je_free(ptr)
可以看到源码中首先会判断系统中是否存在tcmalloc内存分配器,如果没有,则使用jemalloc内存分配器,如果连jemalloc分配器也没有找到,就会报错了。
本次现网部署Redis后,因为没有jemalloc分配器,导致碎片率达到了1.59,redis的内存占用率也就是实际内存占用的1.59倍,这个数据量是非常恐怖的,对内存资源是个相当大的损耗。
在现网环境的linux系统中,可能没有预先安装Jemalloc分配器,需要手动安装。
1、wget http://www.canonware.com/download/jemalloc/jemalloc-3.2.0.tar.bz2
2、tar jxf jemalloc-3.2.0.tar.bz2 (tar.bz2的压缩格式使用 tar jxf 解压)
3、cd jemalloc-3.2.0
4、./configure
5、make && make install
6、ldconfig
过程完成后,在切回到redis-2.6.14目录中,重新执行make命令
当然如果不想使用jemalloc分配器,可以强制使用如下命令来安装redis:
make MALLOC=libc (libc是默认的内存分配器,不过经过验证,碎片率是最高的)
七、安装Keepalived过程中涉及的一些问题 1、虚拟网卡sit0的问题
Keepalived安装完成后,在启动时报了如下的异常:
Oct 18 00:24:43 localhost Keepalived[6866]: Starting VRRP child process, pid=6868
Oct 18 00:24:43 localhost Keepalived_vrrp[6868]: No such interface, sit0
使用ip a命令查看网卡信息如下:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:50:56:ba:67:6e brd ff:ff:ff:ff:ff:ff
inet 10.25.174.122/24 brd 10.25.174.255 scope global eth0
inet6 fe80::250:56ff:feba:676e/64 scope link
valid_lft forever preferred_lft forever
3: sit0: <NOARP> mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0
网上对于sit0的描述如下:
SIT是IPv6-in-IPv4 tunnel interfaces, 这个interfaces(界面或是接口)也称作sitx, sit是"Simple Internet Transition"的缩写. 它可以将IPv6的数据包塞进IPv4, 通过IPv4到达另一个地点.sit0 不能使用在专用的tunnels 上.
一般它没有什么用, 还会减慢上网的速度, 可以修改
在/etc/modprobe.conf文件增加如下两行配置:
alias ipv6 off
alias net-pf-10 off
然后reboot重启服务器 2、nc命令的问题
家里测试环境(79.78、79.79)没有nc命令(类似windows下的telnet)
1) wget http://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz/download
2) tar zxvf netcat-0.7.1.tar.gz
3) ./configure
4) make && make install