Linux常见问题

来源:互联网 发布:自学java如何找工作 编辑:程序博客网 时间:2024/06/05 04:09

问题1:

CenOS6.7无法上网


解决方法: (该解决方法是设置为NAT模式)

1.将网络连接模式设置成NAT模式,不能设置成仅主机模式2.查看IP网段与网关网段是否一致, 如果不一致:将IP网段设置成与网管网段一致3.将ONBOOT设置成yes4.将网关设置成与非虚拟机不同的网关地址, 如:非虚拟机地址为192.168.179.1,那么虚拟机的地址应改为192.168.179.2(除192.168.179.1以外的地址)5.编辑->虚拟网络编辑器->NAT模式->NAT设置,将网关设置成与4中的网关地址一致



问题2:

网卡eth0启动失败


解决方法:

1.查看/etc/sysconfig/network-scripts/ifcfg-eth0下和/etc/udev/rules.d/70-perisitent-net.rules的HWADDR值是否一致,若不一致,则修改HWADDR的值.70-perisitent-net.rules下的ATTR{address}值为准.2.查看/etc/udev/rules.d/70-perisitent-net.rules文件,将不是eth0的网卡注释或者删除3.然后重启网卡注意:记得配置DNS



问题3:

设置虚拟机与系统时间同步问题
在安装完CentOS系统后发现时间与现在时间相差8小时,这是由于我们在安装系统的时选择的时区是上海,
而CentOS默认bios时间是utc时间,所以时间相差了8小时。这个时候的bios的时间和系统的时间是不一致的,一个代表 utc 时间,一个代表cst(+8时区),即上海时间


解决方案:

下面是同步时间的解决方法:
1.编辑文件/etc/sysconfig/clock文件

sudo vi /etc/sysconfig/clock   
ZONE="Asia/Shanghai"                        #将时区设为上海UTC=false                                #设置为false,硬件时钟不于utc时间一致ARC=false

2.将linux的时区设置为上海时区

sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime      

3.对准时间,需要先安装ntp服务器

yum install ntp
sudo ntpdate asia.pool.ntp.org   

4.设置硬件时间和系统时间一致并校准

sudo /sbin/hwclock --systohc   

至此,linux系统时间和计算机硬件时间都是cst时间了,并且为上海时区。




问题4:

配置主从节点NTP服务


解决方法:

1.安装NTP服务

yum install ntp     

2.配置NTP服务, prefer意味着首选IP地址,在主节点设置对准 65.55.56.206 时间,从节点设置主节点IP

vi /etc/ntp.conf    
主:server 65.55.56.206 preferserver 0.asia.pool.ntp.orgserver 1.asia.pool.ntp.orgserver 2.asia.pool.ntp.org  
副: server m1 prefer            #m1为主节点IP

3.设置开机启动NTP服务

chkconfig ntpd on 

4.检查是否设置成功,其中2-5为on状态就代表成功

chkconfig --list ntpd 



问题5:

启动linux时, 无法进入系统, 显示错误:

Kernel panic - not syncing: Attemted to kill init!Pid 1, comm: init not tainted 2.6.32-358.e16.x86_64 #1Call Trace: [<ffffffff8150cfc8>] ? panic+0xa7/0/0x16f[<ffffffff81073ae2>] ? do_exit+0xa7862/0x870[<ffffffff81182885>] ? fput+0x25/0x870[<ffffffff81073b48>] ? do+group_exit+0x58/0x20[<ffffffff81073bd7>] ? sys_exit_group+0x17/0x20[<ffffffff8100b072>] ? system_call_fastpath+0x16/0x161b


解决方法:

1.系统启动的时候,倒数三秒内按下'e'键进入grub编辑界面,编辑grub菜单,选择"kernel /vmlinuz-2.6.23.1-42.fc8 ro root=/dev/vogroup00/logvol00 rhgb quiet" 一栏,按'e'键进入编辑,在末尾增加enforcing=0,即:

kernel /vmlinuz-2.6.23.1-42.fc8 ro root=/dev/vogroup00/logvol00 rhgb quiet enforcing=0

然后回车, 按下"b"重启Linux

2.在重启linux之后, 输入用户名密码进入系统, 然后修改/etc/selinux/config配置文件, 即:

vi /etc/selinux/config
SELINUX=disabled

并且在控制台输入以下命令:

setenforce 0

3.修改(2)中这两项之后, 再次重启Linux.




问题6:

当虚拟机无法ping通主机时


解决方法:

控制面板-> 网络和Internet-> 网络共享中心-> Windows防火墙-> 高级设置-> 入站规则-> 选择"文件和打印共享(回显请求 – ICMPv4-In" "公用和专用"项, 禁用规则(默认为启动规则)



问题7:

在yum运行时强制关闭,后启动yum报错

[centos@h1 ~]$ sudo yum search parquetLoaded plugins: fastestmirror, refresh-packagekit, securityExisting lock /var/run/yum.pid: another copy is running as pid 4292.Another app is currently holding the yum lock; waiting for it to exit...The other application is: yumMemory :  24 M RSS (863 MB VSZ)Started: Mon Dec  5 23:45:51 2016 - 09:56 agoState  : Traced/Stopped, pid: 4292


解决方案:

rm -f /var/run/yum.pid



问题8:

yum下载慢或yum无法下载


解决方案:

更换yum源
163 <=>      wget http://centos.ustc.edu.cn/CentOS-Base.repo搜狐 <=>      wget http://mirrors.sohu.com/help/CentOS-Base-sohu.repo阿里云 <=>    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo网易 <=>      wget http://mirrors.163.com/.help/CentOS-Base-163.repo
(1) cd /etc/yum.repos.d(2) mv CentOS-Base.repo CentOS-Base.repo.backup(3) wget http://mirrors.163.com/.help/CentOS6-Base-163.repo(4) mv CentOS6-Base-163.repo CentOS-Base.repo(5) yum clean all(6) yum makecache



问题9:

linux扩展磁盘空间


解决方案:

http://www.jianshu.com/p/ba7090b1ef38



问题11:

报错信息如下:

crontab中启动的shell脚本不能正常运行,但是使用手动执行没有问题 


解决方案:

在脚本第一行写上source /etc/profile,因为cront进程不会自动加载用户目录下的.profile文件




0 0