云计算 day8
源码编译安装:
源码包---gcc make编译---》可以执行的程序 ----》运行安装
环境准备
所有虚拟机设置SELinux运行模式
[root@server ~]# getenforce
Enforcing
[root@server ~]# setenforce 0 #当前设置
[root@server ~]# getenforce
Permissive
[root@server ~]# vim /etc/selinux/config
SELINUX=permissive
所有虚拟机设置防火墙(停止防火墙服务)
[root@server ~]# yum -y remove firewalld
[root@server ~]# rpm -q firewalld
RPM软件包:rpm -ivh yum -y install
源码包---gcc make编译---》可以执行的程序 ----》运行安装
源码编译安装
RPM软件包: rpm yum
源码包---编译---》可以执行的程序------>运行安装
源码包特点:
1.可以指定安装位置与软件功能 默认安装/usr/local
2.集中化安装到一个目录中
3.版本比较新,一般要比rpm软件包要新
4.源码包的数量更多
eg:
虚拟机A:[root@nsd2408 ~]# ls /root公共 视频 文档 音乐 anaconda-ks.cfg tools.tar.gz模板 图片 下载 桌面 initial-setup-ks.cfg web.zip[root@nsd2408 ~]# 源码包---编译---》可以执行的程序--->运行安装1.进行tar解包]# tar -xf /root/tools.tar.gz -C /usr/local]# ls /usr/local/tools]# tar -xf /usr/local/tools/inotify-tools-3.13.tar.gz -C /usr/local/ ]# ls /usr/local/]# cd /usr/local/inotify-tools-3.13/]# ls2.安装开发工具gcc与make]# yum -y install gcc make3.运行configure脚本作用1:检测当前系统是否安装gcc作用2:指定安装位置与功能作用3:生成Makefile文件(制作程序的大纲,做菜的菜谱)]# cd /usr/local/inotify-tools-3.13/]# ./configure --help #查看帮助信息,大概浏览一下]# ./configure --prefix=/opt/myrpm #指定安装位置,此步骤不产生相应的目录 ]# ls Makefile (制作程序的大纲,做菜的菜谱)4.进行make编译,变成可以执行的程序(放在内存中)[root@server ~]# cd /usr/local/inotify-tools-3.13/[root@server inotify-tools-3.13]# make5.进行make install安装[root@server ~]# cd /usr/local/inotify-tools-3.13/[root@server inotify-tools-3.13]# make install [root@server inotify-tools-3.13]# ls /opt/[root@server inotify-tools-3.13]# ls /opt/myrpm/[root@server inotify-tools-3.13]# ls /opt/myrpm/bin/步骤1:安装开发工具gcc与make步骤2:tar解包,释放源代码至指定目录步骤3:./configure 配置,指定安装目录/功能模块等选项步骤4:make 编译,生成可执行的二进制程序文件步骤5:make install 安装,将编译好的文件复制到安装目录常见的报错信息:gcc开发工具没有安装checking for gcc... nochecking for cc... nochecking for cl.exe... noconfigure: error: no acceptable C compiler found in $PATHSee `config.log\' for more details.补充: 1.如果安装失败,如何修复]# rm -rf /opt/myrpm/ /usr/local/inotify-tools-3.13/]# tar -xf /usr/local/tools/inotify-tools-3.13.tar.gz -C /usr/local/]# cd /usr/local/inotify-tools-3.13/]# ./configure --prefix=/opt/myrpm]# make]# make install 2.如果想要卸载源码安装软件]# rm -rf /opt/myrpm/ /usr/local/inotify-tools-3.13/
远程同步(rsync+ssh)
• 与远程的 SSH目录保持同步下行:rsync [...] user@host:远程目录 本地目录上行:rsync [...] 本地目录 user@host:远程目录虚拟机A的/mydir目录的内容与虚拟机B的/cbd进行同步虚拟机A:]# rsync -avX --delete /mydir/ root@192.168.88.2:/cbd……..connecting (yes/no)? yesroot@192.168.88.2\'s password: #输入密码虚拟机B:]# ls /cbd 实时同步实现ssh无密码验证(公钥与私钥)虚拟机A1.虚拟机A生成公钥与私钥]# ssh-keygen #一路回车]# ls /root/.ssh/id_rsa(私钥) id_rsa.pub(公钥) known_hosts(记录曾经远程管理过的机器)2.虚拟机A将公钥传递给虚拟机B]# ssh-copy-id root@192.168.88.2]# rsync -avX --delete /mydir/ root@192.168.88.2:/cbd
监控目录内容变化工具
• 基本用法
inotifywait [选项] 目标文件夹
• 常用命令选项
-m,持续监控(捕获一个事件后不退出)
-r,递归监控、包括子目录及文件
-q,减少屏幕输出信息
-e,指定监视的 modify、move、create、delete、attrib 等事件类别
]# /opt/myrpm/bin/inotifywait -rq /mydir
]# rsync -avX --delete /mydir/ root@192.168.88.2:/cbd
Shell脚本(了解)
脚本:可以运行一个文件,实现某种功能
中文:新建用户zhangsan shell: useradd zhangsan
[root@nsd2408 /]# vim /root/hello.sh
echo hello world
cat /etc/redhat-release
hostname
ifconfig | head -2
[root@nsd2408 /]# chmod +x /root/hello.sh
[root@nsd2408 /]# /root/hello.sh #绝对路径运行脚本
循环:解决重复执行
for循环:有固定次数的事情
while循环:不定次数的事情
格式:
while [条件]
do
重复执行的事情
done
[root@server /]# vim /opt/rsync.sh
while /opt/myrpm/bin/inotifywait -rqq /mydir/
do
rsync -aX --delete /mydir/ root@192.168.88.2:/cbd
done
[root@server /]# chmod +x /opt/rsync.sh #赋予执行权限
[root@server /]# /opt/rsync.sh & #放入后台运行脚本程序
[root@server /]# jobs -l #-l选项 显示进程的pid
[1] + 17707 运行中 /etc/rsync.sh &
[root@server /]# kill 17707 #停止脚本,可以杀死进程
循环:解决重复执行
for循环:有固定次数的事情
while循环:不定次数的事情
格式:
while [条件]
do
重复执行的事情
done
eg:
[root@server /]# vim /opt/rsync.sh while /opt/myrpm/bin/inotifywait -rqq /mydir/dorsync -aX --delete /mydir/ root@192.168.88.2:/cbddone[root@server /]# chmod +x /opt/rsync.sh #赋予执行权限[root@server /]# /opt/rsync.sh & #放入后台运行脚本程序[root@server /]# jobs -l #-l选项 显示进程的pid[1] + 17707 运行中 /etc/rsync.sh &[root@server /]# kill 17707 #停止脚本,可以杀死进程
数据库基础服务
什么是数据库:存放数据的仓库
在数据库系统中,有很多的数据库,在每一个库中有很多的表格
• 常见的关系型 数据库管理系统
微软的 SQL Server
IBM的 DB2
甲骨文的 Oracle、MySQL
社区开源版 MariaDB
database:数据库
部署数据服务
]# yum -y install mariadb-server
]# systemctl restart mariadb
MariaDB基本使用
1. Linux系统的管理指令不能使用
2. 所有的数据库系统指令都必须以 ; 结尾
3. 数据库系统的指令大部分不支持tab补全
eg:
[root@server /]# mysql #进入数据库系统> create database nsd01; #创建nsd01数据库> show databases; #查看所有数据库> drop database nsd01; #删除数据库nsd01> show databases; #查看所有数据库> create database test; #创建test数据库> show databases; #查看所有数据库> exit; Bye[root@server ~]#[root@server /]# mysql #进入数据库系统> use mysql; #切换到mysql数据库> show tables; #查看当前库中所有表格> show databases; #查看所有数据库> use test; #切换到test数据库> exit; 真机/linux-soft/s1/users.sql文件传递数据到虚拟机A ALT w 然后 ALT f[root@server ~]# mysql test use test; #切换到数据库testMariaDB [test]> show tables; #查看当前库有哪些表
表记录 表字段(表头)
编号
姓名
住址
1
tc
东村
2
dc
西村
增(insert) 删(delete) 改(update) 查(select)
查(select)
格式: select 表字段1, 表字段2,...... from 表名 ;
查看表结构:desc 表名 ;
eg:
[root@server /]# mysql > use test;> select * from base; #查看base所有表字段内容> select * from location; #查看location所有表字段内容> select name,password from base; > desc base;> use mysql;> select * from test.base; > use test;> select id,name from base;[root@server /]# mysql > use test; #切换到test库查询密码为456的记录 > select * from base where password=\'456\';查看id编号为4的记录> select * from base where id=\'4\';查询id编号为4并且密码为123的记录> select * from base where id=\'4\' and password=\'123\';查询id编号为4或者密码为123的记录> select * from base where id=\'4\' or password=\'123\';增(insert)格式:insert 表名 values (‘值’,‘值’,‘值’);MariaDB [test]> insert base values(\'10\',\'dc\',\'789\');MariaDB [test]> insert base values(\'11\',\'tcc\',\'369\');MariaDB [test]> select * from base ;改(update)格式:update 表名 set 表字段=‘新值’ where 表字段=’值’;> select * from base ;> update base set password=\'8888\' where id=\'1\';> select * from base ; > update base set password=\'9999\' where id=\'2\';> select * from base ; 删(delete)> use test;> delete from base where id=\'4\' ;> select * from base ;> delete from base where id=\'3\' ;> select * from base ;
为数据库系统管理员设置密码
mysqladmin [-u用户名] [-p[旧密码]] password \'新密码\'
数据库系统管理员:对于数据库系统有最高权限,名字为root,能够登陆数据系统的用户信息,由mysql库中user表进行储存
Linux系统管理员: 对于Linux系统有最高权限,名字为root,能够登陆Linux系统的用户信息,/etc/passwd进行储存
eg:
root@server /]# mysqladmin -u root password \'456\'[root@server /]# mysql -u root -p #交互式进行登录 Enter password:[root@server /]# mysql -u root -p456 #非交互式进行登录已知旧密码修改新密码 [root@server ~]# mysqladmin -u root -p456 password \'123\'[root@server ~]# mysql -u root -p123 邮件的收发]# yum -y install postfix]# systemctl restart postfix]# useradd yg]# useradd xlnmail 发信操作: mail -s \'邮件标题\' -r 发件人 收件人[root@server /]# yum -y install mailx #提供mail命令软件[root@server /]# mail -s \'test01\' -r yg xlnhahaxixiehehelele. #一行只有一个点表示提交 EOT mail 收信操作: mail [-u 用户名][root@server /]# mail -u xln>N 1 yg@server.tedu.cn Fri Sep 18 17:24 18/510& 1 #输入邮件编号& quit #退出 非交互式发邮件:[root@server ~]# echo 123456 | mail -s \'test02\' -r yg xln[root@server ~]# mail -u xln