溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

linux筆記13

發(fā)布時(shí)間:2020-06-03 18:56:53 來(lái)源:網(wǎng)絡(luò) 閱讀:481 作者:zirui郭 欄目:數(shù)據(jù)庫(kù)

主從DNS同步

當(dāng)單一DNS無(wú)法滿足客戶需求是開啟一個(gè)同步的次級(jí)DNS,他們dns的內(nèi)容一致。

主機(jī):

 vim /etc/named.rfc1912.zones

zone "asd.com" IN {

        type master;

        file "asd.com.zone";

        allow-update { none; };

        allow-transfer { 172.25.254.225; };        從機(jī)地址

};

 

 systemctl restart named

 

從機(jī):

 yum install bind -y            安裝服務(wù)

 vim /etc/named.conf            修改配置文件

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; };

dnssec-validation no;            同主機(jī)一致

 

 vim /etc/named.rfc1912.zones

zone "asd.com" IN {

        type slave;                設(shè)置為從機(jī)

        masters { 172.25.254.125; };            主機(jī)地址

        file "slaves/asd.com.zone";

        allow-update { none; };

};

 systemctl restart named                        重啟服務(wù)

 

(檢測(cè)結(jié)果)

[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<<- opcode: QUERY, status: NOERROR, id: 63544

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

 

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;www.asd.com.INA

 

;; ANSWER SECTION:

www.asd.com.86400INA172.25.254.126

 

DNS修改同步

從機(jī):

 systemctl stop firewalld         關(guān)閉火墻,允許通知通過(guò)

 

主機(jī):

 vim /etc/named.rfc1912.zones

zone "asd.com" IN {

        type master;

        file "asd.com.zone";

        allow-update { none; };

        allow-transfer { 172.25.254.225; };

        also-notify { 172.25.254.225; };                通知從機(jī)同步更新

};

 

 vim /var/named/asd.com.zone

$TTL 1D

@       IN SOA  dns.asd.com. root.asd.com. (

                                        01      ; serial        修改serial,提示有更新(最多10位)文件在更新是查看的比較值

                                        1D      ; refresh

                                        1H      ; retry

                                        1W      ; expire

                                        3H )    ; minimum

        NS      dns.asd.com.

dns     A       172.25.254.125

www     A       172.25.254.128                                    DNS更新

 

systemctl restart named                                            重啟服務(wù)并通知從機(jī)更新dns

 

『測(cè)試結(jié)果』

主從機(jī)DNS保持一致,主機(jī)更新,從機(jī)同步更新

 

 

DNS遠(yuǎn)程更新

主機(jī)(服務(wù)端)

 setenforce 0                                                更改selinux

 chmod 770 /var/named                                        更改目錄權(quán)限

 vim /etc/named.rfc1912.zones                                修改文件

zone "asd.com" IN {

        type master;

        file "asd.com.zone";

        allow-update { 172.25.254.225; };                    發(fā)送新的dns的地址

};

 

發(fā)送端:

 nsupdate

> server 172.25.254.125                                        更改的dns ip

> update delete www.asd.com                                    刪除

> send發(fā)送

> server 172.25.254.125

> update add www.asd.com 86400 A 172.25.254.120                    添加新的dns (86400 緩存一天)

> send

> quit                                                            退出

 

 

注:當(dāng)完成> server 172.25.254.125                           

> update delete www.asd.com                             

> send

后主機(jī)端的/var/named/會(huì)出一個(gè)asd.com.zone.jnl

當(dāng)systemctl retsart named 后 該文件會(huì)覆蓋原本的asd.com.zone,所以建議提前備份

 

『測(cè)試結(jié)果』

遠(yuǎn)程可以更改主機(jī)的dns服務(wù)(可以進(jìn)行刪除和添加)

 

DNS遠(yuǎn)程更新(加密)

主機(jī):

 dnssec-keygen -a HMAC-MD5 -b 100 -n HOST gou  (-a 加密類型 -b加密字節(jié) -n 加密用途)

獲得公鑰和私鑰

 

 cp -p /etc/rndc.key /etc/gou.key                復(fù)制模版

 vim /etc/gou.key                                編寫內(nèi)容

key "gou" {                                        加密名稱

        algorithm hmac-md5;                        格式

        secret "/pLHdCuATXkKuZNjGQ==";             密碼

};

 

 vim /etc/named.conf

43   include "/etc/gou.key";

 

 vim /etc/named.rfc1912.zones                     修改配置文件

zone "asd.com" IN {

        type master;

        file "asd.com.zone";

        allow-update { key gou; };                只接受有key的人的修改

};

 

 scp Kgou.+157+64442.* root@172.25.254.225:/mnt        遠(yuǎn)程發(fā)送密碼給用戶以更新dnsderen

 

systemctl restart named                                    重啟服務(wù)

 

發(fā)送端:

[root@localhost mnt]# nsupdate -k Kgou.+157+64442.private -k 用密匙的方式)

> server 172.25.254.125

> update delete www.asd.com                                    刪除

> send

> quit退出

 

『測(cè)試結(jié)果』

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<<- opcode: QUERY, status: NXDOMAIN, id: 55177

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

 

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;www.asd.com.INA

 

;; AUTHORITY SECTION:

asd.com.10800INSOAdns.asd.com. root.asd.com. 3 86400 3600 604800 10800

 

DDNS(花生殼)動(dòng)態(tài)DNS獲取

 yum install dhcp  -y                                                        安裝dhcp

 cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf        復(fù)制模版

 vim /etc/dhcp/dhcpd.conf                                                        配置文件

 6 # option definitions common to all supported networks...

 7 option domain-name "asd.com";                                                域名

 8 option domain-name-servers 172.25.254.125;dns ip

 13 # Use this to enble / disable dynamic dns updates globally.

 14 ddns-update-style interim;                                                開啟dhcp時(shí)通知dns

 30 subnet 172.25.254.0  netmask 255.255.255.0 {                                子網(wǎng)掩碼

 31   range 172.25.254.247 172.25.254.249;                                    ip獲取段

 32   option routers 172.25.254.125;

 33 }

 34 key gou {                                                                    key名稱

 35         algorithm hmac-md5;                                                加密方式

 36         secret /pLHdCuATXkKuZNjGQ==;

 37 };

 38 zone asd.com. {

 39         primary 127.0.0.1;                                                    自循環(huán)

 40         key gou;

 41 }

 

 vim /var/named/asd.com.zone                                                     復(fù)原該文件

 

 systemctl restart named

 systemctl restart dhcpd                                                         重啟服務(wù)

 

客戶端:

更改ip獲取方式為dhcp

hostnamectl set-hostname  bbq.asd.com                                         更改主機(jī)名(必須屬于asd域)

systemctl restart network                                                         重啟服務(wù)

 

『測(cè)試結(jié)果』

dig bbq.asd.com

結(jié)果與客戶端ip一致

 

 

 

 

 

數(shù)據(jù)庫(kù)

 yum install mariadb-server.x86_64 -y                                    數(shù)據(jù)庫(kù)服務(wù)的安裝

 vim /etc/my.cnf                                                          修改配置文件

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

skip-networking=1                                                        關(guān)閉網(wǎng)卡上的數(shù)據(jù)庫(kù)端口

 systemctl restart mariadb                                                    重啟服務(wù)

 

[root@localhost named]# mysql_secure_installation                         開啟安全機(jī)制

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):                             輸入密碼(無(wú))

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

