LINUX系统工程师技术(Engineer)-------第二天

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

两台虚拟机,均修改防火器与主机名

防火墙将原来的----------public状态---------修改成-------trusted状态

虚拟机server0:

# firewall-cmd --set-default-zone=trusted 

# echo server0.example.com  >  /etc/hostname

# cat /etc/hostname


虚拟机desktop0:

# firewall-cmd --set-default-zone=trusted 

# echo desktop0.example.com  >  /etc/hostname

# cat /etc/hostname


• 电子邮件服务器的基本功能

– 为用户提供电子邮箱存储空间(用户名@邮件域名)

– 处理用户发出的邮件 —— 传递给收件服务器

– 处理用户收到的邮件 —— 投递到邮箱


      用户发邮件的协议:  SMTP  端口25

      用户收邮件的协议:  pop3  端口110    IMAP 端口143        

   

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

虚拟机server0

搭建基本邮件服务器

1. 安装postfix服务端程序

[root@server0 ~]# rpm -q postfix

postfix-2.10.1-6.el7.x86_64


2.配置postfix服务,修改配置文件

[root@server0 ~]# vim /etc/postfix/main.cf

 76行   myhostname = server0.example.com     #指定主机名

 83行   mydomain = example.com               #指定域名

 99行   myorigin = server0.example.com    #默认补全的邮件后缀

 116行 inet_interfaces = all             #允许所有客户端

 164行 mydestination = server0.example.com

                                                                #判断邮件后缀为本域邮件

   补充:vim  命令模式      u 撤销


3.重起postfix服务,设置为开机自起

# systemctl restart postfix                       

# systemctl enable  postfix  


4. 测试邮件的收发


[root@server0 ~]# useradd yg

[root@server0 ~]# echo 123 | passwd --stdin yg


[root@server0 ~]# useradd xln

[root@server0 ~]# echo 123 | passwd --stdin xln


• mail 发信操作

– mail -s '邮件标题'   -r 发件人    收件人


• mail 收信操作

– mail [-u 用户名]


[root@server0 ~]# mail -s 'test01' -r yg   xln


  一行中只有一个  “.”    的时候,代表结束

 

[root@server0 ~]# mail -u xln

  输入 邮件编号 1 查看邮件内容

  quit 退出

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


nullclient邮件服务


空客户端

• nullclient,空客户端

– 不提供任何邮箱账号,因此不需要投递邮件

– 但是可以为用户代发邮件



一、配置desktop0为邮件服务器

1.配置postfix服务,修改配置文件

[root@desktop0 ~]# vim /etc/postfix/main.cf


 99行    myorigin = desktop0.example.com   

 116行  inet_interfaces = all           

 164行  mydestination = desktop0.example.com


[root@desktop0 ~]# systemctl restart postfix

[root@desktop0 ~]# systemctl enable postfix


二、配置server0为空客户端邮件服务器

[root@server0 ~]# vim /etc/postfix/main.cf 


  99行     myorigin = desktop0.example.com

  116行   inet_interfaces = localhost

  164行   mydestination = 

  317行   relayhost = [172.25.0.10]   #指定交给邮件服务器IP地址

   

[root@server0 ~]# systemctl restart postfix


三、测试

虚拟机server0上

# echo   abc   |   mail -s Test1 -r  yg   student


虚拟机desktop0上

# mail -u student

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

 数据库服务基础


• 常见的关系型 数据库管理系统

– 微软的 SQL Server

– IBM的 DB2

– 甲骨文的 Oracle、MySQL

– 社区开源版 MariaDB



• RHEL7 中的 MariaDB 相关包

– mariadb-server:提供服务端有关的系统程序

               端口号 : 3306



一、部署mariadb数据库

1.安装mariadb-server数据库软件

[root@server0 ~]# yum -y install mariadb-server


2.启动mariadb服务

[root@server0 ~]# systemctl restart mariadb

[root@server0 ~]# systemctl enable mariadb



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


[root@server0 ~]# mysql 


MariaDB [(none)]> show databases;           #查看数据库

MariaDB [(none)]> create database nsd1709;  #创建数据库

MariaDB [(none)]> show databases;         


MariaDB [(none)]> drop database nsd1709;    #删除数据库

MariaDB [(none)]> show databases;


MariaDB [(none)]> create database nsd;   

MariaDB [(none)]> show databases;


MariaDB [(none)]> quit                     #退出数据库


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


      数据库管理员为root,但与系统用户root没有关系


• 为数据库账号修改密码

– mysqladmin [-u用户名] [-p[旧密码]] password '新密码'


[root@server0 ~]# mysqladmin -u  root   password  '123'


[root@server0 ~]# mysql

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


