Install the Redis image with Docker in Ubuntu and share it with the Redis container

Source: Internet
Author: User
Tags redis version docker run redis cluster install redis

Install the Redis image with Docker in Ubuntu and share it with the Redis container

1. Install Ubuntu
2. Use Putty to log on to Ubuntu
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.small-40-generic x86_64)

* Documentation: https://help.ubuntu.com/

System information as of Wed Dec 31 06:41:16 UTC 2014

System load: 0.01 Processes: 228
Usage of/: 6.0% of 28.80 GB Users logged in: 0
Memory usage: 11% IP address for eth0: 10.205.178.22
Swap usage: 0% IP address for docker0: 172.17.42.1

Graph this data and manage this system:
Https://landscape.canonical.com/

Get cloud support with Ubuntu Advantage Cloud Guest:
Http://www.ubuntu.com/business/services/cloud

3. Pull the redis Image
Root @ jumping :~ # Sudo docker pull redis: latest
Redis: latest: The image you are pulling has been verified
Eee46bd361c1: Pull complete
Ff8650f588b2: Pull complete
130985f77ca0: Pull complete
4d81fff38a25: Pull complete
E6d98faa32e2: Pull complete
95d3849978c3: Pull complete
263f96794544: Pull complete
1ed9b7611cf5: Pull complete
451742990a7f: Pull complete
2017136ea3c5a: Already exists
F10807909bc5: Already exists
F6fab3b798be: Already exists
1e6ac0ffed3b: Already exists
62ff5003ac9a: Already exists
E49d349e8a75: Already exists
61213f5a1710: Already exists
9feca322d1c7: Already exists
1aa8ce669b93: Already exists
Status: Downloaded newer image for redis: latest
Root @ jumping :~ # Sudo docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
Redis latest 451742990a7f 11 days ago 111.2 MB

4. Start the redis container
Root @ jumping :~ # Sudo docker run-t-I redis: latest
[1] 31 Dec 02:56:57. 870 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server/path/to/redis. conf
_._
_.-''__''-._
_.-'''. '_. ''-. _ Redis 2.8.19 (00000000/0) 64 bit
.-''.-'''.'''\/_.,_''-._
(',.-' | ',) Running in stand alone mode
| '-. _'-...-'_...-.'-. _ | ''_.-'| Port: 6379
| '-. _'. _/_.-'| PID: 1
'-._'-._'-./_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' | Http://redis.io
'-._'-._'-.__.-'_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' |
'-._'-._'-.__.-'_.-'_.-'
'-._'-.__.-'_.-'
'-.__.-'
'-.__.-'

[1] 31 Dec 02:56:57. 890 # Server started, Redis version 2.8.19
[1] 31 Dec 02:56:57. 890 # 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.
[1] 31 Dec 02:56:57. 891 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. this will create latency and memory usage issues with Redis. to fix this issue run the command 'echo never>/sys/kernel/mm/transparent_hugepage/enabled 'as root, and add it to your/etc/rc. local in order to retain the setting after a reboot. redis must be restarted after THP is disabled.
[1] 31 Dec 02:56:57. 891 # WARNING: The TCP backlog setting of 511 cannot be enforced because/proc/sys/net/core/somaxconn is set to the lower value of 128.
[1] 31 Dec 02:56:57. 891 * The server is now ready to accept connections on port 6379

5. What should I do next when the Redis container is started?
Method: Shut down putty and re-enter putty.

6. How to enter the container?
Install NSenter first:

Cd/tmp; curl http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/utils/util-linux/v2.25/util-linux-2.25.tar.gz | tar-zxf-; cd util-linux-2.25;
Sudo apt-get install build-essential
Sudo apt-get make
./Configure -- without-ncurses
Make nsenter & sudo cp nsenter/usr/local/bin

Method 1:

PID =$ (docker inspect -- format "{. State. Pid}" <container>)

Nsenter -- target $ PID -- mount -- uts -- ipc -- net -- pid

Method 2:

Installation script (Script Reference: https://github.com/jpetazzo/nsenter/blob/master/docker-enter)

Wget-P ~ Https://github.com/yeasy/docker_practice/raw/master/_local/.bashrc_docker;

Echo "[-f ~ /. Bashrc_docker] & amp;. ~ /. Bashrc_docker ">> ~ /. Bashrc; source ~ /. Bashrc

Finally, call docker-enter to enter the container:

Root @ jumping:/tmp # docker-enter b1_d6f4ff00 ls
Dirname: invalid option --'s'
Try 'dirname -- help' for more information.
Bin boot data dev entrypoint. sh etc home lib lib64 media mnt opt proc root run sbin selinux srv sys tmp usr var
Root @ b430d6f4ff00 :~ #

Note: here we see an error because $ (dirname "$0" ") is used in the script. You can directly echo" $0 ". What I show here is-su.

7. Test the redis command
After entering the container, you can use redis-cli ping test to connect to the redis-server that was just started on the local machine. If PONG is returned, the connection is successful.

Directly press redis-cli to enter the redis command for testing:

Root @ 816ebd247014 :~ # Redis-cli ping
PONG
Root @ 816ebd247014 :~ # Redis-cli
127.0.0.1: 6379> set myname jumping
OK
127.0.0.1: 6379> get myname
"Jumping"
Wagner. 0.0.1: 6379>

8. This is simple to start redis, to use it, we also need to mirror the port to the host machine, and then can call Redis through the client: http://redis.io/clients

Install and test Redis in Ubuntu 14.04

Redis cluster details

Install Redis in Ubuntu 12.10 (graphic explanation) + Jedis to connect to Redis

Redis series-installation, deployment, and maintenance

Install Redis in CentOS 6.3

Learning notes on Redis installation and deployment

Redis. conf

Redis details: click here
Redis: click here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.