Set root password? [Y/n] y                                                    設(shè)置密碼

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y                                                  關(guān)閉匿名訪問(wèn)

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] y                                            不允許root遠(yuǎn)程訪問(wèn)

 ... Success!

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y                                            不允許臨時(shí)數(shù)據(jù)庫(kù)

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y                                                        刷新

 ... Success!

 

Cleaning up...

 

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

 

Thanks for using MariaDB!

 

 mysql -u root -p westos                                                                     登陸

 

數(shù)據(jù)庫(kù)的查詢(;表示命令輸入完成)

MariaDB [(none)]> SHOW DATABASES;                                                        顯示數(shù)據(jù)庫(kù)

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

 

MariaDB [(none)]> USE mysql;                                                                進(jìn)入數(shù)據(jù)庫(kù)

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;                                                        顯示數(shù)據(jù)庫(kù)中的表

+---------------------------+

| 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;            查看user表中的host,user,password字段

+------+-----------+-------------------------------------------+

| 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 ;                                        創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)

MariaDB [mysql]> USE asd;                                                    進(jìn)入數(shù)據(jù)庫(kù)

MariaDB [asd]> CREATE TABLE UTAB ( uer varchar(10) not null, password varchar(8) not null, age varchar(3) );                   創(chuàng)建一張表(用戶名【10】不能沒(méi)有,密碼【8】不能沒(méi)有,年齡【3】可以不添)

