安装Redis报错:undefined reference to `__sync_add_and_fetch_4'
2016-07-22 11:19
543 查看
在VMware的Linux系统上安装Redis
具体过程如下:
下载,解压和编译:
Shell代码
$ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
$ tar xzf redis-2.6.14.tar.gz
$ cd redis-2.6.14
$ make
在执行make的时候报错,具体报错信息如下:
Shell代码
zmalloc.o: In function `zmalloc_used_memory':
/usr/local/redis-2.6.14/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/usr/local/redis-2.6.14/src'
make: *** [all] Error 2
网上查了下资料,主要是因为我的linux是32位的,所以会报这个错,解决方案如下:
在make操作的时候加一个执行参数:make CFLAGS="-march=i686"
然后就不报错了。
附:启动并运行Redis
编译的可执行文件在src目录中,使用以下命令运行Redis:
Shell代码
[root@localhost redis-2.6.14]# src/redis-server
启动成功后控制台打印如下信息:
Shell代码
[2918] 03 Jul 09:05:01.011 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
[2918] 03 Jul 09:05:01.017 * Max number of open files set to 10032
[2918] 03 Jul 09:05:01.024 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.14 (00000000/0) 32 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 2918
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[2918] 03 Jul 09:05:01.029 # Server started, Redis version 2.6.14
[2918] 03 Jul 09:05:01.030 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[2918] 03 Jul 09:05:01.030 * The server is now ready to accept connections on port 6379
我们可以使用内置的客户端来连接Redis
Shell代码
[root@localhost redis-2.6.14]# src/redis-cli
redis 127.0.0.1:6379> set name chenzhou
OK
redis 127.0.0.1:6379> get name
"chenzhou"
redis 127.0.0.1:6379>
附2:把Redis作为Linux服务开机启动
这里只提供一种最简单的方式,最好的是通过编写开机启动脚本来做。
如果要开机启动redis,我们需要把redis设置为daemon后台启动(如果不设置为后台启动,则linux启动后图形界面会卡在一个空白的页面),而redis只有1个启动参数,就是redis的配置文件路径。redis的默认配置文件redis.conf位于redis的安装目录下。我们可以把该文件copy到/etc目录下
Shell代码
[root@localhost redis-2.6.14]# cp redis.conf /etc/
redis的默认配置文件中daemonize参数的值为no,代表为非后台启动,所以我们需要把该参数的值修改为yes。至于其它的参数在这里就不详细说了,具体可以参见:http://blog.csdn.net/htofly/article/details/7686436
修改完daemonize参数之后,redis就能够通过daemon方式启动了,那么下一步就是把redis加入到linux开机启动服务配置中了,具体步骤如下:
使用VI编辑器打开Linux开机启动服务配置文件/etc/rc.local,并在其中加入下面的一行代码:
Shell代码
/usr/local/redis-2.6.14/src/redis-server /etc/redis.conf
编辑完后保存,然后重启系统就OK了。
停止Redis服务:
Shell代码
src/redis-cli shutdown
具体过程如下:
下载,解压和编译:
Shell代码
$ wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
$ tar xzf redis-2.6.14.tar.gz
$ cd redis-2.6.14
$ make
在执行make的时候报错,具体报错信息如下:
Shell代码
zmalloc.o: In function `zmalloc_used_memory':
/usr/local/redis-2.6.14/src/zmalloc.c:223: undefined reference to `__sync_add_and_fetch_4'
collect2: ld returned 1 exit status
make[1]: *** [redis-server] Error 1
make[1]: Leaving directory `/usr/local/redis-2.6.14/src'
make: *** [all] Error 2
网上查了下资料,主要是因为我的linux是32位的,所以会报这个错,解决方案如下:
在make操作的时候加一个执行参数:make CFLAGS="-march=i686"
然后就不报错了。
附:启动并运行Redis
编译的可执行文件在src目录中,使用以下命令运行Redis:
Shell代码
[root@localhost redis-2.6.14]# src/redis-server
启动成功后控制台打印如下信息:
Shell代码
[2918] 03 Jul 09:05:01.011 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
[2918] 03 Jul 09:05:01.017 * Max number of open files set to 10032
[2918] 03 Jul 09:05:01.024 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.6.14 (00000000/0) 32 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 2918
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[2918] 03 Jul 09:05:01.029 # Server started, Redis version 2.6.14
[2918] 03 Jul 09:05:01.030 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
[2918] 03 Jul 09:05:01.030 * The server is now ready to accept connections on port 6379
我们可以使用内置的客户端来连接Redis
Shell代码
[root@localhost redis-2.6.14]# src/redis-cli
redis 127.0.0.1:6379> set name chenzhou
OK
redis 127.0.0.1:6379> get name
"chenzhou"
redis 127.0.0.1:6379>
附2:把Redis作为Linux服务开机启动
这里只提供一种最简单的方式,最好的是通过编写开机启动脚本来做。
如果要开机启动redis,我们需要把redis设置为daemon后台启动(如果不设置为后台启动,则linux启动后图形界面会卡在一个空白的页面),而redis只有1个启动参数,就是redis的配置文件路径。redis的默认配置文件redis.conf位于redis的安装目录下。我们可以把该文件copy到/etc目录下
Shell代码
[root@localhost redis-2.6.14]# cp redis.conf /etc/
redis的默认配置文件中daemonize参数的值为no,代表为非后台启动,所以我们需要把该参数的值修改为yes。至于其它的参数在这里就不详细说了,具体可以参见:http://blog.csdn.net/htofly/article/details/7686436
修改完daemonize参数之后,redis就能够通过daemon方式启动了,那么下一步就是把redis加入到linux开机启动服务配置中了,具体步骤如下:
使用VI编辑器打开Linux开机启动服务配置文件/etc/rc.local,并在其中加入下面的一行代码:
Shell代码
/usr/local/redis-2.6.14/src/redis-server /etc/redis.conf
编辑完后保存,然后重启系统就OK了。
停止Redis服务:
Shell代码
src/redis-cli shutdown
相关文章推荐
- redis 配置
- redis - java 基本操作
- 非关系型数据库mongodb和redis
- Redis增删改查示例
- Redis内存使用优化与存储
- Python模拟进行Mysql和Redis数据传输总结
- Python定时从Mysql提取数据存入Redis
- Redis3.2.1分布式集群搭建(非单机版本)
- redis 3.0的集群部署
- redis 操作记录
- redis的相关知识
- service redis does not support chkconfig的解决办法
- 测试redis+keepalived实现简单的主备切换【转载】
- [李景山php]thinkphp核心源码注释|Redis.class.php
- [李景山php]每天laravel-20160921|Redis Database.php
- [李景山php]每天laravel-20160921|Redis Database.php
- redis 基础
- redis 安装
- 30个php操作redis常用方法代码例子
- mac 安装redis