No. | Command name | Usage |
---|---|---|
1 | lxcf | Resource setting, resource display, control, and management of LXCF |
LXCF has subcommands which control and manage containers, set and display the resorce of containers.
# lxcf subcommand option specification-values ...
You can execute lxcf subcommand directly with options and specification-values.
It returns when its execution ends.
Options (-f, -c 10, etc.) have to be placed between subcommand and specification-values.
# lxcf
LXCF Facility
GNU GENERAL PUBLIC LICENSE Version 2
Type: 'helpcmd' for help with commands
'exit' or '^d' to quitLXCF # subcommand option specification-values ...
When the lxcf command is executed with no arguments like above, a shell whose prompt is "LXCF #" runs. In this shell-mode, subcommands can be executed directly withouth "lxcf". Arbitrary commands other than LXCF can be used as well as usual bash.
It returns to the LXCF shell when the execution of the subcommand ends. Therefore, uses can continuously input as many subcommands as they want.
resource controls
No. | Subcommand | Arguments |
---|---|---|
1 | cpun | (CONTAINER_NAME or UUID) CPU_NUMBER |
2 | cpurate | (CONTAINER_NAME or UUID) CPU_RATE |
3 | numa | (CONTAINER_NAME or UUID) NUMA_NUMBER |
4 | memlimit | (CONTAINER_NAME or UUID) MEMORY_LIMIT |
5 | memswlimit | (CONTAINER_NAME or UUID) MEMORY&SWAP_LIMIT |
6 | blkio_r | (CONTAINER_NAME or UUID) BLKIO_READ_LIMIT |
7 | blkio_w | (CONTAINER_NAME or UUID) BLKIO_WRITE_LIMIT |
8 | blkiops_r | (CONTAINER_NAME or UUID) BLKIOPS_READ_LIMIT |
9 | blkiops_w | (CONTAINER_NAME or UUID) BLKIOPS_WRITE_LIMIT |
10 | net_cls | (CONTAINER_NAME or UUID) NET_CLS_ID |
11 | show | [(CONTAINER_NAME or UUID)] |
12 | set | [-c CPURATE] [-i CPU-Number] [-n NUMA-Number] [-m MEMLIMIT] [-s MEMSWLIMIT] (CONTAINER_NAME or UUID) ... |
container management
No. | Subcommand | Arguments |
---|---|---|
1 | sysgen | [-h] [-o] [-s] [-j] [-c json-file] [-p path] CONTAINER_NAME ... |
2 | clone | [-p path] (SRC_CONTAINER_NAME or UUID) NEW_CONTAINER_NAME ... |
3 | erase | (CONTAINER_NAME or UUID) ... |
4 | list | [ -q ] [(CONTAINER_NAME or UUID) ...] |
5 | log | [-f] |
6 | console | (CONTAINER_NAME or UUID) |
7 | autostart | (CONTAINER_NAME or UUID) ... |
8 | rename | CONTAINER_NAME NEW_CONTAINER_NAME |
maintenance/update
No. | Subcommand | Arguments |
---|---|---|
1 | update | COMMAND |
2 | deploy | [-d] [-f] FILEorDIR ... |
start/stop management
No. | Subcommand | Arguments |
---|---|---|
1 | start | (CONTAINER_NAME or UUID) ... |
2 | stop | (CONTAINER_NAME or UUID) ... |
3 | suspend | (CONTAINER_NAME or UUID) ... |
4 | resume | (CONTAINER_NAME or UUID) ... |
5 | run | (CONTAINER_NAME or UUID) COMMAND |
Processes two or more containers
No. | Subcommand | Arguments |
---|---|---|
1 | sysgen-n | [-p path] [-c resource-file] name-prefix [start-number] end-number |
2 | clone-n | [-p path] name-prefix [start-number] end-number |
3 | erase-n | name-prefix [start-number] end-number |
4 | start-n | name-prefix [start-number] end-number |
5 | stop-n | name-prefix [start-number] end-number |
6 | resume-n | name-prefix [start-number] end-number |
7 | set-n | [-c CPURATE] [-a Num-of-CPU ] [-i CPU-Number] [-n NUMA-Number] [-m MEMLIMIT] [-s MEMSWLIMIT] name-prefix [start-number] end-number |
8 | autostart-n | [ -d ] name-prefix [start-number] end-number |
Batch queue
No. | Subcommand Name | Arguments |
---|---|---|
1 | submit | LXCF_command |
2 | queue cancel | UUID |
3 | queue clear | [-h] [-q] [-l] [-a] |
4 | queue list | None |
5 | queue move | [-h] [-q] [-l] UUID |
6 | queue multi | [NUMBER] |
snapshot & restore
No. | Subcommand | Arguments |
---|---|---|
1 | snapshot | [ -f ] [ -p PATH ] [ -n SNAPSHOT_IMAGE ] (UUID or NAME) |
2 | restore | [ -n NEW_NAME ] [ -p PATH ] [ -f ] [ -s ] SNAPSHOT_IMAGE |
3 | snapshot-pull | [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME |
4 | snapshot-list | [ -p PASSWORD ] [ -i SERVERNAME:PORT ][ SNAPSHOT_IMAGE ... ] |
5 | snapshot-erase | [ -f ] SNAPSHOT_IMAGE ... |
REST API
No. | Subcommand | Arguments |
---|---|---|
1 | api | ( enable or disable ) |
2 | api-passwd | None |
export
No. | Subcommand | Arguments |
---|---|---|
1 | export-docker | (UUID or NAME) ... |
Network
No. | Subcommand | Arguments |
---|---|---|
1 | net-add | [ -d NETDEV ] [ -n NUMBER ] [ -g GATEWAY ] [ -b BRIDGE ] CONTAINER_NAME IPADDR/MASK |
2 | net-del | [ -n NUMBER ] CONTAINER_NAME |
-b BRIDGE | ||
3 | net-gateway | CONTAINER_NAME IP_ADDR |
4 | net-route | -a [ -n NUMBER ] CONTAINER_NAME NET_ADDR GATEWAY |
-d CONTAINER_NAME NET_ADDR | ||
5 | net-list | [ -b ] |
help
No. | Subcommand | Arguments |
---|---|---|
1 | helpcmd | None |
2 | version | None |
Following is an example of the shell script to change the CPU rate of three containers alternately every hour.
Three containers are named as asia-srv, eruo-srv, and usa-srv.
#!/bin/sh
while :
do
echo "Asia 80% , Euro 10%, USA 10%"
/usr/sbin/lxcf cpurate asia-srv 80
/usr/sbin/lxcf cpurate euro-srv 10
/usr/sbin/lxcf cpurate usa-srv 10
sleep 3600echo "Asia 10% , Euro 80%, USA 10%"
/usr/sbin/lxcf cpurate asia-srv 10
/usr/sbin/lxcf cpurate euro-srv 80
/usr/sbin/lxcf cpurate usa-srv 10
sleep 3600echo "Asia 80% , Euro 10%, USA 10%"
/usr/sbin/lxcf cpurate asia-srv 80
/usr/sbin/lxcf cpurate euro-srv 10
/usr/sbin/lxcf cpurate usa-srv 10
sleep 3600
done
cpun (CONTAINER_NAME | UUID) CPU_NUMBER
Limit available CPUs for the container.
When 0 is specified for cpu number, cpu0 is allocated.
When 0-3 is specified for cpu number, cpu0-3 are allocated.
When 3,8 are specified for cpu number, cpu3 and cpu8 are allocated.
Note) Do not include the blank between the numbers when you specify two or more CPUs.
Example)
# lxcf cpun asia-srv 0
# lxcf cpun asia-srv 0-3
# lxcf cpun asia-srv 3,8
cpurate (CONTAINER_NAME | UUID) CPU_RATE
Limit cpu usage rate for the container.
The value from 0 to 100 can be set to the cpu usage rate.
When two or more CPUs are allocated, the same cpu usage rate is applied to all CPUs.
For instance, when cpu0 and cpu1 are allocated and the cpu rate is specified as 50%, each of cpu0 and cpu1 can be used by 50%.
When - is specified, the limit is removed.
numa (CONTAINER_NAME | UUID) NUMA_NUMBER
Limit available numa-node for the container.
When 0 is specified for numa node number, numa node number 0 is allocated.
When 0-3 is specified for numa node number, numa node number 0-3 is allocated.
When 1,3 are specified for numa node number, numa node number 1 and 3 are allocated.
Note) Do not include the blank between the numbers when you specify two or more NUMA nodes.
memlimit (CONTAINER_NAME | UUID) MEMORY_LIMIT
Limit the amount of available memory for the container.
The floating point number can be specified for the amount of the memory, and the unit of k, M, G, and T can be added.
Example)
# lxcf memlimit lxc-bench1 512M
memswlimit (CONTAINER_NAME | UUID) MEMORY&SWAP_LIMIT
Limit the amount of available memory+swap for the container.
The floating point number can be specified for the amount of the memory+swap, and the unit of k, M, G, and T can be added.
When - is specified, the limit is removed.
Example)
# lxcf memswlimit lxc-bench1 512M
blkio_r (CONTAINER_NAME | UUID) DEVICE BLKIO_READ_LIMIT
blkio_w (CONTAINER_NAME | UUID) DEVICE BLKIO_WRITE_LIMIT
Limit device's throughput of read and write for the containers.
DEVICE is specified as the form of "Majors number:Minor number".
The unit of k, M, G, and T (per sec.) can be added to the limitation value.
When - is specified, the limit is removed.
To set the limitation value for more than two devices, you need to run this command repeatedly for each device as the following example.
Example)
# LXCF blkio_r asia-srv 8:0 10M
# LXCF blkio_r asia-srv 9:0 20M
blkiops_r (CONTAINER_NAME | UUID) DEVICE BLKIOPS_READ_LIMIT
blkiops_w (CONTAINER_NAME | UUID) DEVICE BLKIOPS_WRITE_LIMIT
Limit device's IOPS for the container.
BLKIOPS_READ_LIMIT/BKLIOPS_WRITE_LIMIT is specified in the form of "Majors number:Minor number". Only positive integer values are allowed.
When - is specified, the limit is removed.
To set the limitation value for more than two devices, you need to run this command repeatedly for each device.
net_cls (CONTAINER_NAME | UUID) NET_CLS_ID
Specify network traffic handle for the container, which can be used in “tc”.
By setting NET_CLS_ID (hexadecimal number), the band class label is assigned to the xmit network packet.
User can limit network bandwidth by using the label with "tc" command. Please refer to "tc" manual for details.
set [-c CPURATE] [-i CPU-Number] [-n NUMA-Number] [-m MEMLIMIT] [-s MEMSWLIMIT] (CONTAINER_NAME | UUID) ...
Set some different types of resources at a time for the container.
Details about each option values are described in cpurate, cpun, numa, memlimit and memswlimit command.
show [(CONTAINER_NAME | UUID)]
Show current settings of resources in JSON format.
Example)
# show asia-srv
{"name" : "asia-srv",
"cpun" : "0-15",
"cpurate" : "-",
"numa" : "0-3",
"memlimit" : "1.0G",
"memswlimit" : "-",
"blkio_r" : [ ],
"blkio_w" : [ ],
"blkiops_r" : [ ],
"blkiops_w" : [ ],
"net_cls" : "00000000" }
sysgen [-h] [-o] [-s] [-j] [-c json-file] [-p path] CONTAINER_NAME ...
Create a new LXCF container named as CONTAINER_NAME.
After creation, it starts automatically.
When -c option is specified, the resources for the container are set according to the specified json-file.
When -p option is specified, the file tree for the container is placed on the specified path.
Example)
The same resource value with asia-srv is set to euro-srv newly made.
# lxcf show asia-srv
{"name" : " asia-srv ",
"cpun" : "0-15",
"cpurate" : "-",
"numa" : "0-3",
"memlimit" : "1.0G",
"memswlimit" : "-",
"blkio_r" : [ ],
"blkio_w" : [ ],
"blkiops_r" : [ ],
"blkiops_w" : [ ],
"net_cls" : "00000000" }
# lxcf show asia-srv > asia-srv.json
# lxcf sysgen –c asia-srv.json euro-srv
clone [-p path] (SRC_CONTAINER_NAME | UUID) NEW_CONTAINER_NAME ...
Clone an existing container.
In SEPARATE model, all file trees including /opt etc. are cloned.
In JOINT model, files under /user are just shared, the other file trees are copied.
When -p option is specified, the file tree for the container is placed on the specified path.
erase (CONTAINER_NAME | UUID) ...
Stop and Erase an existing conainer. All configuration information and file-tree about the container are discarded.
list [ -q ] [(CONTAINER_NAME | UUID) ...]
List existing containers information including the name, mode, state and path.
Optional -q displays the list of queue.
Example)
# lxcf list
Name Mode State Path
a-srv joint stopped /opt/lxcf/a-srv
b-srv joint stopped /opt/lxcf/b-srv
c-srv joint stopped /opt/lxcf/c-srv
d-srv joint running /opt/lxcf/d-srv
e-srv joint running /opt/lxcf/e-srv
f-srv joint running /opt/lxcf/f-srv
log [-f]
Log (/var/log/lxcf/lxcf-messages) of LXCF is displayed.
When the content of the log keeps increasing if the option of -f is specified, the added log data is output.
console (CONTAINER_NAME | UUID)
The console command is connected with the console of the container.
Please push "ctrl]" when you end the console.
The display and the input fall into disorder when connecting it from two or more terminals with one console. Therefore, please avoid it.
autostart [ -d ] (CONTAINER_NAME | UUID) ...
Set the container to start automatically at system boot time.
When -d option is specified, the autostart setting is removed.
rename CONTAINER_NAME NEW_CONTAINER_NAME
Container-name is changed into new-container-name.
It is convenient to convert the container prepared beforehand into the name
that the user demands and to offer it.
update COMMAND
The command specified by COMMAND is executed on all LXCF container environments and the host.
The command is supposed to install, update or delete packages, such as rpm, yum, etc.
deploy [-d] [-f] FILE|DIR ...
One or more files and directories specified in the argument are forwarded(copied) to all containers.
When -d option is specified, the files and the directories specified in the argument are deleted from all containers.
The confirmation of (Yes/No) is necessary for the deletion. -f can be used for avoiding the confirmation.
start (CONTAINER_NAME | UUID) ...
Start specified LXCF container.
stop (CONTAINER_NAME | UUID) ...
Stop specified LXCF container.
reboot (CONTAINER_NAME | UUID) ...
Reboot specified LXCF container.
suspend (CONTAINER_NAME | UUID) ...
Suspend specified LXCF container.
resume (CONTAINER_NAME | UUID) ...
Restart suspended LXCF container.
run (CONTAINER_NAME | UUID) COMMAND
Run arbitrary command in specified LXCF container.
sysgen-n [-p path] [-c resource-file] name-prefix [start-number] end-number
clone-n [-p path] name-prefix [start-number] end-number
erase-n name-prefix [start-number] end-number
start-n name-prefix [start-number] end-number
stop-n name-prefix [start-number] end-number
suspend-n name-prefix [start-number] end-number
resume-n name-prefix [start-number] end-number
set-n [-c CPURATE] [-a Num-of-CPU ] [-i CPU-Number] [-n NUMA-Number] [-m MEMLIMIT] [-s MEMSWLIMIT] name-prefix [start-number] end-number
autostart-n [ -d ] name-prefix [start-number] end-number
Operate some containers at a time which named combination of name-prefix and number.
− When start-number is specified, the range of numbers is from start-number to end-number.
− When start-number is NOT specified, the range of numbers is from 1 to end-number.
The number is expressed in 4-digit. The lack of digit is complemented by 0.
The range of numbers needs not to be strict.
Lack and orverlap of containers coresponding to the name is allowed and the operation is processed well without any error.
For instance, let's assume there is only mc0003.
When "stop-n mc 10" is executed, mc0003 only stops.
When "sysgen-n 2 4" is executed, it does not influence mc0003 though mc0002 and mc0004 are generated.
The set-n command is different from the set command, and optional -a has increased. This option specifies the number of allocated CPU.
Example)
# sysgen-n mc 3
Container mc0001, mc0002, and mc0003 are made.
# sysgen-n spc 8 11
Container spc0008, spc0009, spc0009, spc0010, and spc0011 are made.
submit [ -h ] [ -q ] [ -l ] LXCF_COMMAND
The LXCF command is entered as a job.
The command that can be used is the following.
sysgen, sysgen-n, clone, clone-n, set, set-n, erase, erase-n, update, deploy, restore, autostart, autostart-n
Example)
# lxcf submit sysgen new-cont
submited : dbc73b32-c445-11e3-9045-00d068148bd6
“sysgen new-cont” enters Q-QUEUE as a job.
queue cancel UUID
The job on the queue of UUID is canceled.
Example)
# lxcf queue cancel 5cbd8386-c446-11e3-8a9f-00d068148bd6
Canceled : 5cbd8386-c446-11e3-8a9f-00d068148bd6 sysgen-n b 10
queue clear [ -h ] [ -q ] [ -l ] [ -a ]
All jobs on the queue are cleared.
When the option of -h, -q, -l is specified, the queue of H-QUEUE, Q-QUEUE, and L-QUEUE is cleared.
When -a is specified, all queues are cleared.
If the option is not specified, the Q-QUEUE is cleared.
queue list
The job on the queue is displayed.
Example)
# lxcf queue list
H-QUEUE
Q-QUEUE
f12ce8ee-c447-11e3-a39f-00d068148bd6 sysgen-n 1 10
f333abd2-c447-11e3-84f2-00d068148bd6 sysgen-n a 10
L-QUEUE
queue move [-h] [-q] [-l] UUID
It is moved at the end of the queue that specifies the job.
If the option of -h, -q, -l is specified, the queue of H-QUEUE, Q-QUEUE, and L-QUEUE becomes an object respectively.
If the option is not specified, Q-QUEUE becomes an object.
Example)
# lxcf queue move -h f333abd2-c447-11e3-84f2-00d068148bd6
moved to H-QUEUE : f333abd2-c447-11e3-84f2-00d068148bd6 sysgen-n a 10
queue multi [NUMBER]
The multiplicity of the submitted job execution is set.
The multiplicity is displayed when there is no argument.
snapshot [ -f ] [ -p PATH ] [ -n SNAPSHOT_IMAGE ] (UUID | NAME)
The image of the snapshot of the container of specified UUID or container NAME is made, and it puts it under the directory of PATH.
As for the container that takes the snapshot, the state of running and the state of stop are acceptable.
It becomes an error when the snapshot image of the same name is already under PATH. When optional -f is specified, it is overwrited even if the snapshot image of the same name is under PATH.
Optional -p shows path where SNAPSHOT_IMAGE is arranged. -p is not specified, "/opt/lxcf_rep" is path.
Optional -n specifies the name of the snap shot. When the name is not specified, the name of the snap shot becomes "UUID_NAME.img" from UUID and NAME of the object container.
restore [ -n NEW_NAME ] [ -p PATH ] [ -f ] [ -s ] SNAPSHOT_IMAGE
SNAPSHOT_IMAGE is restored as a container.
It is restored by UUID and the container name when the image is gathered when
there is no argument.
When the container of the same name already exists, it becomes an error.
When optional -n is specified, the container is made, and restored by specified container name NEW_NAME and UUID newly allocated. At this time, it becomes an error when there is already a container of the same name.
The -p option specifies PATH that arranges the container similarly to sysgen.
After deleting it even if there is a container of the same name, the –f option restores
the image.
The -s option compares the package environment from which SNAPSHOT_IMAGE is made with the package environment of the server, and adds an insufficient package.
Optional -p shows path where SNAPSHOT_IMAGE is arranged. -p is not specified, "/opt/lxcf_rep" is path.
pull [ -f ] [ -s ] [ -p PASSWORD ] [ -n NEW_SNAP_NAME ] SERVER_NAME:PORT SNAPSHOT_NAME
The snap shot image on other servers is acquired.
The server that becomes an object is specified with SERVER_NAME:PORT.
The snap shot image that becomes an object is specified with SNAPSHOT_NAME.
-f The option overwrites the snap shot image of the same name.
-s The option controls the display of the result.
-p The option specifies the password of lxcf in the server that becomes an object. Specification is unnecessary if there is no password.
-n The option names a new name to the snap shot image.
snapshot-list [ -p PASSWORD ] [ -i SERVERNAME:PORT ] [ SNAPSHOT_IMAGE ... ]
The list of the image in the repository is displayed when there is no
argument.
When SNAPSHOT_IMAGE is specified for the argument, the container name in
the image is displayed.
When the list of snapshot of an outside server is seen, "Password" of the server is pecified by -p, specifying "Server name: the port" by -i.
snapshot-erase [ -f ] SNAPSHOT_IMAGE ...
Command that deletes SNAPSHOT_IMAGE.
The deletion confirmation message is not displayed when there is
optional -f.
api ( enable | disable )
Enable・disable of REST API is specified.
The initialization of API is disable. After the reboot, the setting is effective.
The value to which enable is set with specification or ipaddr:port of/etc/lxcf/lxcf.conf is begun.
REST API stops when disable is specified.
api-passwd
The password when REST API is input.
There is no initial password, and REST API can be executed by an empty password.
If the value is not put by the password input, an empty password is set.
export-docker (UUID | NAME) ...
The LXCF container is exported to the docker container.
The separate model can be handled as docker container.
When the container that converts the joint model is used, it should mount /usr.
net-add [ -d NETDEV ] [ -n NUMBER ] [ -g GATEWAY ] [ -b BRIDGE ] CONTAINER_NAME IPADDR/MASK
IPADDR/MASK is allocated in the container of CONTAINER_NAME.
Please note that the network information disappears all of IPADDR/MASK set with net-add when the container is stopped or is rebooted.
-d : It comes to be able to connect it outside by sharing NIC when NETDEV is set optional -d it. It is shared with the container connected with the same bridge.
-n : In optional -n, two or more VETH can be connected with the container. NUMBER is put up at the end of the VETH name.
-g : In optional -g, default GATEWAY is set.
-b : In optional -b, VETH is connected with BRIDGE. If -b is not specified, it is connected with lxcfbr0. It is newly made when there is no bridge, and if it is existing, it is used.
Example)
# lxcf net-add a-srv 192.168.3.2/24
192.168.3.2/24 is added to container a-srv. This address can be connected only from HOST.
It is connected with bridge lxcfbr0.
# lxcf net-add b-srv 192.168.3.3/24
It adds in b-srv and it adds it to 192.168.3.3/24. Because the network is the same, it is possible to connect it also with a-srv.
Eth1(192.168.3.100/24) connected outside is connected with c-srv. GATEWAY is 192.168.3.1.
# As for lxcf net-add -d eth1 -g 192.168.3.1 c-srv 192.168.3.3/24 a-srv, b-srv, and c-srv, the connection with the outside becomes possible.
net-del [ -n NUMBER ] CONTAINER_NAME
net-del -b BRIDGE
VETH added to the container is deleted.
-n : Optional -n is deleted expressly specifying VETH NUMBER .
-b : When optional -b is specified, the corresponding bridge is deleted.
net-gateway CONTAINER_NAME IP_ADDR
The gateway is set to the container.
net-route -a [ -n NUMBER ] CONTAINER_NAME NET_ADDR GATEWAY
net-route -d CONTAINER_NAME NET_ADDR
Routing information on the container is updated.
-a : Optional -a is added routing information.
-d : Optional- d is deleted routing information.
net-list [ -b ]
Information on the added network is displayed.
-b : Bridge information is displayed in optional -b.
helpcmd
Display the list of the command of LXCF.
version
Display the version of LXCF.