miércoles, 19 de junio de 2019

Install Redis en Ubuntu18.04


Se instala redis server



bext@bext-VPCF13WFX:~$ sudo apt install redis-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libjemalloc1 redis-tools
Suggested packages:
  ruby-redis
The following NEW packages will be installed:
  libjemalloc1 redis-server redis-tools
0 upgraded, 3 newly installed, 0 to remove and 1 not upgraded.
Need to get 634 kB of archives.
After this operation, 3 007 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mx.archive.ubuntu.com/ubuntu bionic/universe amd64 libjemalloc1 amd64 3.6.0-11 [82.4 kB]
Get:2 http://mx.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 redis-tools amd64 5:4.0.9-1ubuntu0.1 [516 kB]
Get:3 http://mx.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 redis-server amd64 5:4.0.9-1ubuntu0.1 [35.4 kB]
Fetched 634 kB in 1s (466 kB/s)           
Selecting previously unselected package libjemalloc1.
(Reading database ... 159985 files and directories currently installed.)
Preparing to unpack .../libjemalloc1_3.6.0-11_amd64.deb ...
Unpacking libjemalloc1 (3.6.0-11) ...
Selecting previously unselected package redis-tools.
Preparing to unpack .../redis-tools_5%3a4.0.9-1ubuntu0.1_amd64.deb ...
Unpacking redis-tools (5:4.0.9-1ubuntu0.1) ...
Selecting previously unselected package redis-server.
Preparing to unpack .../redis-server_5%3a4.0.9-1ubuntu0.1_amd64.deb ...
Unpacking redis-server (5:4.0.9-1ubuntu0.1) ...
Processing triggers for ureadahead (0.100.0-21) ...
ureadahead will be reprofiled on next reboot
Setting up libjemalloc1 (3.6.0-11) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for systemd (237-3ubuntu10.22) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up redis-tools (5:4.0.9-1ubuntu0.1) ...
Setting up redis-server (5:4.0.9-1ubuntu0.1) ...
Created symlink /etc/systemd/system/redis.service → /lib/systemd/system/redis-server.service.
Created symlink /etc/systemd/system/multi-user.target.wants/redis-server.service → /lib/systemd/system/redis-server.service.
Processing triggers for ureadahead (0.100.0-21) ...
Processing triggers for systemd (237-3ubuntu10.22) ...  

Usamos el redis tal cual despues de instalarse, esto es sin modificar si archivo de configuración, (/etc/redis/redis.conf)


Verificamos el estatus del servicio redis

bext@bext-VPCF13WFX:~$ sudo systemctl status redis
 redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor pre
   Active: active (running) since Thu 2019-06-20 18:51:19 CDT; 11s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 4299 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCE
  Process: 4303 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exit
 Main PID: 4304 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/redis-server.service
           └─4304 /usr/bin/redis-server 127.0.0.1:6379

jun 20 18:51:19 bext-VPCF13WFX systemd[1]: Starting Advanced key-value store...
jun 20 18:51:19 bext-VPCF13WFX systemd[1]: redis-server.service: Can't open PID 
jun 20 18:51:19 bext-VPCF13WFX systemd[1]: Started Advanced key-value store.

Se prueba con el cliente redis

bext@bext-VPCF13WFX:~$ redis-cli
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set test "redis server esta funcionando!"
OK
127.0.0.1:6379> get test
"redis server esta funcionando!"
127.0.0.1:6379> exit

Vamos a detener el servicio redis y verificar el estatus

bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo systemctl stop redis
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo systemctl status redis
● redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor pre
   Active: inactive (dead) since Fri 2019-06-21 11:54:10 CDT; 2s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 7075 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCE
 Main PID: 6947 (code=exited, status=0/SUCCESS)

jun 21 11:52:23 bext-VPCF13WFX systemd[1]: Starting Advanced key-value store...
jun 21 11:52:25 bext-VPCF13WFX systemd[1]: redis-server.service: Can't open PID 
jun 21 11:52:25 bext-VPCF13WFX systemd[1]: Started Advanced key-value store.
jun 21 11:54:09 bext-VPCF13WFX systemd[1]: Stopping Advanced key-value store...
jun 21 11:54:10 bext-VPCF13WFX systemd[1]: Stopped Advanced key-value store.

