iSCSI Technology application database service base Management table data

Source: Internet
Author: User
Tags yum repolist

Operating mode for iSCSI disks

? Internet SCSI, inter-network SCSI interface
– A virtual disk technology based on C/s architecture
– The server provides disk space, the client connects and uses it as a local disk

? ISCSI qualified name specification
–iqn.yyyy-mm. Reverse Domain name: custom identity
– Used to identify target disk groups and to identify client identities

Iqn.2018-3.com.example:server0

Server: Virtual Machine SERVER0
1. Partitioning/dev/vdb
[Email protected] ~]# FDISK/DEV/VDB
N-----> Create a new partition 5G

[Email protected] ~]# LS/DEV/VDB1
/dev/vdb1
[Email protected] ~]# lsblk

2. Install the server-side package and provide a shared storage service program
[Email protected] ~]# yum-y install TARGETCLI

3. Run TARGETCLI, interactive interface

? Establish back-end storage:/backstore/block Create backend Store name actual device path

? Set up a disk group (equivalent to the box that holds the partition):/iscsi The IQN name of the Create Disk group

? Put the shared partition in the box:/iscsi/Disk group name/tpg1/luns Create backend storage path

? Specify the IP address that provides the service:/iscsi/Disk group name/tpg1/portals Create IP address

? Settings for access control:/iscsi/Disk group name/TPG1/ACLS Create client claim name

[Email protected] ~]# TARGETCLI
/> Backstores/block Create iscsi_nsd/dev/vdb1

/> Iscsi/create Iqn.2018-03.com.example:server0

/> Iscsi/iqn.2018-03.com.example:server0/tpg1/luns CREATE/BACKSTORES/BLOCK/ISCSI_NSD

/> Iscsi/iqn.2018-03.com.example:server0/tpg1/portals Create 172.25.0.11

/> Iscsi/iqn.2018-03.com.example:server0/tpg1/acls Create
Iqn.2018-03.com.example:desktop0

/> ls
/> Exit
4. Start the target service
[Email protected] ~]# systemctl restart target #重起target服务
[Email protected] ~]# Systemctl enable target #设置为开机自启动

################################################################
Client: Virtual Machine Desktop0

1. Install the client software to access iSCSI shared storage
[email protected] ~]# Yum repolist #生成Yum的缓存

[Email protected] ~]# yum-y install iscsi-initiator-utils.i686

2. When setting up client access, the claimed name
[Email protected] ~]# VIM/ETC/ISCSI/INITIATORNAME.ISCSI

Initiatorname=iqn.2018-03.com.example:desktop0

3. Refresh the client iqn name
[Email protected] ~]# systemctl restart Iscsid
Warning:unit file of Iscsid.service changed on disk, ' Systemctl daemon-reload ' recommended.
[Email protected] ~]# Systemctl daemon-reload
[Email protected] ~]# systemctl restart Iscsid
[Email protected] ~]# Systemctl enable Iscsid

4. Load the iSCSI shared storage and access the service side (Ctrl + Ctrl+shift + # to get bigger)
[Email protected] ~]# iscsiadm--mode discoverydb--type sendtargets--portal 172.25.0.11--discover

172.25.0.11:3260,1 Iqn.2018-03.com.example:server0

[Email protected] ~]# systemctl restart iSCSI #重起iscsi服务加载共享存储
[Email protected] ~]# lsblk

##################################################################
Database service Basics

What is a database: The warehouse where the data resides

There are a lot of small libraries in the database, there are a lot of tables in each library, and there are many records in each of these tables.

Table fields: Header

Table Records: Table contents

Deploying the MARIADB Database server
? MariaDB related packages in RHEL7
–mariadb-server: Provision of server-side related system programs

Port: 3306

Build a basic database
1. Installing Mariadb-server
[Email protected] ~]# yum-y install Mariadb-server

2. Turn on the database service
[Email protected] ~]# systemctl restart MARIADB
[Email protected] ~]# Systemctl enable MARIADB