MariaDB [asd]> SHOW TABLES;                                                    顯示數(shù)據(jù)庫(kù)

+---------------+

| Tables_in_asd |

+---------------+

| UTAB          |

+---------------+

 

MariaDB [asd]> DESC UTAB ;                                    顯示表的屬性

+----------+-------------+------+-----+---------+-------+

| 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');    添加內(nèi)容進(jìn)表

Query OK, 1 row affected (0.00 sec)

 

MariaDB [asd]> SELECT * FROM UTAB ;                                    顯示表

+-----+----------+------+

| uer | password | age  |

+-----+----------+------+

| asd | qwe      | 24   |

+-----+----------+------+

 

MariaDB [asd]> ALTER TABLE UTAB ADD class varchar(8) AFTER password ;            添加一個(gè)字段在password后

Query OK, 1 row affected (0.03 sec)                

Records: 1  Duplicates: 0  Warnings: 0

 

MariaDB [asd]> UPDATE UTAB SET  ;                                                class附值

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   |

+-----+----------+-------+------+

 

MariaDB [asd]> UPDATE UTAB SET  WHERE uer='asd';                            class值的修改

Query OK, 1 row affected (0.01 sec)

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.01 sec)

 

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 3     | 24   |

| gou | qwe      |       | 24   |

+-----+----------+-------+------+

 

MariaDB [asd]> DELETE FROM UTAB uer='gou';                                        刪除某一列

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.01 sec)

 

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 3     | 24   |

+-----+----------+-------+------+

 

MariaDB [asd]> DROP TABLE UTAB                                                刪除表

    -> ;

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;                                                    刪除庫(kù)

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)

 

數(shù)據(jù)庫(kù) 用戶的權(quán)限和訪問(wèn)

 

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

Query OK, 0 rows affected (0.00 sec)         創(chuàng)建用戶we,密碼為westos,僅可本地登陸(we@'%'可遠(yuǎn)程登陸)

 

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

Query OK, 0 rows affected (0.00 sec)                授權(quán)可以在任意庫(kù)的任意表中創(chuàng)建

MariaDB [(none)]> SHOW GRANTS FOR we@localhost ;        權(quán)限顯示

+------------------------------------------------------------------------------------------------------------+

| 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.00 sec)                可以在任意庫(kù)的任意表中插入

 

MariaDB [(none)]> SHOW GRANTS FOR we@localhost ;        權(quán)限查看

+--------------------------------------------------------------------------------------------------------------------+

| Grants for we@localhost                                                                                            |

+--------------------------------------------------------------------------------------------------------------------+

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

+--------------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

 

FLUSH PRIVILEGES  ;                                                    重載授權(quán)表

 

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

Query OK, 0 rows affected (0.00 sec)                                撤銷用戶創(chuàng)建權(quán)限

 

MariaDB [(none)]> DROP USER we@localhost ;                                刪除用戶

Query OK, 0 rows affected (0.00 sec)

 

數(shù)據(jù)庫(kù)密碼

當(dāng)忘記密碼:

systemctl stop mariadb.service                                     停止服務(wù)

mysqld_safe --skip-grant-tables &                                開啟安全模式

[root@localhost ~]# fg

mysqld_safe --skip-grant-tables

^Z       

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

mysql -u root                                                        進(jìn)入數(shù)據(jù)庫(kù)

 

MariaDB [(none)]> UPDATE mysql.user set Password='redhat' WHERE User='root' ;        更新密碼(明文)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

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

 

MariaDB [(none)]> UPDATE mysql.user set Password=password('redhat') WHERE User='root' ; 更新密碼(加密)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

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

 

