Redis [Snippet] Redis 32bit compiling problem on ubuntu 13.04

Redis logo

root@ubuntu-1303-amd64:/home/adminuser/redis-2.6.7# make 32bit
cd src && make 32bit
make[1]: Entering directory `/home/adminuser/redis-2.6.7/src’

WARNING: if it fails under Linux you probably need to install libc6-dev-i386

make CFLAGS=”-m32″ LDFLAGS=”-m32″
make[2]: Entering directory `/home/adminuser/redis-2.6.7/src’
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[3]: Entering directory `/home/adminuser/redis-2.6.7/deps’
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[3]: Leaving directory `/home/adminuser/redis-2.6.7/deps’
(rm -f .make-*)
echo STD=-std=c99 -pedantic >> .make-settings
echo WARN=-Wall >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS=-m32 >> .make-settings
echo LDFLAGS=-m32 >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -Wall -O2 -g -rdynamic -ggdb -m32 -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS=-m32 -g -rdynamic -ggdb >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[3]: Entering directory `/home/adminuser/redis-2.6.7/deps’
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo “-m32” > .make-ldflags)
(echo “-m32” > .make-cflags)
MAKE hiredis
cd hiredis && make static
make[4]: Entering directory `/home/adminuser/redis-2.6.7/deps/hiredis’
cc -std=c99 -pedantic -c -O3 -fPIC -m32 -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
net.c:34:23: fatal error: sys/types.h: No such file or directory
compilation terminated.
make[4]: *** [net.o] Error 1
make[4]: Leaving directory `/home/adminuser/redis-2.6.7/deps/hiredis’
make[3]: *** [hiredis] Error 2
make[3]: Leaving directory `/home/adminuser/redis-2.6.7/deps’
make[2]: [persist-settings] Error 2 (ignored)
CC adlist.o
In file included from /usr/include/features.h:341:0,
from /usr/include/stdlib.h:24,
from adlist.c:32:
/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make[2]: *** [adlist.o] Error 1
make[2]: Leaving directory `/home/adminuser/redis-2.6.7/src’
make[1]: *** [32bit] Error 2
make[1]: Leaving directory `/home/adminuser/redis-2.6.7/src’
make: *** [32bit] Error 2
root@ubuntu-1303-amd64:/home/adminuser/redis-2.6.7# make
cd src && make all
make[1]: Entering directory `/home/adminuser/redis-2.6.7/src’
CC adlist.o
In file included from /usr/include/features.h:341:0,
from /usr/include/stdlib.h:24,
from adlist.c:32:
/usr/include/stdc-predef.h:30:26: fatal error: bits/predefs.h: No such file or directory
compilation terminated.
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/home/adminuser/redis-2.6.7/src’
make: *** [all] Error 2

If got error like me, just type this command, apt-get install libc6-dev-i386 . And now redis ready to use.

Advertisements

Redis [Snippet] Redis compiling problem on ubuntu 10.04 32bit

cd hiredis && make static
make[3]: Entering directory `/home/project/redis/redis-2.6.4/deps/hiredis’
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[3]: gcc: Command not found
make[3]: *** [net.o] Error 127
make[3]: Leaving directory `/home/project/redis/redis-2.6.4/deps/hiredis’
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory `/home/project/redis/redis-2.6.4/deps’
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
/bin/sh: cc: not found
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory `/home/project/redis/redis-2.6.4/src’
make: *** [all] Error 2

That’s mean no gcc installed, so just type this command, apt-get install gcc

And then when I tried to make again, I’m encounter this problem.

root@vx-ubu:/home/project/redis/redis-2.6.4# make
cd src && make all
make[1]: Entering directory `/home/project/redis/redis-2.6.4/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 `/home/project/redis/redis-2.6.4/src’
make: *** [all] Error 2

All You have to do is type this command make distclean. And now, redis-2.6.4 is ready to use.

Python [snippet/problem] : Kill process via python, script won’t continue

Have You wondering, how to kill process in Your linux machine and restart it again? I have some problem with it, let’s see the first code now.

#usr/bin/python
import os, time

sleepTime = 3

''' STEP 1 - Kill Stream '''
text = 'TwitterStreamEncode'
#execute = 'kill -9 `ps -ef | grep %s | grep -v grep | awk \'{print $2}\'`' % sys.argv[1] # ==> Note 1
execute = 'kill -9 `ps -ef | grep %s | grep -v grep | awk \'{print $2}\'`' % text # ==> Note 2
print execute
cmdKill  = os.system(execute)