Verificamos su estatus en red

bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ netstat -lnp | grep redis(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)

Ahora lo levantamos y verificamos su estatus
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo systemctl start redis
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo systemctl status redis
 redis-server.service - Advanced key-value store
   Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor pre
   Active: active (running) since Fri 2019-06-21 12:01:19 CDT; 6s ago
     Docs: http://redis.io/documentation,
           man:redis-server(1)
  Process: 7075 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCE
  Process: 7116 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exit
 Main PID: 7117 (redis-server)
    Tasks: 4 (limit: 4915)
   CGroup: /system.slice/redis-server.service
           └─7117 /usr/bin/redis-server 127.0.0.1:6379

jun 21 12:01:19 bext-VPCF13WFX systemd[1]: Starting Advanced key-value store...
jun 21 12:01:19 bext-VPCF13WFX systemd[1]: redis-server.service: Can't open PID 
jun 21 12:01:19 bext-VPCF13WFX systemd[1]: Started Advanced key-value store.

Verificanos el estado de red

bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ sudo netstat -lnp 
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    

tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      5057/redis-server 1 
tcp6       0      0 ::1:6379                :::*                    LISTEN      5057/redis-server 1 

Probamos redis con python

Instalamos el paquete redis con pip

bext@bext-VPCF13WFX:~$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1
  libc-dev-bin libc6-dev libcilkrts5 libexpat1-dev libfakeroot libgcc-7-dev
  libitm1 liblsan0 libmpx2 libpython-all-dev libpython-dev libpython-stdlib
  libpython2.7-dev libquadmath0 libstdc++-7-dev libtsan0 libubsan0
  linux-libc-dev make manpages-dev python python-all python-all-dev
  python-asn1crypto python-cffi-backend python-crypto python-cryptography
  python-dbus python-dev python-enum34 python-gi python-idna python-ipaddress
  python-keyring python-keyrings.alt python-minimal python-pip-whl
  python-pkg-resources python-secretstorage python-setuptools python-six
  python-wheel python-xdg python2.7 python2.7-dev python2.7-minimal
Suggested packages:
  debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg
  gcc-multilib autoconf automake libtool flex bison gcc-doc gcc-7-multilib
  gcc-7-locales libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg
  libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg
  libmpx2-dbg libquadmath0-dbg glibc-doc libstdc++-7-doc make-doc python-doc
  python-tk python-crypto-doc python-cryptography-doc
  python-cryptography-vectors python-dbus-dbg python-dbus-doc
  python-enum34-doc python-gi-cairo libkf5wallet-bin gir1.2-gnomekeyring-1.0
  python-fs python-gdata python-keyczar python-secretstorage-doc
  python-setuptools-doc python2.7-doc binfmt-support
The following NEW packages will be installed:
  build-essential dpkg-dev fakeroot g++ g++-7 gcc gcc-7 libalgorithm-diff-perl
  libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1
  libc-dev-bin libc6-dev libcilkrts5 libexpat1-dev libfakeroot libgcc-7-dev
  libitm1 liblsan0 libmpx2 libpython-all-dev libpython-dev libpython-stdlib
  libpython2.7-dev libquadmath0 libstdc++-7-dev libtsan0 libubsan0
  linux-libc-dev make manpages-dev python python-all python-all-dev
  python-asn1crypto python-cffi-backend python-crypto python-cryptography
  python-dbus python-dev python-enum34 python-gi python-idna python-ipaddress
  python-keyring python-keyrings.alt python-minimal python-pip python-pip-whl
  python-pkg-resources python-secretstorage python-setuptools python-six
  python-wheel python-xdg python2.7 python2.7-dev python2.7-minimal
