Linux All sorts of problems

Linux下碰到各种各样的问题:

1. 电脑突然断电,虚拟机上 Linux 系统下 ifconfig 命令无网络接口 ens33

解决办法:http://www.cnblogs.com/PatrickLiu/p/8443019.html

[root@sc ~]# /sbin/dhclient 
2. 每次打开虚拟机都没有网络接口 ens33

解决办法:https://blog.csdn.net/qq_42917336/article/details/86490399

systemctl stop NetworkManager 临时关闭 
systemctl disable NetworkManager 永久关闭网络管理命令 
systemctl start network.service 开启网络服务
3. 打开文件,出现 Found a swap file by the name "/etc/.sudoers.tmp.swp

*.swp文件是在 vi 编辑文件时产生的一个临时文件,在编辑过程中过一段时间自动保存一次。如果意外退出,比如在 vi 编辑文件过程中退出系统(意外关机、直接关闭了 Shell 终端等情况),该文件就会存在,下次打开上次编辑的文件时就会出现提示。

解决办法一:mv /etc/.sudoers.tmp.swp /tmp/
解决办法二:冒号 recover 回车,会看到文件内容,然后保存退出,rm /etc/.sudoers.tmp.swp 删除就可以了
E325: ATTENTION
Found a swap file by the name "/etc/.sudoers.tmp.swp
"
          owned by: root   dated: Mon Mar 25 20:35:4
6 2019
         file name: /etc/sudoers.tmp
          modified: YES
         user name: root   host name: sc
        process ID: 9060
While opening file "/etc/sudoers.tmp"
             dated: Mon Mar 25 22:46:40 2019
      NEWER than swap file!

(1) Another program may be editing the same file.  I
f this is the case,
    be careful not to end up with two different inst
ances of the same
    file when making changes.  Quit, or continue wit
h caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /
etc/sudoers.tmp"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/
etc/.sudoers.tmp.swp"
    to avoid this message.
4. 虚拟机昨晚关机了,今天已启动,显示之前创建的虚拟主机 111.com 网页登陆不上了,解决办法如下

在这里插入图片描述

1. 首先查看虚拟主机的配置文件是否有问题,可以测一下:
[root@sc ~]# vim /usr/local/apache2.4.39/conf/extra/httpd-vhosts.conf

2. 查看一下在linux环境下,能否执行并显示:
[root@sc ~]# curl -x127.0.0.1:80 -u sc:123 111.com/123.php
123.php[root@sc ~]#

3. 这个时候可以初步判断虚拟主机是没有问题的

