swap 信息丢失 free top 命令不显示交换分区信息

机器运行缓慢,使用top查看时,发现交换分区没有大小,更没有使用率

free -m 查看结果如下:

total       used       free     shared    buffers     cached
Mem:          2016       1961         54          0          3       1369
-/+ buffers/cache:        588       1427
Swap:            0          0          0

fdisk -l 查看结果如下:

Disk /dev/hda: 320.0 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        2538    20386453+   7  HPFS/NTFS
/dev/hda2            2539        7127    36861142+  83  Linux
/dev/hda3            7128        7641     4128705   82  Linux swap / Solaris
/dev/hda4            7650       38913   251128080    f  W95 Ext’d (LBA)
/dev/hda5            7650       15298    61440561    7  HPFS/NTFS
/dev/hda6           15299       28047   102406311    b  W95 FAT32
/dev/hda7           28048       38883    87040138+   7  HPFS/NTFS

/etc/fstab信息如下:

LABEL=/                 /                       ext3    defaults        1 1
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-hda4         swap                    swap    defaults        0 0
/dev/hda6               /mnt/disk/hda6          vfat    defaults        0 0

系统之前出过一次问题,可能因此又导致交换信息丢失,恢复结果如下:

确定之前swap分区为:hda3

swapon /dev/hda3

修改fstab上面红色部分为:

/dev/hda3                swap                    swap    defaults        0 0

保存重启,交换分区正常。

rpm 命令

命令格式 rpm {-q|–query} [select-options] [query-options]

  RPM的查询功能是极为强大,是极为重要的功能之一;举几个常用的例子,更为详细的具体的,请参考#man rpm

1、对系统中已安装软件的查询

1)查询系统已安装的软件

  语法:rpm -q 软件名

  举例:[root@localhost beinan]# rpm -q gaim

  gaim-1.3.0-1.fc4   

       查看系统中所有已经安装的包,要加 -a 参数 ;

  [root@localhost RPMS]# rpm -qa

  如果分页查看,再加一个管道 |和more命令;

  [root@localhost RPMS]# rpm -qa |more

  在所有已经安装的软件包中查找某个软件,比如说 gaim ;可以用 grep 抽取出来;

  [root@localhost RPMS]# rpm -qa |grep gaim

  上面这条的功能和 rpm -q gaim 输出的结果是一样的;

2)查询一个已经安装的文件属于哪个软件包

  语法 rpm -qf 文件名

  注:文件名所在的绝对路径要指出

  举例:

  [root@localhost RPMS]# rpm -qf /usr/lib/libacl.la

  libacl-devel-2.2.23-8

3)查询已安装软件包都安装到何处

  语法:rpm -ql 软件名 或 rpm rpmquery -ql 软件名

  举例:

  [root@localhost RPMS]# rpm -ql lynx

  [root@localhost RPMS]# rpmquery -ql lynx

4)查询一个已安装软件包的信息

  语法格式: rpm -qi 软件名

  举例:

  [root@localhost RPMS]# rpm -qi lynx

5)查看一下已安装软件的配置文件

  语法格式:rpm -qc 软件名

  举例:

  [root@localhost RPMS]# rpm -qc lynx

6)查看一个已经安装软件的文档安装位置

  语法格式: rpm -qd 软件名

  举例:

  [root@localhost RPMS]# rpm -qd lynx

7)查看一下已安装软件所依赖的软件包及文件

  语法格式: rpm -qR 软件名

  举例:

  [root@localhost beinan]# rpm -qR rpm-python

  查询已安装软件的总结:对于一个软件包已经安装,我们可以把一系列的参数组合起来用;比如 rpm -qil ;比如:

  [root@localhost RPMS]# rpm -qil lynx

2、对于未安装的软件包的查看:

  查看的前提是您有一个.rpm 的文件,也就是说对既有软件file.rpm的查看等;

1)查看一个软件包的用途、版本等信息;

  语法: rpm -qpi file.rpm

  举例:

  [root@localhost RPMS]# rpm -qpi lynx-2.8.5-23.i386.rpm

2)查看一件软件包所包含的文件;

  语法: rpm -qpl file.rpm

  举例:

  [root@localhost RPMS]# rpm -qpl lynx-2.8.5-23.i386.rpm

3)查看软件包的文档所在的位置;

  语法: rpm -qpd file.rpm

  举例:

  [root@localhost RPMS]# rpm -qpd lynx-2.8.5-23.i386.rpm

4)查看一个软件包的配置文件;

  语法: rpm -qpc file.rpm

  举例:

  [root@localhost RPMS]# rpm -qpc lynx-2.8.5-23.i386.rpm

