首页 技术 正文
技术 2022年11月21日
0 收藏 913 点赞 2,794 浏览 2025 个字

一、临时配置网络(ip,网关,dns)

ifconfig查看网络配置

修改ip地址  ifconfig ens33 192.168.255.129/24

ens33网卡名称、192.168.255.129/24是要配置的ip地址,255.255.255.0 子网掩码

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

配置网关为192.168.255.1 并查看

shell(1):网络配置、BATH环境和通配符

、永久配置网络(ip,网关,dns)

ifconfig查看网络配置

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

修改网络配置,保存。

shell(1):网络配置、BATH环境和通配符

DEVICE=ens33  #网卡名称
HWADDR='' #网卡mac地址
TYPE=static #静态IP
IPADDR=192.168.255.129 #IP地址
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.16.254 #网关地址
DNS1=192.168.16.254 #DNS服务器地址

  

三、为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式

hostnamectl set-hostname python #设置主机名

hostname #查看主机名 

更改主机中的hosts文件:

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

分机1

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

分机2

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

分机3

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

测试

shell(1):网络配置、BATH环境和通配符

主机python ping 分机python-web1、python-web1、python-web2、python-web3测试shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

 四、ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试

1.ssh登录:ssh+域名或ip地址

shell(1):网络配置、BATH环境和通配符

2.scp上传

shell(1):网络配置、BATH环境和通配符

scp下载

shell(1):网络配置、BATH环境和通配符

3.ssh秘匙登录

创建密钥,拿主机1做实验:

ssh-kengen #生成秘钥

shell(1):网络配置、BATH环境和通配符

ls /root/.ssh/ #秘钥生成目录

shell(1):网络配置、BATH环境和通配符

ssh-copy-id -i +域名 #发送锁给另外一台分机

将密钥发送给另外两台主机。ssh-copy-i python-web2ssh-copy-i python-web3

  

shell(1):网络配置、BATH环境和通配符

web1测试连接web2和web3

shell(1):网络配置、BATH环境和通配符

4.更改ssh server的端口号为8888,测试登录和scp登录

以下在python-web1为例

vim /etc/ssh/sshd_config #修改主机ssh端口为888

shell(1):网络配置、BATH环境和通配符

在python-web2测试连接和远程上传下载。ssh python-web1 -p 8888scp -P 8888 /test/1.txt python-web1:/test

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

五、整理bash命令类型,验证寻找一个命令的优先级

命令解释器bash优先级从左向右依次递减:

alias>Compound Commands>function>build_in>hash>$PATH>error

alias,也叫别名。用来简化比较长的命令语句的。声明别名格式: alias a=‘ cd ’,a就拥有了cd命令的功能,删除别名unalias a。

Compound Commands也就是常用的条件判断关键字if、while和for。

function也就是函数,有一个输入就用一个相应的输出。主要用来数据封装,提高代码复用。set查看所有函数,unset清除函数或变量,函数的定义function  test(){echo ‘hello’;}。

build_in就是内置的命令,随着整个shell进程的启动而启动。

hash用来缓存常用的命令(的路径),命令每执行一次,相应的计数器加一。hash 命令。hash -r清除hash缓存。

$PATH 存储环境变量的。

当shell解释器遇到一个命令,它会沿着这个优先级依次查找。

证明alias比Compound Commands优先级高:

shell(1):网络配置、BATH环境和通配符

证明Compound Commands比function 优先级高:

shell(1):网络配置、BATH环境和通配符

证明function比内置命令优先级高:

shell(1):网络配置、BATH环境和通配符

证明bulitin比hash优先级高:

shell(1):网络配置、BATH环境和通配符

证明hash比$PATH高

shell(1):网络配置、BATH环境和通配符

六、通配符实验

通配符是由shell解释器解释执行的。

~,是指家目录,如:cd ~

shell(1):网络配置、BATH环境和通配符

“用来保存结果,和$()一样,推荐用$():

shell(1):网络配置、BATH环境和通配符

{1..10}.txt生成1.txt到10.txt个文件,也可以用{a..z}。{}作命令列表时括号里的首尾必须是空格。

shell(1):网络配置、BATH环境和通配符

[]取中括号里的任意一个元素,如[123]表示1或2或3

shell(1):网络配置、BATH环境和通配符

!取反 和 执行命令,如!ll,是执行上一次ll命令;!数字,执行相应行的命令(history)。取反和^一样。

shell(1):网络配置、BATH环境和通配符

shell(1):网络配置、BATH环境和通配符

/根目录,和路径分隔符

# 注释

[m-n]表示从m到n,要表示所有大小写字母[a-Z],大小写是按照a、A、b、B、c、C……z、Z这样的顺序排的:

shell(1):网络配置、BATH环境和通配符

echo $[]作算术运算用的

shell(1):网络配置、BATH环境和通配符

A&&B 表示只有A执行成功,才执行B:

shell(1):网络配置、BATH环境和通配符

A||B 表示A执行成功,就不执行B;A执行失败,才执行B:

shell(1):网络配置、BATH环境和通配符

|管道

shell(1):网络配置、BATH环境和通配符

+加,-减,*乘,/求整,%求余,=赋值

*匹配任意长度的字符

shell(1):网络配置、BATH环境和通配符

\转义,要打印默写特殊的符号用

“ 软连接”    ‘硬链接’,软连接里是有意义的。硬链接里写的是什么打印的就是什么。

shell(1):网络配置、BATH环境和通配符

. /和 source 执行文件

shell(1):网络配置、BATH环境和通配符

: 永真

shell(1):网络配置、BATH环境和通配符

test 语句 +echo $?

${}:

shell(1):网络配置、BATH环境和通配符

*匹配任意字符,?匹配单一字符

& 后台执行

> 覆盖,>> 追加

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,961
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,485
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,330
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,113
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,746
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,780