4. 查看端口是否开放:
[root@sc ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      6068/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      6305/master         
tcp6       0      0 :::80                   :::*                    LISTEN      6810/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      6068/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      6305/master         

5. 重启 httpd 服务:
[root@sc ~]# /usr/local/apache2.4.39/bin/apachectl start

6. 这时候网站显示还是没有

7. 临时启动 80 端口
[root@sc ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT

8. 网页可以显示了

在这里插入图片描述

5. 在做 mysql 主从实验过程中碰到个错误,显示 IO 是 NO 的状态,随后查看错误日志

解决问题网址:https://www.cnblogs.com/datalife/p/8026928.html

mysql> stop slave; 停止 从机
mysql> start slave; 开启 从机
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.85.130
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: sc-01.000002
          Read_Master_Log_Pos: 120
               Relay_Log_File: sc02-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: sc-01.000002
             Slave_IO_Running: No              #这里有问题
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 120
              Relay_Log_Space: 120
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1593
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 130
                  Master_UUID: 
             Master_Info_File: /data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 190529 14:02:47
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
1 row in set (0.00 sec)

mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)

mysql> start slave;
Query OK, 0 rows affected (0.01 sec)

mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State: 
                  Master_Host: 192.168.85.130
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: sc-01.000002
          Read_Master_Log_Pos: 120
               Relay_Log_File: sc02-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: sc-01.000002
             Slave_IO_Running: No
            Slave_SQL_Running: Yes
              Replicate_Do_DB: 
          Replicate_Ignore_DB: 
           Replicate_Do_Table: 
       Replicate_Ignore_Table: 
      Replicate_Wild_Do_Table: 
  Replicate_Wild_Ignore_Table: 
                   Last_Errno: 0
                   Last_Error: 
                 Skip_Counter: 0
          Exec_Master_Log_Pos: 120
              Relay_Log_Space: 120
              Until_Condition: None
               Until_Log_File: 
                Until_Log_Pos: 0
           Master_SSL_Allowed: No
           Master_SSL_CA_File: 
           Master_SSL_CA_Path: 
              Master_SSL_Cert: 
            Master_SSL_Cipher: 
               Master_SSL_Key: 
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 1593
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work.
               Last_SQL_Errno: 0
               Last_SQL_Error: 
  Replicate_Ignore_Server_Ids: 
             Master_Server_Id: 130
                  Master_UUID: 
             Master_Info_File: /data/mysql/master.info
                    SQL_Delay: 0
          SQL_Remaining_Delay: NULL
      Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
           Master_Retry_Count: 86400
                  Master_Bind: 
      Last_IO_Error_Timestamp: 190529 14:06:44
     Last_SQL_Error_Timestamp: 
               Master_SSL_Crl: 
           Master_SSL_Crlpath: 
           Retrieved_Gtid_Set: 
            Executed_Gtid_Set: 
                Auto_Position: 0
1 row in set (0.00 sec)

mysql>
首先查看 mysql 的错误日志:

[root@sc01 ~]# cd /data/mysql/
[root@sc01 mysql]# ls
auto.cnf  ib_logfile0  ib_logfile1  ibdata1  mysql  mysql2  performance_schema  sc-01.000001  sc-01.000002  sc-01.index  sc.err  sc01  sc01.err  sc01.pid  test  zrlog
[root@sc01 mysql]# vi sc01.err

Slave I/O: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server UUIDs; these UUIDs must be different for replication to work. Error_code: 1593I/O:致命错误:I/O线程停止,因为主从拥有相同的MySQL服务器uuid;这些uuid必须是不同的,以便复制能够工作。Error_code: 1593

因为是克隆机,所以mysql的uuid是一样的

解决办法:

mv /mysql/data/auto.cnf /mysql/data/auto.cnf.bak 重启mysql解决
6. zabbix服务端连接客户端报错Received empty response from Zabbix Agent at [192.168.85.131]. Assuming that agent dropped connection because of access permissions

在这里插入图片描述

解决办法:https://blog.csdn.net/zunwangtianqian/article/details/82793460

1. 先查看客户端的配置文件 service和serviceActive 一定要填写的是service端本机的ip,而不是配置文件127.0.0.1
2. 在service端重启zabbix-service
3. 在客户端重启zabbix-agent
4. [root@test01 ~]# zabbix_get -s 192.168.85.131 -k "system.hostname"
test02
7. MySQL内存太小,mysqld_safe启动时报错“/usr/bin/mysqld_safe: line 166: 8059 Killed”的解决办法

在这里插入图片描述

服务器内存太小的原因

Starting MySQL./usr/local/mysql/bin/mysqld_safe: line 183: 16250 Killed                  nohup /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/error.log --pid-file=/data/mysql/sc-01.pid --socket=/tmp/mysql.sock < /dev/null > /dev/null 2>&1
The server quit without updating PID file (/data/mysql/sc-0[FAILED]

在这里插入图片描述

解决办法:

[root@sc-01 bin]# vim /etc/my.cnf

datadir=/data/mysql
socket=/tmp/mysql.sock
log-error=/data/mysql/error.log
key_buffer=16K
table_open_cache=4
query_cache_limit=256K
query_cache_size=4M
max_allowed_packet=1M
sort_buffer_size=64K
read_buffer_size=256K
thread_stack=64K
innodb_buffer_pool_size = 56M

8. 停止或者启动mysql问题

/usr/local/mysql/bin/mysqld stop

2019-08-13 16:31:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-13 16:31:08 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-08-13 16:31:08 0 [Note] /usr/local/mysql/bin/mysqld (mysqld 5.6.43) starting as process 6299 ...
2019-08-13 16:31:08 6299 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2019-08-13 16:31:08 6299 [ERROR] Aborting

2019-08-13 16:31:08 6299 [Note] Binlog end
2019-08-13 16:31:08 6299 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete

[root@user ~]# mysqld  --initialize
2019-08-13 16:36:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-08-13 16:36:08 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2019-08-13 16:36:08 0 [Note] mysqld (mysqld 5.6.43) starting as process 6301 ...
2019-08-13 16:36:09 6301 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root!

2019-08-13 16:36:09 6301 [ERROR] Aborting

2019-08-13 16:36:09 6301 [Note] Binlog end
2019-08-13 16:36:09 6301 [Note] mysqld: Shutdown complete


#错误含义:

不推荐使用具有隐式默认值的时间戳。请使用——explicit_defaults_for_timestamp服务器选项(有关详细信息,请参阅文档)[注意]——secure-file-priv被设置为NULL。禁用与导入和导出数据相关的操作

[注意]/usr/local/mysql/bin/mysqld (mysqld 5.6.43)从进程6299开始…

[错误]致命错误:请阅读手册的“安全”部分,了解如何运行mysqld作为根目录!



2019-08-13 16:31:08 6299[错误]正在中止



[]Binlog结束

[注意]/usr/local/mysql/bin/mysqld:关机完成




出现问题的可能性
1、可能是/usr/local/mysql/data/数据目录mysql用户没有权限(修改数据目录的权限)

   解决方法 :给予权限,执行  "chown -R mysql.mysql /usr/local/mysql/data"  然后重新启动mysqld

 

2、可能进程里已经存在mysql进程

   解决方法:用命令“ps -ef|grep mysqld”查看是否有mysqld进程,如果有使用“kill -9  进程号”杀死,然后重新启动mysqld!

 

3、可能是第二次在机器上安装mysql,有残余数据影响了服务的启动。

   解决方法:去mysql的二进制日志目录看看,如果存在mysql-binlog.index,就赶快把它删除掉吧

 

4、mysql在启动时没有指定配置文件时会使用/etc/my.cnf配置文件,请打开这个文件查看在[mysqld]下有没有指定数据目录(datadir)。

   解决方法:请在[mysqld]下设置这一行:datadir = /usr/local/mysql/data

 

5、skip-federated字段问题

   解决方法:检查一下/etc/my.cnf文件中有没有没被注释掉的skip-federated字段,如果有就立即注释掉吧。

 

6、错误日志目录不存在

   解决方法:使用“chown” “chmod”命令赋予mysql所有者及权限



7、selinux惹的祸,如果是centos系统,默认会开启selinux



8、解决办法:因为是克隆机启动mysqld服务就遇到问题

   5.7总会出现这个问题
   在cmd安装好MySQL之后,输入mysqld  --initialize 进行初始化
   然后就会发现目录下多了一个data文件夹,再启动应该就没问题了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值