[Openstack] Create virtual machine in console

Open environment variable script

source your_admin-openrc

Create image from file

openstack image create --disk-format qcow2 --public --file ubuntu1604-image.qcow2 ubuntu1604

Create volume for virtual machine from image

openstack volume create --size 11 --image ubuntu1604 ubuntu1604-volume

If flavor not exist, crate one.

openstack flavor create --ram 8096 --vcpus 4 --public --disk 15 m1.large

Create simple network

openstack network create local
openstack subnet create local_subnet --network local --subnet-range 10.10.10.0/24 --allocation-pool start=10.10.10.10,end=10.10.10.20 --dns-nameserver 8.8.8.8

Create vm

Unfortunately when createin vm you have to use network id, not network name

$ openstack network list
+--------------------------------------+-------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+-------+--------------------------------------+
| e5d6ba6a-9866-4089-8125-2d2d90d1e890 | local | ae9e3f32-8e8c-483d-a957-50a0551a7fab |
+--------------------------------------+-------+--------------------------------------+
openstack server create --volume ubuntu1604-volume --flavor m1.large  --nic net-id=network_uuid ubuntu1604-vm

How to edit system images (e.g. Rasbian, Openstack)

We can use guestfish a simple tool to edit images file

Open file with command

guestfish -a OrangePi_2G-IOT_Ubuntu1604_Server_GSMPPP_V1_0.img
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
 'man' to read the manual
 'quit' to quit the shell

><fs> run
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
><fs> list-filesystems 
/dev/sda1: ext2
/dev/sda2: ext4
><fs> mount /dev/sda2 /
><fs> edit /etc/network

 

PostgreSQL console

Useful Commands

Here are a few commands that can help you get an idea of your current environment:

  • \?: Get a full list of psql commands, including those not listed here.
  • \h: Get help on SQL commands. You can follow this with a specific command to get help with the syntax.
  • \q: Quit the psql program and exit to the Linux prompt.
  • \d: List available tables, views, and sequences in current database.
  • \du: List available roles
  • \dp: List access privileges
  • \dt: List tables
  • \l: List databases
  • \c: Connect to a different database. Follow this by the database name.
  • \password: Change the password for the username that follows.
  • \conninfo: Get information about the current database and connection.

systemd

W Centosie 7 wprowadzono do obsługi servisów systemd, w związku z czym z katalogu /etc/init.d znikneły skrypty do obsługi serwisów usług.

Teraz do obsługi serwisów będziemy korzystać z aplikacji service i systemctl

Aby zobaczyć listę dostępnych serwisów:

$systemctl list-unit-files

Jeśli chcemy zatrzymać/uruchomić jakąś usługę:

$service mariadb start

Aby wyświetlić informacje nt. danej usługi.

$service mariadb status
Redirecting to /bin/systemctl status mariadb.service
● mariadb.service – MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: active (running) since wto 2016-04-12 15:27:53 CEST; 1s ago
Process: 886 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
Process: 804 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
Main PID: 885 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─ 885 /bin/sh /usr/bin/mysqld_safe –basedir=/usr
└─1042 /usr/libexec/mysqld –basedir=/usr –datadir=/var/lib/mysql –plugin-dir=/usr/lib64/mysql/plugin –log-error=/var/log/mariadb/mariadb.log –pid-file=/…

kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: The latest information about MariaDB is available at http://mariadb.org/.
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: You can find additional information about the MySQL part at:
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: http://dev.mysql.com
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: Support MariaDB development by buying support/new features from MariaDB
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: Corporation Ab. You can contact us about this at sales@mariadb.com.
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: Alternatively consider joining our community based development effort:
kwi 12 15:27:50 backup01 mariadb-prepare-db-dir[804]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
kwi 12 15:27:50 backup01 mysqld_safe[885]: 160412 15:27:50 mysqld_safe Logging to ‘/var/log/mariadb/mariadb.log’.
kwi 12 15:27:50 backup01 mysqld_safe[885]: 160412 15:27:50 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
kwi 12 15:27:53 backup01 systemd[1]: Started MariaDB database server.