5)查看一个软件包的依赖关系

  语法: rpm -qpR file.rpm

  举例:

  [root@localhost archives]# rpm -qpR yumex_0.42-3.0.fc4_noarch.rpm

  /bin/bash

  /usr/bin/python

  config(yumex) = 0.42-3.0.fc4

  pygtk2

  pygtk2-libglade

  rpmlib(CompressedFileNames) <= 3.0.4-1

  rpmlib(PayloadFilesHavePrefix) <= 4.0-1

  usermode

  yum >= 2.3.2

cisco 3640 配置 VPN

                                  Router VPN

r1(config)#crypto isakmp policy 1

(定义IPsec策略框架)

r1(config-isakmp)#encryption 3des

(加密方式为3des)

r1(config-isakmp)#hash sha

(哈希值函数为sha)

r1(config-isakmp)#group 2

(密钥长度group1为76位,group2为1024位)

r1(config-isakmp)#lifetime 28800

(生存时间,即密钥的有效期/秒)

r1(config-isakmp)#authentication pre-share

(认证方式为预共享密钥,/VPN两端预认证字段)

r1(config-isakmp)#exit

r1(config)#crypto isakmp identity address

r1(config)#crypto isakmp key huayu address 218.56.57.59

(标识对端IP地址及预共享密钥内容)

r1(config)#crypto ipsec transform-set huayuipsec esp-3des esp-md5-hmac

(定义IPsec转换集,名为huayuipsec)

r1(cfg-crypto-trans)#exit

配置感兴趣流量

r1(config)#access-list 101  101 permit ip 192.168.10.0 0.0.0.255 192.168.20.0 0.0.0.255

配置map

r1(config)#crypto map huayumap 10 ipsec-isakmp

(定义map图,优先级为10,优先级VPN两端匹配)

% NOTE: This new crypto map will remain disabled until a peer

        and a valid access list have been configured.

r1(config-crypto-map)#set peer 218.56.57.59

(设置对等地址)

r1(config-crypto-map)#set transform-set huayuipsec

(调用定义的转换集)

r1(config-crypto-map)#match address 101

(匹配感兴趣流量)

r1(config-crypto-map)#exit

应用到端口

r1(config)#interface e0/0

r1(config-if)#crypto map huayumap

r1(config-if)#end

*Mar  1 00:29:32.051: %CRYPTO-6-ISAKMP_ON_OFF: ISAKMP is ON

show cryto ipsec sa

mysql 修改密码、开启远程登录(远程访问)

今天朋友做服务器,遇到了点儿问题,协助给解决了一下,其实也没什么,mysql安装及配置问题。

系统为CentOS,内核 2.6.18-164.el5

安装mysql时提示gcc编译错误,估计是没安装gcc编译器。

yum install -y gcc

yum install -y mysql

然后把相关的rpm包都装上,在此不做写出

登陆mysql:

默认用户名为root,密码为空

[root@fast ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.77 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

修改密码为123:

mysql> set password=password(‘123’);
Query OK, 0 rows affected (0.00 sec)

需要远程登录mysql数据库,默认是关闭的,要启动它:

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root’@’%’IDENTIFIED BY ‘YOURPASSWORD’ WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

刷新生效

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

完成。

Neither host ‘localhost’ nor ‘localhost’ could be looked up

安装MYSQL数据库时,启动服务遇到问题,提示如下,由提示错误可以看出,是因为主机名的解析有问题

查看/etc/hosts,文件中没有任何内容,添加一行配置,内容如下:

127.0.0.1        localhost

保存退出,重启服务测试

之前的错误提示:

[root@localhost yum.repos.d]# service mysqld start
初始化 MySQL 数据库: Neither host ‘localhost’ nor ‘localhost’ could be looked up with
/usr/bin/resolveip
Please configure the ‘hostname’ command to return a correct
hostname.
If you want to solve this at a later stage, restart this script
with the –force option
                                                           [失败]

[root@localhost yum.repos.d]# vi /etc/hosts
[root@localhost yum.repos.d]# service mysqld start
初始化 MySQL 数据库: Installing MySQL system tables…
100329 18:18:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to

4294967295
100329 18:18:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to

4294967295
OK
Filling help tables…
100329 18:18:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to

4294967295
100329 18:18:19 [Warning] option ‘max_join_size’: unsigned value 18446744073709551615 adjusted to

4294967295
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password ‘new-password’
/usr/bin/mysqladmin -u root -h localhost password ‘new-password’

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

The latest information about MySQL is available on the web at

http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com
                                                           [确定]
启动 MySQL:                                               [确定]
[root@localhost yum.repos.d]#
[root@localhost yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.77 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> show databases
    -> ;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| test               |
+——————–+
3 rows in set (0.00 sec)

mysql> exit
Bye
[root@localhost yum.repos.d]# mysqladmin -u root password root      //修改密码为root

[root@localhost yum.repos.d]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.0.77 Source distribution

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>