首页 > 系统服务 > 详细

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

时间:2017-12-07 21:49:36      阅读:227      评论:0      收藏:0      [点我收藏+]
两台虚拟机,均修改防火器与主机名

防火墙将原来的----------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; ? #查看表结构












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

原文:http://blog.51cto.com/13513556/2048481

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!