How to monitor the hard disk status
How to monitor the hard disk status
Checking if SMART is enabled
Find out the names of your hard disks by using one of the following commands:
df -h fdisk -l
Let’s become familiar with the smartctl utility. The first thing we want to check is if S.M.A.R.T support is active on the device. To perform this operation we can run the smartctl utility with the -i option (short for --info):
$ sudo smartctl -i /dev/sda
The output of the command is the following:
smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-193.28.1.el8_2.x86_64] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Vendor: LSILOGIC Product: Logical Volume Revision: 3000 User Capacity: 498 999 492 608 bytes [498 GB] Logical block size: 512 bytes Logical Unit id: 0x600508e0000000002bc75cd385bf0d0c Device type: disk Local Time is: Tue Oct 25 14:17:01 2022 CEST SMART support is: Unavailable - device lacks SMART capability.
We can see that basic information are displayed such as the device family, model, sector sizes, etc. What interests us the most, however is the content of the last two lines. From there we can see that the device has SMART capabilities and that, in this case, SMART support is disabled. What if we want to enable it? All we have to do is to run smartctl with the -s option, using “on” as argument:
smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-193.28.1.el8_2.x86_64] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org =======> INVALID ARGUMENT TO -s: /dev/sda =======> VALID ARGUMENTS ARE: on, off, aam,[N|off], apm,[N|off], dsn,[on|off], lookahead,[on|off], security-freeze, standby,[N|off|now], wcache,[on|off], rcache,[on|off], wcreorder,[on|off[,p]], wcache-sct,[ata|on|off[,p]] <======= Use smartctl -h to get a usage summary Getting familiar with smartctl To get all the available SMART information about a storage device, we can launch the utility with the -a option (short for -all) and of course pass the path of the device we want to check as the last argument of the command. Suppose we want to check the current status of the /dev/sda device; we would run: $ sudo smartctl -a /dev/sda The command above produces a lot of output. Among the other things, we can see the status of various SMART parameters:
smartctl 7.1 2020-04-05 r5049 [x86_64-linux-4.18.0-193.28.1.el8_2.x86_64] (local build) Copyright (C) 2002-19, Bruce Allen, Christian Franke, www.smartmontools.org === START OF INFORMATION SECTION === Vendor: LSILOGIC Product: Logical Volume Revision: 3000 User Capacity: 498 999 492 608 bytes [498 GB] Logical block size: 512 bytes Logical Unit id: 0x600508e0000000002bc75cd385bf0d0c Device type: disk Local Time is: Tue Oct 25 14:19:37 2022 CEST SMART support is: Unavailable - device lacks SMART capability. === START OF READ SMART DATA SECTION === Current Drive Temperature: 0 C Drive Trip Temperature: 0 C Error Counter logging not supported Device does not support Self Test logging
RAID Commands
fdisk -l
lblsk
lshw -class disk - show all disk with information
smartctl --scan - show all installed disks
smartctl -d sat -all /dev/sg1
lspci |grep -i raid
lspci -vv | grep -i raid
cat /proc/scsi/scsi
# smartctl -a /dev/sda -d sat+megaraid,00
-
Show all physical disks on controller 0
$ omreport storage pdisk controller=0 -
Show all logical disks on controller 0
$ omreport storage vdisk controller=0 -
Show all physical disks on vdisk 0
$ omreport storage pdisk controller=0 vdisk=0 -
Reconfigure a vdisk to be raid1 from raid0 (COOL!!!!)
$ sudo omconfig storage vdisk action=reconfigure controller=0 vdisk=1 raid=r1 pdisk=0:0:2,0:0:3 -
omreport storage pdisk controller=0 vdisk=0 | grep -v ": Not "
How To Change a MariaDB Data Directory to a New Location on CentOS
How To Change a MariaDB Data Directory to a New Location on CentOS
1 — Moving the MariaDB Data Directory
To prepare for moving MariaDB’s data directory, let’s verify the current location by starting an interactive session using the administrative credentials.
#mysql -u root -p
When prompted, supply the MariaDB root password. Then from the mysql prompt, select the data directory:
> select @@datadir;
/var/lib/mysql/
This output confirms that MariaDB is configured to use the default data directory, /var/lib/mysql/, so that’s the directory we need to move.
To ensure the integrity of the data, we’ll stop service - MariaDB before we actually make changes to the data directory:
# systemctl stop mariadb
to check if the service is stopped use the command:
#systemctl status mariadb
Sep 11 12:21:04 mysql systemd[1]: Stopped MariaDB database server.
Now that the server is shut down, we’ll copy the existing database directory to the new location with rsync. Using the -a flag preserves the permissions and other directory properties, while-v provides verbose output so you can follow the progress.
Note: Be sure there is no trailing slash on the directory, which may be added if you use tab completion. When there’s a trailing slash, rsync will dump the contents of the directory into the mount point instead of transferring it into a containing mysql directory:
#rsync -av /var/lib/mysql /mnt/volume-mariadb
Once the rsync is complete, rename the current folder with a .bak extension and keep it until we’ve confirmed the move was successful. By re-naming it, we’ll avoid confusion that could arise from files in both the new and the old location:
#mv /var/lib/mysql /var/lib/mysql.bak
Step 2 — Pointing to the New Data Location
MySQL has several ways to override configuration values. By default, the datadir is set to /var/lib/mysql in the /etc/my.cnf file. Edit this file to reflect the new data directory:
#vi /etc/my.cnf
SQL. Search for any text or integer in the database
SQL. Search for any text or integer in the database
Small queries to search for any number or text in the desired MS SQL database.
Find an integer.
- set nocount on
- declare @name varchar(128), @substr bigint, @column varchar(128)
- set @substr = 462083 -- ИСКОМОЕ ЦЕЛОЕ ЧИСЛОВОЕ ЗНАЧЕНИЕ
- /* Create a table for output */
- create table #rslt2
- (table_name varchar(128), field_name varchar(128), value bigint)
- /* Populate the created table with the found data */
- declare s cursor for select table_name as table_name from information_schema.tables where table_type = 'BASE TABLE' order by table_name
- open s
- fetch next from s into @name
- while @@fetch_status = 0
- begin
- declare c cursor for
- select quotename(column_name) as column_name from information_schema.columns
- where data_type in ('int', 'bigint') and table_name = @name
- set @name = quotename(@name)
- open c
- fetch next from c into @column
- while @@fetch_status = 0
- begin
- print 'Processing table - ' + @name + ', column - ' + @column
- exec('insert into #rslt2 select ''' + @name + ''' as Table_name, ''' + @column + ''', ' + @column +
- ' from' + @name + ' where ' + @column + ' = ' + @substr )
- fetch next from c into @column
- end
- close c
- deallocate c
- fetch next from s into @name
- end
- select table_name as [Table Name], field_name as [Field Name], count(*) as [Found Mathes] from #rslt2
- group by table_name, field_name
- order by table_name, field_name
- /* Display found values if needed (uncomment next line) */
- -- select * from #rslt2 order by table_name, field_name
- drop table #rslt2
- close s
- deallocate s
Wyszukaj ciąg znaków.
- set nocount on
- declare @name varchar(128), @substr nvarchar(4000), @column varchar(128)
- set @substr = '%Пружинкин%' -- ФРАГМЕНТ ИСКОМОЙ СТРОКИ
- /* Create a table for output */
- create table #rslt
- (table_name varchar(128), field_name varchar(128), value ntext)
- /* Populate the created table with the found data */
- declare s cursor for select table_name as table_name from information_schema.tables where table_type = 'BASE TABLE' order by table_name
- open s
- fetch next from s into @name
- while @@fetch_status = 0
- begin
- declare c cursor for
- select quotename(column_name) as column_name from information_schema.columns
- where data_type in ('text', 'ntext', 'varchar', 'char', 'nvarchar', 'char', 'sysname') and table_name = @name
- set @name = quotename(@name)
- open c
- fetch next from c into @column
- while @@fetch_status = 0
- begin
- print 'Processing table - ' + @name + ', column - ' + @column
- exec('insert into #rslt select ''' + @name + ''' as Table_name, ''' + @column + ''', ' + @column +
- ' from' + @name + ' where ' + @column + ' like ''' + @substr + '''')
- fetch next from c into @column
- end
- close c
- deallocate c
- fetch next from s into @name
- end
- select table_name as [Table Name], field_name as [Field Name], count(*) as [Found Mathes] from #rslt
- group by table_name, field_name
- order by table_name, field_name
- /* Display found values if needed (uncomment next line) */
- --select * from #rslt order by table_name, field_name
- drop table #rslt
- close s
- deallocate s
How to Check CentOS Version
How to Check CentOS Version From Command Line
lsb Command to Display Details of CentOS Linux Release
LSB (Linux Standard Base) is a joint project of several Linux distributions to standardize software system structure. One of the commands available from the command line lsb_release. The output will indicate which OS version you are running.
1. Before you can use lsb commands, you have to install the package first. Use the following command:
# sudo yum install redhat-lsb-core
2. Type in your sudo password to authorize the installation and then press Y and Enter to confirm.
3. Once you have installed it, you can check your CentOS/REHL version as shown with the command:
# lsb_release -dor
# lsb_release -a
Find CentOS Version with the hostnamectl Command CentOS version 7 and next distributions,
hostnamectl command is used to query and set Linux system hostname, and show other system related information, such as operating system release version
It displays information from the
/etc/centos-release file,
uname –a file and others.
In addition to version number, it indicates which Linux kernel your system is using.
To see these specifics, use the command:
# hostnamectl
Find CentOS Version with RPM - RPM (Red Hat Package Manager) is a popular open-source and core package management utility for Red Hat based systems like (RHEL, CentOS, Fedora).
With the rpm command, you can find out the full package name and the release version of CentOS you are running.
Use the command:
# rpm –qa centos-release
or
# rpm -ql centos-release | grep release$
or
# rpm -qf /etc/redhat-release
Check CentOS Version in Release File To check which Linux distro and major release version you have installed,
open the release file using the command:
# cat /etc/os-release
The output reveals the name of the operating system, its major release version,
and other specifics, as displayed in the image below.
Check Linux Kernel Version in CentOS Knowing the kernel version you are running is often as useful as finding the release version.
Find out which Linux kernel version you running, with the command:
# uname –r
or
# uname -s -r
The output you receive is the version number of the kernel of your operating system.
The 4 files shown below provides the update version of the CentOS/Redhat OS.
/etc/centos-release
/etc/os-release
/etc/redhat-release
/etc/system-release
Страница 20 из 58