[root@server0 ~]# mysql  -u  root  -p

Enter password: 


[root@server0 ~]# mysql -u root -p123      #免交互登陆



• 禁止监听,只服务于本机-----------------表示只对本机服务,其他用户访问不了数据库

[root@server0 ~]# vim /etc/my.cnf   #数据库主配置文件

[mysqld]

skip-networking         #跳过网络监听

......

[root@server0 ~]# systemctl restart mariadb


• MariaDB [(none)]> 交互指令

--------------- 列出数据库:show databases;

---------------使用/选择数据库:use 数据库名;

--------------列出库里有哪些表:show tables;

-------------- 创建数据库:create database 数据库名;

-----------删除数据库:drop database 数据库名;




http://172.25.254.254/pub/materials/users.sql


• 导入/恢复到数据库

– mysql [-u用户名] [-p[密码]] 数据库名  <  备份文件.sql



# wget http://172.25.254.254/pub/materials/users.sql

# mysql -u root -p123 nsd < users.sql


# mysql -u root -p123


MariaDB [nsd]> use nsd;          #进入nsd库

MariaDB [nsd]> show tables;      #查看都有那些表格



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


 查询操作

# mysql -u root -p123

MariaDB [nsd]> use nsd;


MariaDB [nsd]> select * from base;

MariaDB [nsd]> select * from location;


MariaDB [nsd]> select id,name from base;


MariaDB [nsd]> select * from base where name='tom';


MariaDB [nsd]> select * from location where city='beijing';


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

  数据库授权


MariaDB [(none)]> 交互指令

– grant 权限列表  on  数据库名.表名   to  用户名@localhost

  identified by '密码'


   当lisi用户从本地localhost登陆,输入密码123,将会获得库nsd所有表的查询权限


# mysql -u root -p123


MariaDB [(none)]> grant select on nsd.* to lisi@localhost identified by '123';


查看MariaDB数据库中,用户表信息


MariaDB [mysql]> select user,password from mysql.user;


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

案例5:使用数据库查询


2. 在系统 server0 上使用数据库 nsd,并使用相

应的 sql 查询以回答下列问题:


1) 密码是 solicitous 的人的名字?


> select * from nsd.base where password='solicitous';

> select * from nsd.base where password='solicitous' and  id='3';


> select * from nsd.base where name='Barbara' or  id='3';


2) 有多少人的姓名是 Barbara 同时居住在 Sunnyvale?


> use nsd;


> select * from base,location

where base.name='Barbara' and location.city='Sunnyvale'   and  base.id=location.id;


> select count(*) from base,location    

where base.name='Barbara' and location.city='Sunnyvale' and  base.id=location.id;


> insert base values(6,'Barbara',123456);  #插入表记录

> insert location values(6,'Sunnyvale');   #插入表记录

> select * from base;

> select * from location;




1. 禁止空密码root用户访问 mariadb 数据库


> use mysql;


> select user,host,password from user where password=''and user='root';


> delete from user where password='' and user='root';------删除以root用户名和空密码的


> select user,host,password from user ;


> desc  user;   #查看表结构


     本文转自hj_1314wgn 51CTO博客,原文链接:http://blog.51cto.com/13513556/2048481,如需转载请自行联系原作者







相关文章
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
11 1
|
2天前
|
Linux 数据安全/隐私保护
Linux系统忘记密码的三种解决办法
这篇博客介绍了三种在Linux忘记密码时重置登录密码的方法:1) 使用恢复模式,通过控制台界面以管理员权限更改密码;2) 利用Linux Live CD/USB启动,挂载硬盘分区并使用终端更改密码;3) 进入单用户模式,自动以管理员身份登录后重置密码。每个方法都提供了详细步骤,提醒用户在操作前备份重要数据。
|
2天前
|
JSON Unix Linux
Linux系统之jq工具的基本使用
Linux系统之jq工具的基本使用
29 2
|
2天前
|
数据采集 监控 安全
linux系统被×××后处理经历
linux系统被×××后处理经历
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
40 2
|
2天前
|
缓存 Linux
linux系统缓存机制
linux系统缓存机制
|
3天前
|
存储 Linux Android开发
RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo
RK3568 Android/Linux 系统动态更换 U-Boot/Kernel Logo
18 0
|
3天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
6 0
|
4天前
|
资源调度 JavaScript Ubuntu
Linux系统之部署briefing视频聊天系统
【4月更文挑战第21天】Linux系统之部署briefing视频聊天系统
40 2
|
5天前
|
Linux Perl
Linux系统替换字符串常用命令
请注意,`sed`命令可以非常强大,可以根据不同的需求使用不同的选项和正则表达式来进行更复杂的字符串替换操作。
17 0