''' STEP 2 - Give sleep to make sure process is killed '''
print "Sleeping for %s sec\n" % sleepTime
time.sleep(sleepTime)

Here’s the command to start my test

root@fajri-laptop : ~# nohup /usr/bin/php /home/project/MW/TwitterStreamEncode.php > /dev/null &
[1] 28435
root@fajri-laptop : ~# nohup: ignoring input and redirecting stderr to stdout
^C
root@fajri-laptop : ~# ps -ef | grep Twitter
root     28435 28424  2 21:13 pts/1    00:00:00 /usr/bin/php /home/project/MW/TwitterStreamEncode.php
root     28438 28424  0 21:13 pts/1    00:00:00 grep --color=auto Twitter

You can see, the process is starting with PID 28435
Then I’m execute it like usual, python try_kill.py

root@vx662-sekremm:/home/project/MW# python try_kill.py
kill -9 `ps -ef | grep TwitterStreamEncode | grep -v grep | awk '{print $2}'`
Sleeping for 3 sec

root@fajri-laptop : ~# ps -ef | grep Twitter
root     28451 28424  0 21:16 pts/1    00:00:00 grep --color=auto Twitter
[1]+  Killed                  nohup /usr/bin/php /home/project/MW/TwitterStreamEncode.php > /dev/null

You can see, the first script is fine, the process is killed.

But, I want to make it simpler, myscript able to receive parameter via command line, like python try_kill.py TwitterStreamEncode, so it will find the process, and kill it.
So I change my code to Note 1 #execute = 'kill -9 `ps -ef | grep %s | grep -v grep | awk \'{print $2}\'`' % sys.argv[1] , and here’s the output.

root@fajri-laptop : ~# nohup /usr/bin/php /home/project/MW/TwitterStreamEncode.php > /dev/null &
[1] 28473
root@fajri-laptop : ~# nohup: ignoring input and redirecting stderr to stdout
^C

root@fajri-laptop : ~# ps -ef | grep Twitter
root     28473 28424  5 21:20 pts/1    00:00:00 /usr/bin/php /home/project/MW/TwitterStreamEncode.php
root     28476 28424  0 21:20 pts/1    00:00:00 grep --color=auto Twitter

root@vx662-sekremm:/home/project/MW# python try_kill.py TwitterStreamEncode
kill -9 `ps -ef | grep TwitterStreamEncode | grep -v grep | awk '{print $2}'`
Killed

root@fajri-laptop : ~# ps -ef | grep Twitter
root     28485 28424  0 21:22 pts/1    00:00:00 grep --color=auto Twitter
[1]+  Killed                  nohup /usr/bin/php /home/project/MW/TwitterStreamEncode.php > /dev/null

You can see, my script won’t continue after it execute os.system
I’m still don’t know why this is happened 😦

Redis [Snippet] PHP Redis compiling on centos 6.2 64bit

I have some error when try to compile PHP Redis on Centos 6.2 64bit. There is a little difference between ubuntu & centos php configuration. So, here’s the step to solve it

  1. download this file (nicolasff-phpredis-2.2.1-63-gf3dff08.zip)
  2. unzip nicolasff-phpredis-2.2.1-63-gf3dff08.zip
  3. cd nicolasff-phpredis-f3dff08
  4. yum install php-devel –enablerepo=remi
  5. phpize
  6. ./configure
  7. make && make install
  8. vim /etc/php.d/redis.ini
  9. extension=redis.so #insert to redis.ini file

Redis [Snippet] Redis compiling problem on centos 6.2 64bit

[root@wave3 redis-2.4.17]# make
cd src && make all
make[1]: Entering directory `/home/source/redis/redis-2.4.17/src’
MAKE hiredis
make[2]: Entering directory `/home/source/redis/redis-2.4.17/deps/hiredis’
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[2]: gcc: Command not found
make[2]: *** [net.o] Error 127
make[2]: Leaving directory `/home/source/redis/redis-2.4.17/deps/hiredis’
make[1]: *** [dependencies] Error 2
make[1]: Leaving directory `/home/source/redis/redis-2.4.17/src’
make: *** [all] Error 2

I have that Error when try to compile Redis 2.4.17 on Centos 6.2 64bit, after some googling it’s solved. Here’s how to solved it.

yum install glibc-devel.x86_64
yum install glibc.i686
yum install gcc.x86_64