[root@localhost ~]# fg                                                            查看后臺(tái)

mysqld_safe --skip-grant-tables

^Z       

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

[root@localhost ~]# killall -9 mysqld_safe                                    關(guān)閉后臺(tái)進(jìn)程

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

[root@localhost ~]# ps aux | grep mysql                                                        查看進(jìn)程

mysql     3196  0.0  4.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  0.0 112640   940 pts/0    R+   20:58   0:00 grep --color=auto mysql

[root@localhost ~]# kill -9 3196                                                        關(guān)閉

systemctl start mariadb                                            開啟服務(wù)(可以正常登陸)

 

修改密碼:

mysqladmin -uroot -predhat password westos

 

數(shù)據(jù)庫(kù)的備份和恢復(fù)

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.01 sec)

 

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

Query OK, 1 row affected (0.01 sec)

MariaDB [westos]> SELECT * FROM UTAB;

+------+----------+-------+

| user | password | class |

+------+----------+-------+

| asd  | 123      | 4     |

| lee  | 123      |       |

+------+----------+-------+

 

(創(chuàng)建一個(gè)實(shí)驗(yàn)用的數(shù)據(jù)庫(kù))

 

[root@localhost ~]# mysqldump -uroot -pwestos westos > /mnt/westos.sql                備份數(shù)據(jù)庫(kù)

-- 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                 只備份表格不備份其中數(shù)據(jù)

mysqldump -uroot -pwestos westos --all-database                備份全部

 

 

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

mysql -uroot -pwestos -e "DROP westos;"                        刪除原有庫(kù)(非交互)

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                恢復(fù)數(shù)據(jù)庫(kù)

[root@localhost ~]# mysql -uroot -pwestos -e "SELECT * FROM westos.UTAB;"

+------+----------+-------+

| user | password | class |

+------+----------+-------+

| asd  | 123      | 4     |

| lee  | 123      |       |

+------+----------+-------+

 

圖形管理數(shù)據(jù)庫(kù)

 yum install httpd -y                                        安裝服務(wù)

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                    復(fù)制配置和i文件模版

vim config.inc.php                                        修改配置文件

17 $cfg['blowfish_secret'] = 'westos'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

 

systemctl restart httpd                                        重啟服務(wù)

 

linux筆記13

linux筆記13

linux筆記13

linux筆記13

linux筆記13


 

 

 

 

 

 

 

 

郵件服務(wù)(smtp協(xié)議)

配置基礎(chǔ)dns郵件服務(wù)

『結(jié)果』

(主機(jī))

