Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux Notes 13

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Master-slave DNS synchronization

When a single DNS cannot meet the needs of customers, a synchronous secondary DNS is opened, and the content of their dns is consistent.

Host:

Vim / etc/named.rfc1912.zones

Zone "asd.com" IN {

Type master

File "asd.com.zone"

Allow-update {none;}

Allow-transfer {172.25.254.225;; slave address

}

Systemctl restart named

Slave:

Yum install bind-y installation service

Vim / etc/named.conf modify configuration file

Options {

Listen-on port 53 {any;}

Listen-on-v6 port 53 {:: 1;}

Directory "/ var/named"

Dump-file "/ var/named/data/cache_dump.db"

Statistics-file "/ var/named/data/named_stats.txt"

Memstatistics-file "/ var/named/data/named_mem_stats.txt"

Allow-query {any;}

The dnssec-validation no; is consistent with the host

Vim / etc/named.rfc1912.zones

Zone "asd.com" IN {

Type slave; is set as a slave

Masters {172.25.254.125;}; host address

File "slaves/asd.com.zone"

Allow-update {none;}

}

Systemctl restart named restart service

(test results)

[root@localhost ~] # dig www.asd.com

; DiG 9.9.4-RedHat-9.9.4-14.el7 www.asd.com

;; global options: + cmd

;; Got answer:

;;-> > HEADER update delete www.asd.com deletion

> send by send

> server 172.25.254.125

> update add www.asd.com 86400 A 172.25.254.120 add a new dns (86400 cache for one day)

> send

> quit exit

Note: when finished > server 172.25.254.125

> update delete www.asd.com

> send

The / var/named/ on the back host side will send an asd.com.zone.jnl.

After systemctl retsart named, the file will overwrite the original asd.com.zone, so it is recommended to back up in advance.

"Test results"

The dns service of the host can be changed remotely (can be deleted and added)

DNS remote Update (encryption)

Host:

Dnssec-keygen-a HMAC-MD5-b 100-n HOST gou (- an encryption type-b encryption bytes-n encryption purpose)

Get public and private keys

Cp-p / etc/rndc.key / etc/gou.key copy template

Content written by vim / etc/gou.key

Key "gou" {encrypted name

Algorithm hmac-md5; format

Secret "/ pLHdCuATXkKuZNjGQ=="; password

}

Vim / etc/named.conf

43 include "/ etc/gou.key"

Vim / etc/named.rfc1912.zones modify configuration file

Zone "asd.com" IN {

Type master

File "asd.com.zone"

Allow-update {key gou;}; only accept modifications from people with key

}

Scp Kgou.+157+64442.* root@172.25.254.225:/mnt remotely sends a password to the user to update dnsderen

Systemctl restart named restart service

Sender:

[root@localhost mnt] # nsupdate-k Kgou.+157+64442.private (- k uses keys)

> server 172.25.254.125

> update delete www.asd.com deletion

> send

> quit exit

"Test results"

Root@localhost named] # ls

Asd.com.zone data named.ca named.localhost slaves

Asd.com.zone.jnl dynamic named.empty named.loopback

Root@localhost named] # dig www.asd.com

; DiG 9.9.4-RedHat-9.9.4-14.el7 www.asd.com

;; global options: + cmd

;; Got answer:

;;-> > HEADER SHOW DATABASES; display database

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

+-+

3 rows in set (0.00 sec)

MariaDB [(none)] > USE mysql; enters the database

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with-A

Database changed

MariaDB [mysql] > SHOW TABLES; displays tables in the database

+-+

| | Tables_in_mysql |

+-+

| | columns_priv |

| | db |

| | event |

| | func |

| | general_log |

| | help_category |

| | help_keyword |

| | help_relation |

| | help_topic |

| | host |

| | ndb_binlog_index |

| | plugin |

| | proc |

| | procs_priv |

| | proxies_priv |

| | servers |

| | slow_log |

| | tables_priv |

| | time_zone |

| | time_zone_leap_second |

