**1.修改主机名**
~~~
[root@shizhan /]# vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=shizhan
~~~
**2.修改ip地址**
>[success]
>[root@shizhan ~]# ifconfig eth0 192.168.43.88 重启后无效
~~~
#永久有效
[root@shizhan /]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #网卡设备名称
HWADDR=00:0C:29:9A:0B:82
TYPE=Ethernet
UUID=b1cbd75d-722e-47a8-82fe-6fb028c84a58
ONBOOT=yes #开机自启动
NM_CONTROLLED=no
BOOTPROTO=static #ip地址设置为静态的
IPADDR=192.168.43.66 #ip地址
NETMASK=255.255.255.0 #子网掩码
GATEWAY=192.168.43.2 #网关ip
#启动生效
service network restart 或 /etc/init.d/network restart
~~~
**3.修改ip地址和主机名的映射关系**
~~~
[root@shizhan /]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.30.62 server1.test.cn
~~~
**4.关闭selinux**
~~~
[root@shizhan /]# vi /etc/selinux/config
SELINUX=disabled
[root@shizhan /]# setenforce 0 #生效
~~~
**5.ssh免密码登录**
* linux使用密码远程连接
~~~
[root@shizhan /]# ssh 192.168.43.68
The authenticity of host '192.168.43.68 (192.168.43.68)' can't be established.
RSA key fingerprint is a3:d9:24:47:03:6d:8a:db:0d:f5:66:0a:f4:27:42:4b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.43.68' (RSA) to the list of known hosts.
reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT!
root@192.168.43.68's password:
Last login: Thu Sep 6 21:36:56 2018 from 192.168.43.1
[root@mini ~]# ls
anaconda-ks.cfg install.log install.log.syslog
~~~
* 远程拷贝
~~~
[root@mini ~]# scp install.log root@192.168.43.68:/home/ #scp 拷贝本地文件到另一台服务器的home目录下
The authenticity of host '192.168.43.68 (192.168.43.68)' can't be established.
RSA key fingerprint is a3:d9:24:47:03:6d:8a:db:0d:f5:66:0a:f4:27:42:4b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.43.68' (RSA) to the list of known hosts.
reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT!
root@192.168.43.68's password:
install.log 100% 23KB 23.1KB/s 00:00
[root@mini ~]#
~~~
* 生成ssh密钥
~~~
[root@shizhan /]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
66:63:a7:11:cf:08:40:08:13:ff:d5:08:9d:c0:f0:bf root@shizhan
The key's randomart image is:
+--[ RSA 2048]----+
|+o.==o . |
| o...ooo |
| . . + o |
| . o . = |
| . . S + |
| = = |
| E . |
| |
| |
+-----------------+
[root@shizhan ~]# ll .ssh
总用量 12
-rw-------. 1 root root 1675 9月 6 14:08 id_rsa
-rw-r--r--. 1 root root 394 9月 6 14:08 id_rsa.pub
-rw-r--r--. 1 root root 798 9月 6 13:44 known_hosts
~~~
* 拷贝密钥到服务器上
~~~
[root@mini .ssh]# ssh 192.168.43.66 #先连接生成密钥的66服务器
root@192.168.43.66's password:
Last login: Wed Sep 5 14:42:25 2018 from 192.168.43.1
[root@shizhan ~]# cd .ssh
[root@shizhan .ssh]# ll
total 12
-rw-------. 1 root root 1675 Sep 6 14:08 id_rsa
-rw-r--r--. 1 root root 394 Sep 6 14:08 id_rsa.pub
-rw-r--r--. 1 root root 798 Sep 6 13:44 known_hosts
[root@shizhan .ssh]# ssh-copy-id 192.168.43.68 #拷贝密钥到另一台68服务器
reverse mapping checking getaddrinfo for bogon [192.168.43.68] failed - POSSIBLE BREAK-IN ATTEMPT!
root@192.168.43.68's password:
Now try logging into the machine, with "ssh '192.168.43.68'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
[root@shizhan .ssh]# exit #退出生成密钥的66服务器
logout
Connection to 192.168.43.66 closed.
[root@mini .ssh]# ll
total 8
-rw-------. 1 root root 452 Sep 6 22:18 authorized_keys
-rw-r--r--. 1 root root 790 Sep 6 21:52 known_hosts
[root@mini .ssh]# cat authorized_keys #查看拷贝到68服务器的密钥
~~~
* 在66服务器上免密码连接68服务器
~~~
[root@shizhan .ssh]# ssh 192.168.43.68
Last login: Thu Sep 6 21:44:50 2018 from 192.168.43.66
[root@mini ~]#
~~~
* 根据hostname 登录
~~~
[root@shizhan ~]# vi /etc/hosts #在66服务上添加
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.43.68 mini
[root@shizhan ~]# ssh mini #直接根据hostname登录
Last login: Thu Sep 6 23:03:07 2018 from shizhan
~~~
**6.修改开机等待时间**
~~~
[root@mini grub]# vi /boot/grub/grub.conf
timeout=0
~~~
**7.解决克隆后eth0不见的问题**
>[danger] 直接修改 /etc/sysconfig/network-script/ifcfg-eth0
>删掉UUID HWADDR
>配置静态地址
>然后 rm -rf /etc/udev/rules.d/70-persistent-net.rules 获者修改这个文件将eth1改为eth0 将原来eth0的删掉。
>然后reboot
>
①查看和配置网络设备
~~~
[root@shizhan ~]# ifconfig -a
eth1 Link encap:Ethernet HWaddr 00:0C:29:9A:0B:82
inet addr:192.168.43.66 Bcast:192.168.43.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe9a:b82/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:32546 errors:0 dropped:0 overruns:0 frame:0
TX packets:4276 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2168414 (2.0 MiB) TX bytes:787699 (769.2 KiB)
~~~
②删掉UUID HWADDR
~~~
[root@shizhan ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=no
BOOTPROTO=static
IPADDR=192.168.43.66
NETMASK=255.255.255.0
GATEWAY=192.168.43.2
~~~
③编辑/etc/udev/rules.d/70-persistent-net.rules 将原来的eth0删掉 将eth1 改为eth0 并reboot
~~~
[root@shizhan ~]# vi /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:9a:0b:82", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
~~~
- 前言准备
- Linux新服务器的前期配置
- 认识linux下的Web服务器
- Linux的基本配置
- LNMP一键安装包快速部署web服务器
- LAMP服务器环境部署
- LAMP服务器管理
- LNMP服务器环境部署
- LNMP服务器管理
- lnmp一键安装包-常见问题
- 使用包管理器快速部署环境
- 包管理器快速部署LAMP服务器环境
- 升级php和mysql版本
- 包管理器快速部署LNMP服务器环境
- 使用源码包部署Linux服务器web环境
- 编译LAMP服务器环境部署
- apache安装与配置
- mysql的安装与配置
- PHP的安装与配置
- 编译LNMP服务器环境部署
- nginx服务启动脚本
- 源码安装常见问题
- Centos6与Centos7的区别
- 默认控制系统服务工具不同
- 设置开机启动的方式不同
- 编写service启动脚本
- 编写systemctl启动脚本
- 服务器安全
- 隐藏服务器信息
- Linux服务器防火墙设置
- 防火墙设置脚本
- 邮件发送
- 任务脚本的编写
- 服务器磁盘和服务器健康状态脚本
- 服务器登录报警脚本
- 数据库备份脚本
- 定时任务及应用
- 常见问题
- linux中使用ping命令不同的问题
- Linux中无法发送邮件
- mailx通过ssl方式发送邮件
- Mysql配置文件
- Linux TCP/UDP 常用端口
- Linux常见命令
- 系统信息
- 关机 (系统的关机、重启以及登出 )
- 文件和目录
- 文件搜索
- 挂载一个文件系统
- 磁盘空间
- 用户和群组
- 文件的权限
- 文件的特殊属性
- 打包和压缩文件
- RPM包
- YUM软件包升级器
- DEB 包 (Debian, Ubuntu 以及类似系统)
- APT 软件工具 (Debian, Ubuntu 以及类似系统)
- 查看文件内容
- 文本处理
- 字符设置和文件格式转换
- 文件系统分析
- 初始化一个文件系统
- SWAP文件系统
- 备份
- 光盘
- 网络-(以太网和WIFI无线)
- vi命令
- cut命令 截取
- Mysql
- MySQL备份-增量备与恢复命令实战
- mysqlbinlog
- mysql的安装
- 卸载mysql
- mysql多实例安装
- mysql 常用基础命令操作
- linux安装jdk、rpm安装mysql
- linux制作本地yum源
- shell脚本