0 upgraded, 59 newly installed, 0 to remove and 1 not upgraded.
Need to get 60.6 MB of archives.
After this operation, 176 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python2.7-minimal amd64 2.7.15-4ubuntu4~18.04 [1 295 kB]
Get:2 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-minimal amd64 2.7.15~rc1-1 [28.1 kB]
Get:3 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python2.7 amd64 2.7.15-4ubuntu4~18.04 [239 kB]
Get:4 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libpython-stdlib amd64 2.7.15~rc1-1 [7 620 B]
Get:5 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python amd64 2.7.15~rc1-1 [140 kB]
Get:6 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libc-dev-bin amd64 2.27-3ubuntu1 [71.8 kB]
Get:8 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libc6-dev amd64 2.27-3ubuntu1 [2 587 kB]
Get:7 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-libc-dev amd64 4.15.0-52.56 [1 004 kB]
Get:9 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libitm1 amd64 8.3.0-6ubuntu1~18.04.1 [28.0 kB]
Get:10 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libatomic1 amd64 8.3.0-6ubuntu1~18.04.1 [9 184 B]
Get:11 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libasan4 amd64 7.4.0-1ubuntu1~18.04.1 [359 kB]
Get:12 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 liblsan0 amd64 8.3.0-6ubuntu1~18.04.1 [133 kB]
Get:13 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtsan0 amd64 8.3.0-6ubuntu1~18.04.1 [288 kB]
Get:14 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libubsan0 amd64 7.4.0-1ubuntu1~18.04.1 [126 kB]
Get:15 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcilkrts5 amd64 7.4.0-1ubuntu1~18.04.1 [42.5 kB]
Get:16 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmpx2 amd64 8.3.0-6ubuntu1~18.04.1 [11.6 kB]
Get:17 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libquadmath0 amd64 8.3.0-6ubuntu1~18.04.1 [133 kB]
Get:18 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgcc-7-dev amd64 7.4.0-1ubuntu1~18.04.1 [2 381 kB]
Get:19 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7 amd64 7.4.0-1ubuntu1~18.04.1 [7 463 kB]
Get:20 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc amd64 4:7.4.0-1ubuntu2.3 [5 184 B]
Get:21 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libstdc++-7-dev amd64 7.4.0-1ubuntu1~18.04.1 [1 468 kB]
Get:22 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++-7 amd64 7.4.0-1ubuntu1~18.04.1 [7 574 kB]
Get:23 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++ amd64 4:7.4.0-1ubuntu2.3 [1 568 B]
Get:24 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 make amd64 4.1-9.1ubuntu1 [154 kB]
Get:25 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg-dev all 1.19.0.5ubuntu2.1 [608 kB]
Get:26 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 build-essential amd64 12.4ubuntu1 [4 758 B]
Get:27 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libfakeroot amd64 1.22-2ubuntu1 [25.9 kB]
Get:28 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 fakeroot amd64 1.22-2ubuntu1 [62.3 kB]
Get:29 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB]
Get:30 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-xs-perl amd64 0.04-5 [11.1 kB]
Get:31 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB]
Get:32 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libexpat1-dev amd64 2.2.5-3 [122 kB]
Get:33 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython2.7-dev amd64 2.7.15-4ubuntu4~18.04 [28.3 MB]
Get:34 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libpython-dev amd64 2.7.15~rc1-1 [7 684 B]
Get:35 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 libpython-all-dev amd64 2.7.15~rc1-1 [1 092 B]
Get:36 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 manpages-dev all 4.15-1 [2 217 kB]
Get:37 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-all amd64 2.7.15~rc1-1 [1 076 B]
Get:38 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python2.7-dev amd64 2.7.15-4ubuntu4~18.04 [278 kB]
Get:39 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-dev amd64 2.7.15~rc1-1 [1 256 B]
Get:40 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-all-dev amd64 2.7.15~rc1-1 [1 100 B]
Get:41 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-asn1crypto all 0.24.0-1 [72.7 kB]
Get:42 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-cffi-backend amd64 1.11.5-1 [63.4 kB]
Get:43 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-crypto amd64 2.6.1-8ubuntu2 [244 kB]
Get:44 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-enum34 all 1.1.6-2 [34.8 kB]
Get:45 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-idna all 2.6-1 [32.4 kB]
Get:46 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-ipaddress all 1.0.17-1 [18.2 kB]
Get:47 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-six all 1.11.0-2 [11.3 kB]
Get:48 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python-cryptography amd64 2.1.4-1ubuntu1.3 [221 kB]
Get:49 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-dbus amd64 1.2.6-1 [90.2 kB]
Get:50 http://mx.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python-gi amd64 3.26.1-2ubuntu1 [197 kB]
Get:51 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-secretstorage all 2.3.1-2 [11.8 kB]
Get:52 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-keyring all 10.6.0-1 [30.6 kB]
Get:53 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-keyrings.alt all 3.0-1 [16.7 kB]
Get:54 http://mx.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 python-pip-whl all 9.0.1-2.3~ubuntu1.18.04.1 [1 653 kB]
Get:55 http://mx.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 python-pip all 9.0.1-2.3~ubuntu1.18.04.1 [151 kB]
Get:56 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-pkg-resources all 39.0.1-2 [128 kB]
Get:57 http://mx.archive.ubuntu.com/ubuntu bionic/main amd64 python-setuptools all 39.0.1-2 [329 kB]
Get:58 http://mx.archive.ubuntu.com/ubuntu bionic/universe amd64 python-wheel all 0.30.0-0.2 [36.4 kB]
Get:59 http://mx.archive.ubuntu.com/ubuntu bionic/universe amd64 python-xdg all 0.25-4ubuntu1 [31.3 kB]
Fetched 60.6 MB in 16s (3 754 kB/s)                                            
Extracting templates from packages: 100%
Selecting previously unselected package python2.7-minimal.
(Reading database ... 160074 files and directories currently installed.)
Preparing to unpack .../python2.7-minimal_2.7.15-4ubuntu4~18.04_amd64.deb ...
Unpacking python2.7-minimal (2.7.15-4ubuntu4~18.04) ...
Selecting previously unselected package python-minimal.
Preparing to unpack .../python-minimal_2.7.15~rc1-1_amd64.deb ...
Unpacking python-minimal (2.7.15~rc1-1) ...
Selecting previously unselected package python2.7.
Preparing to unpack .../python2.7_2.7.15-4ubuntu4~18.04_amd64.deb ...
Unpacking python2.7 (2.7.15-4ubuntu4~18.04) ...
Selecting previously unselected package libpython-stdlib:amd64.
Preparing to unpack .../libpython-stdlib_2.7.15~rc1-1_amd64.deb ...
Unpacking libpython-stdlib:amd64 (2.7.15~rc1-1) ...
Setting up python2.7-minimal (2.7.15-4ubuntu4~18.04) ...
Linking and byte-compiling packages for runtime python2.7...
Setting up python-minimal (2.7.15~rc1-1) ...
Selecting previously unselected package python.
(Reading database ... 160131 files and directories currently installed.)
Preparing to unpack .../00-python_2.7.15~rc1-1_amd64.deb ...
Unpacking python (2.7.15~rc1-1) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../01-libc-dev-bin_2.27-3ubuntu1_amd64.deb ...
Unpacking libc-dev-bin (2.27-3ubuntu1) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../02-linux-libc-dev_4.15.0-52.56_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.15.0-52.56) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../03-libc6-dev_2.27-3ubuntu1_amd64.deb ...
Unpacking libc6-dev:amd64 (2.27-3ubuntu1) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../04-libitm1_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking libitm1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../05-libatomic1_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking libatomic1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libasan4:amd64.
Preparing to unpack .../06-libasan4_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking libasan4:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../07-liblsan0_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking liblsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../08-libtsan0_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking libtsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../09-libubsan0_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking libubsan0:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../10-libcilkrts5_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking libcilkrts5:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../11-libmpx2_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking libmpx2:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../12-libquadmath0_8.3.0-6ubuntu1~18.04.1_amd64.deb ...
Unpacking libquadmath0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Selecting previously unselected package libgcc-7-dev:amd64.
Preparing to unpack .../13-libgcc-7-dev_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking libgcc-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package gcc-7.
Preparing to unpack .../14-gcc-7_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking gcc-7 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package gcc.
Preparing to unpack .../15-gcc_4%3a7.4.0-1ubuntu2.3_amd64.deb ...
Unpacking gcc (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package libstdc++-7-dev:amd64.
Preparing to unpack .../16-libstdc++-7-dev_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../17-g++-7_7.4.0-1ubuntu1~18.04.1_amd64.deb ...
Unpacking g++-7 (7.4.0-1ubuntu1~18.04.1) ...
Selecting previously unselected package g++.
Preparing to unpack .../18-g++_4%3a7.4.0-1ubuntu2.3_amd64.deb ...
Unpacking g++ (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package make.
Preparing to unpack .../19-make_4.1-9.1ubuntu1_amd64.deb ...
Unpacking make (4.1-9.1ubuntu1) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../20-dpkg-dev_1.19.0.5ubuntu2.1_all.deb ...
Unpacking dpkg-dev (1.19.0.5ubuntu2.1) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../21-build-essential_12.4ubuntu1_amd64.deb ...
Unpacking build-essential (12.4ubuntu1) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../22-libfakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.22-2ubuntu1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../23-fakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking fakeroot (1.22-2ubuntu1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../24-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../25-libalgorithm-diff-xs-perl_0.04-5_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-5) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../26-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libexpat1-dev:amd64.
Preparing to unpack .../27-libexpat1-dev_2.2.5-3_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.5-3) ...
Selecting previously unselected package libpython2.7-dev:amd64.
Preparing to unpack .../28-libpython2.7-dev_2.7.15-4ubuntu4~18.04_amd64.deb ...
Unpacking libpython2.7-dev:amd64 (2.7.15-4ubuntu4~18.04) ...
Selecting previously unselected package libpython-dev:amd64.
Preparing to unpack .../29-libpython-dev_2.7.15~rc1-1_amd64.deb ...
Unpacking libpython-dev:amd64 (2.7.15~rc1-1) ...
Selecting previously unselected package libpython-all-dev:amd64.
Preparing to unpack .../30-libpython-all-dev_2.7.15~rc1-1_amd64.deb ...
Unpacking libpython-all-dev:amd64 (2.7.15~rc1-1) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../31-manpages-dev_4.15-1_all.deb ...
Unpacking manpages-dev (4.15-1) ...
Selecting previously unselected package python-all.
Preparing to unpack .../32-python-all_2.7.15~rc1-1_amd64.deb ...
Unpacking python-all (2.7.15~rc1-1) ...
Selecting previously unselected package python2.7-dev.
Preparing to unpack .../33-python2.7-dev_2.7.15-4ubuntu4~18.04_amd64.deb ...
Unpacking python2.7-dev (2.7.15-4ubuntu4~18.04) ...
Selecting previously unselected package python-dev.
Preparing to unpack .../34-python-dev_2.7.15~rc1-1_amd64.deb ...
Unpacking python-dev (2.7.15~rc1-1) ...
Selecting previously unselected package python-all-dev.
Preparing to unpack .../35-python-all-dev_2.7.15~rc1-1_amd64.deb ...
Unpacking python-all-dev (2.7.15~rc1-1) ...
Selecting previously unselected package python-asn1crypto.
Preparing to unpack .../36-python-asn1crypto_0.24.0-1_all.deb ...
Unpacking python-asn1crypto (0.24.0-1) ...
Selecting previously unselected package python-cffi-backend.
Preparing to unpack .../37-python-cffi-backend_1.11.5-1_amd64.deb ...
Unpacking python-cffi-backend (1.11.5-1) ...
Selecting previously unselected package python-crypto.
Preparing to unpack .../38-python-crypto_2.6.1-8ubuntu2_amd64.deb ...
Unpacking python-crypto (2.6.1-8ubuntu2) ...
Selecting previously unselected package python-enum34.
Preparing to unpack .../39-python-enum34_1.1.6-2_all.deb ...
Unpacking python-enum34 (1.1.6-2) ...
Selecting previously unselected package python-idna.
Preparing to unpack .../40-python-idna_2.6-1_all.deb ...
Unpacking python-idna (2.6-1) ...
Selecting previously unselected package python-ipaddress.
Preparing to unpack .../41-python-ipaddress_1.0.17-1_all.deb ...
Unpacking python-ipaddress (1.0.17-1) ...
Selecting previously unselected package python-six.
Preparing to unpack .../42-python-six_1.11.0-2_all.deb ...
Unpacking python-six (1.11.0-2) ...
Selecting previously unselected package python-cryptography.
Preparing to unpack .../43-python-cryptography_2.1.4-1ubuntu1.3_amd64.deb ...
Unpacking python-cryptography (2.1.4-1ubuntu1.3) ...
Selecting previously unselected package python-dbus.
Preparing to unpack .../44-python-dbus_1.2.6-1_amd64.deb ...
Unpacking python-dbus (1.2.6-1) ...
Selecting previously unselected package python-gi.
Preparing to unpack .../45-python-gi_3.26.1-2ubuntu1_amd64.deb ...
Unpacking python-gi (3.26.1-2ubuntu1) ...
Selecting previously unselected package python-secretstorage.
Preparing to unpack .../46-python-secretstorage_2.3.1-2_all.deb ...
Unpacking python-secretstorage (2.3.1-2) ...
Selecting previously unselected package python-keyring.
Preparing to unpack .../47-python-keyring_10.6.0-1_all.deb ...
Unpacking python-keyring (10.6.0-1) ...
Selecting previously unselected package python-keyrings.alt.
Preparing to unpack .../48-python-keyrings.alt_3.0-1_all.deb ...
Unpacking python-keyrings.alt (3.0-1) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../49-python-pip-whl_9.0.1-2.3~ubuntu1.18.04.1_all.deb ...
Unpacking python-pip-whl (9.0.1-2.3~ubuntu1.18.04.1) ...
Selecting previously unselected package python-pip.
Preparing to unpack .../50-python-pip_9.0.1-2.3~ubuntu1.18.04.1_all.deb ...
Unpacking python-pip (9.0.1-2.3~ubuntu1.18.04.1) ...
Selecting previously unselected package python-pkg-resources.
Preparing to unpack .../51-python-pkg-resources_39.0.1-2_all.deb ...
Unpacking python-pkg-resources (39.0.1-2) ...
Selecting previously unselected package python-setuptools.
Preparing to unpack .../52-python-setuptools_39.0.1-2_all.deb ...
Unpacking python-setuptools (39.0.1-2) ...
Selecting previously unselected package python-wheel.
Preparing to unpack .../53-python-wheel_0.30.0-0.2_all.deb ...
Unpacking python-wheel (0.30.0-0.2) ...
Selecting previously unselected package python-xdg.
Preparing to unpack .../54-python-xdg_0.25-4ubuntu1_all.deb ...
Unpacking python-xdg (0.25-4ubuntu1) ...
Setting up libquadmath0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up libatomic1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up python-pip-whl (9.0.1-2.3~ubuntu1.18.04.1) ...
Setting up make (4.1-9.1ubuntu1) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Setting up libasan4:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3.18.04.2) ...
Setting up libcilkrts5:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libubsan0:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libtsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up linux-libc-dev:amd64 (4.15.0-52.56) ...
Setting up python2.7 (2.7.15-4ubuntu4~18.04) ...
Setting up liblsan0:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up libpython-stdlib:amd64 (2.7.15~rc1-1) ...
Setting up libmpx2:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libfakeroot:amd64 (1.22-2ubuntu1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up libc-dev-bin (2.27-3ubuntu1) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Setting up manpages-dev (4.15-1) ...
Setting up libc6-dev:amd64 (2.27-3ubuntu1) ...
Setting up libitm1:amd64 (8.3.0-6ubuntu1~18.04.1) ...
Setting up python (2.7.15~rc1-1) ...
Setting up python-xdg (0.25-4ubuntu1) ...
Setting up python-idna (2.6-1) ...
Setting up python-asn1crypto (0.24.0-1) ...
Setting up python-crypto (2.6.1-8ubuntu2) ...
Setting up python-wheel (0.30.0-0.2) ...
Setting up python-pkg-resources (39.0.1-2) ...
Setting up fakeroot (1.22-2ubuntu1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libstdc++-7-dev:amd64 (7.4.0-1ubuntu1~18.04.1) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up python-cffi-backend (1.11.5-1) ...
Setting up python-gi (3.26.1-2ubuntu1) ...
Setting up python-six (1.11.0-2) ...
Setting up libalgorithm-diff-xs-perl (0.04-5) ...
Setting up python-enum34 (1.1.6-2) ...
Setting up libexpat1-dev:amd64 (2.2.5-3) ...
Setting up libpython2.7-dev:amd64 (2.7.15-4ubuntu4~18.04) ...
Setting up python-dbus (1.2.6-1) ...
Setting up python-ipaddress (1.0.17-1) ...
Setting up python-pip (9.0.1-2.3~ubuntu1.18.04.1) ...
Setting up python2.7-dev (2.7.15-4ubuntu4~18.04) ...
Setting up python-all (2.7.15~rc1-1) ...
Setting up libpython-dev:amd64 (2.7.15~rc1-1) ...
Setting up python-setuptools (39.0.1-2) ...
Setting up gcc-7 (7.4.0-1ubuntu1~18.04.1) ...
Setting up g++-7 (7.4.0-1ubuntu1~18.04.1) ...
Setting up python-dev (2.7.15~rc1-1) ...
Setting up libpython-all-dev:amd64 (2.7.15~rc1-1) ...
Setting up gcc (4:7.4.0-1ubuntu2.3) ...
Setting up python-keyrings.alt (3.0-1) ...
Setting up python-all-dev (2.7.15~rc1-1) ...
Setting up python-cryptography (2.1.4-1ubuntu1.3) ...
Setting up g++ (4:7.4.0-1ubuntu2.3) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up python-secretstorage (2.3.1-2) ...
Setting up python-keyring (10.6.0-1) ...
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
bext@bext-VPCF13WFX:~$ pip

Usage:   
  pip <command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring
                              environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be
                              used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be
                              used up to 3 times (corresponding to WARNING,
                              ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form
                              [user:passwd@]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should
                              attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists:
                              (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does
                              not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file
                              containing the private key and the certificate
                              in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check
                              Don't periodically check PyPI to determine
                              whether a new version of pip is available for
                              download. Implied with --no-index.
bext@bext-VPCF13WFX:~$ sudo pip install redis
The directory '/home/bext/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/bext/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting redis
  Downloading https://files.pythonhosted.org/packages/ac/a7/cff10cc5f1180834a3ed564d148fb4329c989cbb1f2e196fc9a10fa07072/redis-3.2.1-py2.py3-none-any.whl (65kB)
    100% |████████████████████████████████| 71kB 694kB/s 
Installing collected packages: redis
Successfully installed redis-3.2.1

 Editamos un archivo de prueba python (testpython.py)

import redis
#crear una connexion con la instancia del servidor local de redis# por default corren en puerto 6379redis_db = redis.StrictRedis(host="localhost", port=6379, db=0)
redis_db.keys()
redis_db.set("redis","Esta funcionando!")
redis_db.keys()
redis_db.get("redis")
redis_db.incr("visitas")
redis_db.get("visitas")

Este programa incrementa la key visitas, ahora jugamos con redis-cli para colocar la key visitas a un valor de 1.

bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ redis-cli
127.0.0.1:6379> keys *
1) "visitas"
2) "test"
3) "full stack"
4) "foo"
127.0.0.1:6379> get visitas
"4"
127.0.0.1:6379> decr visitas
(integer) 3
127.0.0.1:6379> decr visitas
(integer) 2
127.0.0.1:6379> decr visitas
(integer) 1
127.0.0.1:6379> del foo
(integer) 1
127.0.0.1:6379> del full stack
(integer) 0
127.0.0.1:6379> keys *
1) "visitas"
2) "test"
3) "full stack"
127.0.0.1:6379> del 'full stack'
(integer) 1
127.0.0.1:6379> keys *
1) "visitas"
2) "test"
127.0.0.1:6379>  

Ahora ejecutamos el programa de prueba python

bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ python testRedis.py
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ redis-cli
127.0.0.1:6379> get visitas
"2"
127.0.0.1:6379> exit
bext@bext-VPCF13WFX:~/DockerAppConfig/DockerSampleApp$ 

Ok, observamos el valor de key visitas a 2.

referencias
https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04
https://github.com/andymccurdy/redis-py/#installation

eot

No hay comentarios:

Publicar un comentario