| | time_zone_name |

| | time_zone_transition |

| | time_zone_transition_type |

| | user |

+-+

24 rows in set (0.00 sec)

MariaDB [mysql] > SELECT User,Host,Password FROM user; View the host,user,password field in the user table

+-- +

| | User | Host | Password | |

+-- +

| | root | localhost | * 28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

| | root | 127.0.0.1 | * 28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

| | root |:: 1 | * 28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

+-- +

3 rows in set (0.00 sec)

MariaDB [mysql] > CREATE DATABASE asd; create a database

MariaDB [mysql] > USE asd; enters the database

MariaDB [asd] > CREATE TABLE UTAB (uer varchar (10) not null, password varchar (8) not null, age varchar (3)); create a table (user name [10], password [8], age [3] can not be added)

MariaDB [asd] > SHOW TABLES; display database

+-+

| | Tables_in_asd |

+-+

| | UTAB |

+-+

MariaDB [asd] > DESC UTAB; displays the properties of the table

+-+ +

| | Field | Type | Null | Key | Default | Extra | |

+-+ +

| | uer | varchar (10) | NO | | NULL |

| | password | varchar (8) | NO | | NULL |

| | age | varchar (3) | YES | | NULL |

+-+ +

MariaDB [asd] > INSERT INTO UTAB VALUES ('asd','qwe','24'); add content to the table

Query OK, 1 row affected (0.00 sec)

MariaDB [asd] > SELECT * FROM UTAB; display table

+-+

| | uer | password | age | |

+-+

| | asd | qwe | 24 | |

+-+

MariaDB [asd] > ALTER TABLE UTAB ADD class varchar (8) AFTER password; add a field after password

Query OK, 1 row affected (0.03 sec)

Records: 1 Duplicates: 0 Warnings: 0

MariaDB [asd] > UPDATE UTAB SET; class attached value

Query OK, 1 row affected (0.00 sec)

Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [asd] > SELECT * FROM UTAB

+-+

| | uer | password | class | age | |

+-+

| | asd | qwe | 1 | 24 | |

+-+

Modification of MariaDB [asd] > UPDATE UTAB SET WHERE uer='asd'; class value

Query OK, 1 row affected (0.01sec)

Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [asd] > SELECT * FROM UTAB

+-+

| | uer | password | class | age | |

+-+

| | asd | qwe | 3 | 24 | |

+-+

MariaDB [asd] > INSERT INTO UTAB VALUES ('asd','qwe','24')

ERROR 1136 (21S01): Column count doesn't match value count at row 1

MariaDB [asd] > INSERT INTO UTAB VALUES ('gou','qwe','','24')

Query OK, 1 row affected (0.01sec)

MariaDB [asd] > SELECT * FROM UTAB

+-+

| | uer | password | class | age | |

+-+

| | asd | qwe | 3 | 24 | |

| | gou | qwe | | 24 |

+-+

MariaDB [asd] > DELETE FROM UTAB uer='gou'; delete a column

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'uer='gou'' at line 1

MariaDB [asd] > DELETE FROM UTAB WHERE uer='gou'

Query OK, 1 row affected (0.01sec)

MariaDB [asd] > SELECT * FROM UTAB

+-+

| | uer | password | class | age | |

+-+

| | asd | qwe | 3 | 24 | |

+-+

MariaDB [asd] > DROP TABLE UTAB delete table

->

Query OK, 0 rows affected (0.00 sec)

MariaDB [asd] > SELECT * FROM UTAB

ERROR 1146 (42S02): Table 'asd.UTAB' doesn't exist

MariaDB [asd] > DROP DATABASE asd; delete library

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)] > SELECT * FROM UTAB

ERROR 1046 (3D000): No database selected

MariaDB [(none)] > SHOW DATABASES

->

+-+

| | Database |

+-+

| | information_schema |

| | mysql |

| | performance_schema |

+-+

3 rows in set (0.00 sec)

Permissions and access of database users

MariaDB [(none)] > CREATE USER we@localhost identified by 'westos'

Query OK, 0 rows affected (0.00 sec) create user we with password of westos, and can only log in locally (we@'%' can log in remotely)

MariaDB [(none)] > GRANT CREATE ON *. * TO we@localhost

Query OK, 0 rows affected (0.00 sec) authorization can be created in any table of any library

MariaDB [(none)] > SHOW GRANTS FOR we@localhost; permission display

+-+

| | Grants for we@localhost |

+-+

| | GRANT CREATE ON *. * TO 'we'@'localhost' IDENTIFIED BY PASSWORD' * 28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96' |

+-+

1 row in set (0.00 sec)

MariaDB [(none)] > GRANT INSERT ON *. * to we@localhost

Query OK, 0 rows affected (0 sec) can be inserted in any table of any library

MariaDB [(none)] > SHOW GRANTS FOR we@localhost; permission view

+-+

| | Grants for we@localhost |

+-+

| | GRANT INSERT, CREATE ON *. * TO 'we'@'localhost' IDENTIFIED BY PASSWORD' * 28C1E2BE2BE45562A34B6CC34A19CFAFC2F88F96' |

+-+

1 row in set (0.00 sec)

FLUSH PRIVILEGES; overload authorization table

MariaDB [(none)] > REVOKE CREATE on *. * from we@localhost

Query OK, 0 rows affected (0.00 sec) revokes the user's creation permission

MariaDB [(none)] > DROP USER we@localhost; delete user

Query OK, 0 rows affected (0.00 sec)

Database password

When you forget your password:

Systemctl stop mariadb.service out of service

Mysqld_safe-skip-grant-tables & turn on the safe mode

[root@localhost ~] # fg

Mysqld_safe-skip-grant-tables

^ Z

[1] + Stopped mysqld_safe-- skip-grant-tables

Mysql-u root enters the database

MariaDB [(none)] > UPDATE mysql.user set Password='redhat' WHERE User='root'; update password (clear text)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3 Changed: 3 Warnings: 0

| | localhost | root | redhat | Y | Y |

MariaDB [(none)] > UPDATE mysql.user set Password=password ('redhat') WHERE User='root'; update password (encryption)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3 Changed: 3 Warnings: 0

| | localhost | root | * 84BB5DF4823DA319BBF86C99624479A198E6EEE9 | Y | Y |

[root@localhost ~] # fg View backend

Mysqld_safe-skip-grant-tables

^ Z

[1] + Stopped mysqld_safe-- skip-grant-tables

[root@localhost] # killall-9 mysqld_safe shuts down the background process

[1] + Killed mysqld_safe-- skip-grant-tables

[root@localhost ~] # ps aux | grep mysql to view the process

Mysql 3196 0.04.8 859060 91736 pts/0 Sl 20:52 0:00 / usr/libexec/mysqld-basedir=/usr-datadir=/var/lib/mysql-plugin-dir=/usr/lib64/mysql/plugin-user=mysql-skip-grant-tables-log-error=/var/log/mariadb/mariadb.log-pid-file=/var/run/mariadb/mariadb.pid-socket=/var/lib/mysql/mysql.sock

Root 3416 0.0 112640 940 pts/0 R + 20:58 0:00 grep-color=auto mysql

[root@localhost ~] # kill-9 3196 shutdown

Systemctl start mariadb enables the service (you can log in normally)

Change the password:

Mysqladmin-uroot-predhat password westos

Backup and recovery of database

MariaDB [(none)] > CREATE DATABASE westos

MariaDB [westos] > CREATE TABLE UTAB (user varchar (10) not null, password varchar (10) not null, class varchar (5))

MariaDB [westos] > INSERT INTO UTAB VALUES ('asd','123','4')

Query OK, 1 row affected (0.01sec)

MariaDB [westos] > INSERT INTO UTAB VALUES ('lee','123','')

Query OK, 1 row affected (0.01sec)

MariaDB [westos] > SELECT * FROM UTAB

+-+

| | user | password | class | |

+-+

| | asd | 123 | 4 | |

| | lee | 123 |

+-+

(create an experimental database)

[root@localhost ~] # mysqldump-uroot-pwestos westos > / mnt/westos.sql backup database

-- MySQL dump 10.14 Distrib 5.5.35-MariaDB, for Linux (x86 / 64)

--

-- Host: localhost Database: westos

-

-- Server version5.5.35-MariaDB

/ * 40101 SET @ OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT * /

/ * 40101 SET @ OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS * /

/ * 40101 SET @ OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION * /

/ * 40101 SET NAMES utf8 * /

/ * 40103 SET @ OLD_TIME_ZONE=@@TIME_ZONE * /

/ * 40103 SET TIME_ZONE='+00:00' * /

/ * 40014 SET @ OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 * /

/ * 40014 SET @ OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 * /

/ * 40101 SET @ OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' * /

/ * 40111 SET @ OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 * /

--

-- Table structure for table `UTAB`

--

DROP TABLE IF EXISTS `UTAB`

/ *! 40101 SET @ saved_cs_client = @ @ character_set_client * /

/ *! 40101 SET character_set_client = utf8 * /

CREATE TABLE `UTAB` (

`user`varchar (10) NOT NULL

`password` varchar (10) NOT NULL

`class`varchar (5) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1

/ * 40101 SET character_set_client = @ saved_cs_client * /

--

-- Dumping data for table `UTAB`

--

LOCK TABLES `UTAB` WRITE

/ *! 40000 ALTER TABLE `UTAB` DISABLE KEYS * /

INSERT INTO `UTAB` VALUES ('asd','123','4'), (' lee','123','')

/ *! 40000 ALTER TABLE `UTAB` ENABLE KEYS * /

UNLOCK TABLES

/ * 40103 SET TIME_ZONE=@OLD_TIME_ZONE * /

/ * 40101 SET SQL_MODE=@OLD_SQL_MODE * /

/ * 40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS * /

/ * 40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS * /

/ * 40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT * /

/ * 40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS * /

/ * 40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION * /

/ * 40111 SET SQL_NOTES=@OLD_SQL_NOTES * /

-- Dump completed on 2016-11-26 21:26:37

Mysqldump-uroot-pwestos westos-- no-data only backs up the table, not the data in it

Mysqldump-uroot-pwestos westos-- all-database backup all

Mysql-uroot-pwestos-e "SHOW DATABASES;"

Mysql-uroot-pwestos-e "DROP westos;" deletes the existing library (non-interactive)

Mysql-uroot-pwestos-e "DROP DATABASE westos;"

Mysql-uroot-pwestos-e "SHOW DATABASES;"

Mysql-uroot-pwestos-e "CREATE DATABASE westos;"

Mysql-uroot-pwestos westos

< /mnt/westos.sql 恢复数据库 [root@localhost ~]# mysql -uroot -pwestos -e "SELECT * FROM westos.UTAB;" +------+----------+-------+ | user | password | class | +------+----------+-------+ | asd | 123 | 4 | | lee | 123 | | +------+----------+-------+ 图形管理数据库 yum install httpd -y 安装服务 lftp 172.25.254.250 下载 phpMyAdmin-3.4.0-all-languages.tar.bz2 tar -jxf phpMyAdmin-3.4.0-all-languages.tar.bz2 解压 yum install php php-mysql -y 安装php cd myadmin/ cp -p config.sample.inc.php config.inc.php 复制配置和i文件模版 vim config.inc.php 修改配置文件 17 $cfg['blowfish_secret'] = 'westos'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ systemctl restart httpd 重启服务 邮件服务(smtp协议) 配置基础dns邮件服务 『结果』 (主机) [root@localhost ~]# dig -t mx westos.com ; DiG 9.9.4-RedHat-9.9.4-14.el7 -t mx westos.com ;; global options: +cmd ;; Got answer: ;; ->

> HEADERHEADER

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report