3. Access to MARIADB database basic operations
[[email protected] ~]# MySQL
MariaDB [(None)]> show databases; #查看所有的库
MariaDB [(None)]> CREATE Database nsd; #创建库nsd
MariaDB [(None)]> show databases;
MariaDB [(None)]> drop database nsd; #删除库nsd
MariaDB [(None)]> show databases;
MariaDB [(None)]> CREATE Database nsd1802;
MariaDB [(None)]> show databases;
MariaDB [(None)]> exit

    1. Set the password for the MARIADB database administrator

–mysqladmin [-u user name] [-p[old password]] password ' new password '

The database administrator root is not the same user as the system administrator root

Database administrator root:mysql The user table in the library
System Administrator ROOT:/ETC/PASSWD

[Email protected] ~]# mysqladmin-u root password ' 123 '

[Email protected] ~]# mysql-u root-p

Database master configuration file:/etc/my.cnf

5. Importing data from a database

wget Http://cla***oom.example.com/pub/materials/users.sql

[Email protected] ~]# mysql-u root-p123 nsd1802 < Users.sql

[Email protected] ~]# mysql-u root-p123
MariaDB [(None)]> show databases;

| nsd1802

MariaDB [(None)]> use nsd1802; #进入库nsd1802

MariaDB [nsd1802]> Show tables; #查看当前库的所有表格

There are four actions for a table: Add (insert) Delete (delete) (update) (SELECT)

MariaDB [nsd1802]> Select from base; #显示base表所有字段内容
MariaDB [nsd1802]> Select
from location; #显示location表所有字段内容

View table structure: DESC table name;

MariaDB [mysql]> SELECT * from Nsd1802.base;

6. Database authorization, do not need to create a local user

MariaDB [(none)]> Interactive Instruction

–grant permissions list on database name. Table name to User name @
Client address identified by ' password ';

Grant Select on nsd1802.* to [e-mail protected] identified by ' 123 ';

When the Lisi user enters password 123 from the local localhost login, the query permission for all tables in the nsd1802 library will be obtained.

[Email protected] ~]# mysql-u lisi-p123

[Email protected] ~]# mysql-u root-p123
MariaDB [(None)]> Grant Select on nsd1802.* to [e-mail protected] identified by ' 123 ';

MariaDB [(None)]> exit

[Email Protected]ver0 ~]# mysql-u lisi-p123

Case 5: Working with database queries

    1. Use the database nsd1802 on the system Server0 and use the phase
      The SQL query that is expected to answer the following questions:
      1) password is the name of the person who solicitous?
      Conditional query: where
      [Email protected] ~]# mysql-u root-p123
      MariaDB [(None)]> use nsd1802;

MariaDB [nsd1802]> SELECT * from base;

MariaDB [nsd1802]> SELECT * from base where password= ' solicitous ';

MariaDB [nsd1802]> select name from base where password= ' solicitous ';

MariaDB [nsd1802]> SELECT * from base where name= ' Tom ';

2) How many people's names are Barbara while residing in Sunnyvale? (Multi-Table union query)
MariaDB [nsd1802]> Use nsd1802
MariaDB [nsd1802]> SELECT * from Base,location
where Base.name= ' Barbara ' and location.city= ' Sunnyvale '
and base.id=location.id;

MariaDB [nsd1802]> Select COUNT (*) from base,location
where Base.name= ' Barbara ' and location.city= ' Sunnyvale '
and base.id=location.id;

MariaDB [nsd1802]> Insert Base values (6, ' Barbara ', ' 321 ');
MariaDB [nsd1802]> SELECT * from base;

MariaDB [nsd1802]> Insert Location VALUES (6, ' Sunnyvale ');
MariaDB [nsd1802]> SELECT * from location;

MariaDB [nsd1802]> SELECT * from Base,location
where Base.name= ' Barbara ' and location.city= ' Sunnyvale '
and base.id=location.id;

##################################################################

    1. Disable null password root user access to MARIADB database (user table is the information table for logged-in database users)

MariaDB [nsd1802]> use MySQL;

MariaDB [mysql]> Select User,host,password from user;

MariaDB [mysql]> Select User,host,password from user where password= ';

MariaDB [mysql]> Delete from user where password= '; #删除表记录

MariaDB [mysql]> flush Privileges; #刷新数据库策略
MariaDB [mysql]> exit

[Email protected] ~]# mysql-u root-h server0.example.com #测试网络登陆

###############################################################

iSCSI Technology application database service base Management table data

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.