[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:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22032

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

 

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;westos.com.INMX

 

;; ANSWER SECTION:

westos.com.86400INMX1 172.25.254.225.

 

;; AUTHORITY SECTION:

westos.com.86400INNSdns.westos.com.

 

;; ADDITIONAL SECTION:

dns.westos.com.86400INA172.25.254.125

 

(從機(jī))

[root@localhost ~]# dig  -t mx linux.com

 

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> -t mx linux.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42394

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

 

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;linux.com.INMX

 

;; ANSWER SECTION:

linux.com.86400INMX1 172.25.254.125.

 

;; AUTHORITY SECTION:

linux.com.86400INNSdns.linux.com.

 

;; ADDITIONAL SECTION:

dns.linux.com.86400INA172.25.254.125

 

郵件通信(smtp)

主機(jī):

vim /etc/postfix/main.cf                     修改postfix配置文件

 75 myhostname = linux.com                    主機(jī)名稱

 83 mydomain = linux.com                        域名

 99 myorigin = $mydomain                        郵件后綴

113 inet_interfaces = all                        開啟所有網(wǎng)絡(luò)端口

116 #inet_interfaces = localhost

164 mydestination = $myhostname, $mydomain, localhost            接受郵件類型

systemctl restart postfix.service                 重啟服務(wù)

scp /etc/postfix/main.cf root@172.25.254.225:/etc/postfix/main.cf        向從機(jī)發(fā)送模版

從機(jī):

vim /etc/postfix/main.cf                        修改postfix配置文件

 75 myhostname = westos.com                      主機(jī)名稱

 83 mydomain = westos.com                        域名

 99 myorigin = $mydomain                        郵件后綴

113 inet_interfaces = all                       開啟所有網(wǎng)絡(luò)端口

116 #inet_interfaces = localhost

164 mydestination = $myhostname, $mydomain, localhost   接受那些目的地過(guò)來(lái)的郵件

systemctl restart postfix.service               重啟服務(wù)

 

『測(cè)試結(jié)果』

從機(jī)向主機(jī)

[root@localhost ~]# mail root@linux.com

Subject: asd

asd

asdqwe.

.

EOT

[root@localhost ~]# mailq

Mail queue is empty

主機(jī)

[root@localhost named]# mailq

Mail queue is empty

You have mail in /var/spool/mail/root

[root@localhost named]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sun Nov 27 01:56  22/700   "asd"

& 1

Message  1:

From root@westos.com  Sun Nov 27 01:56:18 2016

Return-Path: <root@westos.com>

X-Original-To: root@linux.com

Delivered-To: root@linux.com

Date: Sun, 27 Nov 2016 01:56:17 -0500

To: root@linux.com

Subject: asd

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: root@westos.com (root)

Status: R

 

asd

asdqwe.

 

mailq         查看郵件信息

postsuper -d 4B9DE17E849                刪除滯留郵件(4E..為郵件編號(hào))

postsqueue -f            刷新滯留郵件

 

郵件別名

vim /etc/aliases

# Person who should get root's mail

#root:          marc

qqq:            root                                        root的別名為qqq

more:           :include:/etc/moreusers                    多方用戶

 

vim /etc/moreusers                                          配置多方用戶

root

student                                                    (包含的用戶)

 

postalias /etc/aliases                                    重新讀取/etc/aliases文件

systemctl restart postfix.service                            重啟服務(wù)

 

『測(cè)試結(jié)果』

[root@localhost ~]# mail qqq@linux.com                root的別名發(fā)送郵件(可接受)

Subject: 123

qweasd

.

EOT

[root@localhost ~]# mail more@linux.com                向多方發(fā)送郵件(root,student都可接受)

Subject: 234

aaqwe

.

EOT

 

postconf -e "inet_interface=localhost"                修改/etc/postfix/main.cf 文件

postconf -d                                             查找/etc/postfix/main.cf中的信息

postconf -n                                            列出/etc/postfix/main.cf中所有參數(shù)

 

郵件的匿名

從機(jī)

cd /etc/postfix

vim generic                                             修改匿名文件

root@westos.com     123@qq.com                             (最后一行 前為真實(shí)郵件地址;后為假的)

postmap generic                                                加密文件

postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"            將文件寫如配置文件參數(shù)

systemctl restart postfix.service                                            重啟服務(wù)

『測(cè)試結(jié)果』

從機(jī):

[root@localhost postfix]# mail root@linux.com                        發(fā)送郵件

Subject: 456

asd

asd

.

EOT

主機(jī):

[root@localhost ~]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sun Nov 27 03:38  22/681   "456"

& 1

Message  1:

From 123@qq.com  Sun Nov 27 03:38:52 2016                            發(fā)送方變?yōu)槟涿?/span>

Return-Path: <123@qq.com>

X-Original-To: root@linux.com

Delivered-To: root@linux.com

Date: Sun, 27 Nov 2016 03:38:52 -0500

To: root@linux.com

Subject: 456

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: 123@qq.com (root)

Status: R

 

asd

asd

 

遠(yuǎn)程檢測(cè)25端口

[root@localhost postfix]# telnet 172.25.254.125 25                        鏈接25端口

Trying 172.25.254.125...

Connected to 172.25.254.125.

Escape character is '^]'.

220 linux.com ESMTP Postfix

ehlo hello                                                                    檢測(cè)

250-linux.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:root@westos.com                                                     郵件來(lái)自

250 2.1.0 Ok

rcpt to:root@linux.com                                                        發(fā)送去

250 2.1.5 Ok

data                                                                            內(nèi)容

354 End data with <CR><LF>.<CR><LF>

asd

asdw

.

250 2.0.0 Ok: queued as D8C7C17E84F

quit                        退出

 


向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI