In this video, Emmanuel Henri goes over the installation of the Redis server and the cli client. Then he validates that the server is properly installed by starting it and testing a few commands.
- Before we start looking at potential clients and the one we'll use in this course, let's go ahead and install redis. First on our system, there is a version of redis ported for Windows and you can get it by going to this page here so it's "github.com/microsoftarchive/redis" Then when you get to that page, you can scroll all the way down to the installation instructions. Please take note that redis was made for UNIX based systems.
So it works well with Linux, it works well with Mac. It's not made for Windows. So for those that want to try it with Windows, it's going to work with that port but be aware that there's going to be some issues. Sometimes, it may be unsupported at this point. It's not the supported version by redis themselves. Just a note. Or you can actually do it on Windows as well. The commands that we're going to do whether it's on Mac, Linux, and Windows are the same when we're using the "cli" client. So if you're using Windows, and using terminal you can enter the same command that we're going to do.
No problem there. Okay, so let's go ahead and install it on our system. So go to redis.io then go into the download section here so check the downloads page then scroll all the way down to the installation section here. So if you have the Apple developer tools installed, you can do the wget no problem. If you don't, and we'll just assume that you don't. We'll do a curl instead. So copy this line here.
Or copy the whole line if you have the Apple developer tools. Get into your terminal. And do "curl-O" then paste that address. So for our Windows folks, make sure you do not use git bash and use regular command prompt that comes with Windows if you want to get the same results. I am here. And it will download the files that we need. Then we need to extract those files so do a tar and xzf, which is a special command.
And you want to do the redis file we just downloaded, so it's "redis-4.0.2" ".tar.gz" like so, and then get inside of that Which is directories so let's make sure it's there so we got this directory here so we could copy this-let's call it directory, if you want. And do- a quick note also for when you're taking this course. The version of this redis might be a little bit different.
So just make sure you enter the "4.0.2" or the "4.0.3", or whatever version you're on when you tar and when you enter the directory that we're going to do here. So the best way to do this is just do an "ls" and check the files that are here. So you would see that redis is now the "4.0.2" but if for you it's different, then make sure you tar the right file and make sure you cd into the right directory. So let's go ahead and cd inside of our directory that we just copied, like so.
And then you will do the command "make". Another quick note, for those that don't have the apple developer tools. When you enter "make" and you click "enter" it's going to ask you to install those tools. When you're done installing those tools, come back and do the "make" command again because if you don't do the "make" command after you have the Apple developer tools installed, it's not going to work. So make sure you do that. So I'm going to do the "make" command. I have the apple developer tools already installed and it's going to do a whole bunch of stuff.
If you don't see this, it means that you don't have the developer tools installed. It's going to ask you to install them. Install them and then do the "make" command again. If you don't, up until you see those things happening, it means that it hasn't been installed yet. Okay? So the next thing we need to do, is actually start our redis server. So the best way to do this, is to do "src/redis-server" like so. And this is going to start our server.
So if you see this, our redis server is actually installed. For Windows folks, when you first install redis on Windows, it starts service automatically, and uses the default port 6379. So when you try to run the server again, it's trying to use a port already in use. So the solution is to type "shut down" in your newly started client, and then run the server again. But for more details on this issue, visit the stack overflow link indicated on your screen. Now let's start the client.
Let's go ahead and tab a second window for our terminal. So for Mac, you can do Command+T to open a second tab and for Windows folks, you just go to "file" open a second tab and then console and you should be able to open a second tab for your console. So if we do an "ls" right now, we're in the same directory. If you're not, make sure that you "cd" to the actual directory where redis is installed. So, if you're not, most often you just need to do "cd" and then the actual- let me just jump out and show it you.
So if we do an "ls", now I'm going to be able to see that directory. If you're at the top level, just go ahead and do a "cd" again. And then the name of the directory and then we're back inside of here. So, to open the actual client is: "src" and its redis client as opposed to redis servers. So "redis-cli" like so. And then this will open the actual cli for our redis servers so now we're connected to the redis servers. This is the official ip address for the redis server, and this is the query.
So we could literally insert a new key and I'm going to show you how all that works, very, very soon so set name "manny", so I'm actually entering a new key. And then what I could do is I get the key like so, and you'll see when you're using redis cli. You'll see that they will always suggest what you could do next, like so. "Get name" and there you go. I have an official cli client installed and the redis server installed. So now that we've got a redis server installed and running, and we could literally continue the course without installing any other tools, but I want to take a look at a few options available before we move on.
- Installing and setting up Redis
- Reviewing the basics of data types
- Setting up persistence and replication
- Exploring strings and lists
- The hash data structure
- Securing a Redis instance
- Publishing and subscribing with Redis