To begin with,
we move out to our AlmaLinux 8.5 system where we set up our iSCSI target
or the iSCSI server. And here we are then on the command line of AlmaLinux
8. Now, this is our fresh virtual machine.
So as I go through, we can see I've just got port 22 the
port‑mapper service 111 running, nothing else.
And if I go through and take a look at our block devices,
I have got just the sda block device.
Now the whole idea of iSCSI is that we share out block devices, but don't
worry, I don't need to create them independently myself.
The command‑line utility targetcli will also create file back‑ends
if that's what we want to useo. And, of course, that is what we're
going to be using. Now, we do need to go through and run through a
little bit of an installation.
So, not too much,
it's just the package targetcli. It's going to add some Python packages
in for us, so we can go through and allow it to run through. And with
that up and running, we're able to go through, and seeing that well
nothing will have changed, we won't have started up any of our ports.
We'll see that as we create our block devices that are being shared out,
we will actually then go through and start seeing our ports being opened.
But we're never going to see our block devices as local block devices.
The whole idea is that we are going to be sharing out, so the block
devices show on our client or the initiator. Now to start our
configuration, we use the targetcli command.
This could be used interactively.
So as I go through and hit Enter,
we can see now that we are in the targetcli shell. I can use ls to
start listing, and as we list, we can see that we don't have any
targets or any objects in our backstore. So we can go through then
and start creating our objects.
And the first thing that we're going to do is create a backstore.
We can choose between block devices,
fileio, pscsi, and ramdisk, but we're going to go through and run
backstores/fileio. Put a space because we can then put a command
after that, and we're going to go through and create. We're going
to assign a name to our device.
So we're going to call it targetdisk1.
We're going to set the properties for this.
It's fileio, so it's going to be a file in our filesystem, and we're just
going to call it /root/targetdisk1, and we can set our size. So that then
goes through and creates the file for me.
So I don't have to worry about fallocate running separately.
We have now just created the 1 GB file.
I now need to go through and create an iSCSI target, and I do
that moving to iscsi space create. The name of the device is
an iscsi qualified name, IQN.
This is then normally IQN followed by the date and reverse DNS name.
So once we've got this in, we can then use colon to separate the IQN
from the actual device name that we want to use.
I'm just going to call it san1.
So that's created a TPG directory structure, a target portal group.
With this, we can go through and start creating a LUN and access
control lists to start linking this both to our initiator and
our back‑end or backstore device.
Now remember, we can use the ls command at any stage, so we can see
then the backstore that we've created, targetdisk1, and we can see
then the IQN that we've created, an rtpg1.
Now with this then set up, let's move to finish it off.
I'm going to move into the iSCSI and IQN subdirectory and
TPG1. Working within this directory structure,
I can go through and create my access control list and LUN. We can
see under TPG1, we have a ACLs, LUNs, and portals.
I can use ls to list just this directory, but we're now going to go through
and start linking the portal through to the backstore.
So with this, I can go into luns/ create and then backstore. I can
tab complete. I've only got the one backstore, so that's really easy
to create. And then I can go into the ACLs, and in the same way, I
can go through and create an ACL.
The ACL is then listing the client that we want to use. So
I can specify the name of the client.
We can pretend, if you like, the client has been around a little bit
longer. So our client was created, let's say, in March 2015.
But again, part of Pluralsight, so .com.pluralsight, and then we can say
.client at the end of this, and again, linking it through to our san1. So our
client then will have access through. It's listed in the access control list
for san1. I forgot the create, so we can just up arrow key and add in the
create subcommand just in front of our IQN.
So all of that is good now. And we're pretty much there and ready to go
now. I'm just going to copy into my paste buffer the IQN.
Remember, this is the initiator name, so I must configure
my client with this initiator name.
We can list everything from our root of our configuration tree, and once we're
happy with this, we can then go through and use exit to save, and it will then
create a JSON file, which is used to load it later. We should be up and running.
We can go and start checking this now.
If I go through and look at my open ports, we'll see that port 3260 is open.
So this is our standard ports that we're using with the iSCSI target. I don't
have firewalld running, so I don't have to worry about access through to the
firewall. If I lose my block device, remember what I was saying, though, this
block device is not available locally,
it's available to any iSCSI client that connects. Remember, I've set up
the access control list, so I must then access from that client. But we
did create the back‑end storage, so our targetdisk1, which you can see
as the 1 GB file listed here.
Now the last thing we need to concern ourselves with is how is
that port 3260 going to be opened in the future, and how is our
block device going to be shared out?
Well, we know we stored the configuration in a JSON file, and that
JSON file is going to be read by our system and ctl, and if I look
at the status of the target service,
we read in our target configuration during the boot phase.
This service doesn't need to be loaded all of the time.
It only needs to read in the configuration. But I do need to make
sure that it's enabled, so it starts when the system starts. So I
just go through and enable this.
Now this is all looking very good from the target side,
our server side,
but we now need to revisit or visit our Ubuntu system to take
a look at getting the initiator or client up and running to access the shared block device.