执行apt-get install 的时候提示
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.
错误。
解决方式
mkdir -p /var/cache/apt/archives/partial
或者
touch /var/cache/apt/archives/lock
执行apt-get install 的时候提示
E: Unable to write to /var/cache/apt/
E: The package lists or status file could not be parsed or opened.
错误。
解决方式
mkdir -p /var/cache/apt/archives/partial
或者
touch /var/cache/apt/archives/lock
SSH Server一般会根据设定的设计自动断开SSH连接,这就是为什么一定时间不操作SSH,SSH会自动断开的原因。
按以下步骤可以延长自动断开的时间。以debian为例
编辑配置文件
nano /etc/ssh/sshd_config
添加两个参数
ClientAliveInterval 600
ClientAliveCountMax 3
按以上的配置的含义就是 SSH会在 30分钟(600秒 X 3)后自动退出。系统默认是ClientAliveInterval为15,ClientAliveCountMax 为3,所以SSH会在45秒之后断开。
保存设置并重载配置文件
/etc/init.d/ssh reload
colinux:~/test# ls
test.tar
colinux:~/test# tar -tvf test.tar
drwxr-xr-x root/root 0 2005-11-17 10:13:37 ./
-rw-r--r-- root/root 16 2005-11-17 10:12:55 ./test2
-rwxr-xr-x root/root 89 2005-11-10 03:23:37 ./test.sh
colinux:~/test# tar --get -vf test.tar test.sh
tar: test.sh: Not found in archive
tar: Error exit delayed from previous errors
colinux:~/test# tar --get -vf test.tar ./test.sh
./test.sh
colinux:~/test# ls -l
total 16
-rwxr-xr-x 1 root root 89 Nov 10 03:23 test.sh
-rw-r--r-- 1 root root 10240 Nov 17 10:13 test.tar
注意添加ip的如果出现错误会导致无法连接服务器,因此改动过程中要非常注意
准备工作
- 认清主机商给你提供的是哪些ip
- ifconfig查看当前服务器的ip
- ping ips -t 查看链接状况,如果此时这是能够Ping通,有可能该ip并没有真正分配给你
开始添加
- 修改 /etc/network/interfaces 文件
- 当前文件可能是如下样式
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 200.63.48.64
netmask 255.255.255.0
network 200.63.48.0
broadcast 200.63.48.255
gateway 200.63.48.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 208.67.222.222
dns-search alicestore.info
- 添加第二个ip
将第一个ip的inferce修改为以下样式
….
# The primary network interface
allow-hotplug eth0:0
iface eth0:0 inet static
…..
eth0可以看作网卡,:0 是绑定的第一个ip
假如主机上分配给你的是 200.63.48.80
直接在文件末尾添加
…..
auto eth0:1
iface eth0:1 inet static
address 200.63.48.80
netmask 255.255.255.0
network 200.63.48.0
broadcast 200.63.48.255
gateway 200.63.48.1
…..
- 认真检查是否正确
- 重新启动networking
执行
# /etc/init.d/networking restart
执行的结果例子
debian:/etc/network# /etc/init.d/networking restart
Reconfiguring network interfaces…if-up.d/mountnfs[eth0:1]: waiting for interface eth0:2 before doing NFS
mounts (warning).
done.
debian:/etc/network# /etc/init.d/networking restart
Reconfiguring network interfaces…if-up.d/mountnfs[eth0:1]: waiting for interface eth0:2 before doing NFS
mounts (warning).
done.
系统应当马上就生效,这是Ping这个ip的话应该就能够Ping通了。
HyperVM,由一家小型公司专门设计的虚拟机支持软件昨天被黑客攻破。HyperVM中绑定虚拟主机管理工具 LXadmin,算open source 中比较健全的软件,因此应用比较广泛。此次攻击导致大约100,000家网站被黑客攻击。一家叫fsckvps的公司损失最大,直接导致大批网站数据丢失完全无法恢复。而开发这个虚拟机软件的公司LXLabs的创始人Ligesh也试图用自杀来逃避的这场灾难。说成灾难是完全的。fsckvps 已经关闭的网站首页,完全改为服务器恢复状态记录清单。从记录上看,有不低于80台机器受到攻击。我们目前有一台放在巴拿马的主机也是用的HyperVM集成的Lxadmin,明天看样子要马上下线更新。
VPS是一种新的主机形态,通过虚拟化技术,将一台物理独立主机分割为更小的虚拟独立主机。因此对需要底层管理权限同时预算有限网站站长非常具有吸引力。目前VPS发展态势非常强劲,但此次软件问题暴露的问题确实震惊。不过国内公司多用windows,这次算是躲过一劫。
根据Wiki提供的消息,Mr. Ligesh在5年前也是自杀身亡,唉,也许这个就是宿命。
MySQLTuner 是一个简易的Perl脚本,可以对你的MySQL性能进行简易分析,并给出优化建议。执行这个脚本进行优化前,简易MySQL在工作状态下工作24个小时。
先下载执行
debian:/usr/local/bin# wget http://mysqltuner.com/mysqltuner.pl
debian:/usr/local/bin# chmod +x mysqltuner.pl
debian:/usr/local/bin# ./mysqltuner.pl
>> MySQLTuner 1.0.0 - Major Hayden <major@mhtx.net>
>> Bug reports, feature requests, and downloads at http://mysqltuner.com/
>> Run with ‘–help’ for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:
——– General Statistics ————————————————–
[–] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.32-Debian_7etch6-log
[OK] Operating on 32-bit architecture with less than 2GB RAM
——– Storage Engine Statistics ——————————————-
[–] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[–] Data in MyISAM tables: 609M (Tables: 3461)
[–] Data in InnoDB tables: 9M (Tables: 185)
[–] Data in MEMORY tables: 213K (Tables: 5)
[!!] Total fragmented tables: 64
——– Performance Metrics ————————————————-
[–] Up for: 2d 16h 7m 39s (4M q [19.375 qps], 64K conn, TX: 1B, RX: 624M)
[–] Reads / Writes: 87% / 13%
[–] Total buffers: 626.0M global + 2.6M per thread (500 max threads)
[!!] Maximum possible memory usage: 1.9G (95% of installed RAM)
[OK] Slow queries: 0% (0/4M)
[OK] Highest usage of available connections: 1% (7/500)
[OK] Key buffer size / total MyISAM indexes: 400.0M/32.2M
[OK] Key buffer hit rate: 99.9% (9M cached / 11K reads)
[OK] Query cache efficiency: 84.4% (3M cached / 4M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 33K sorts)
[!!] Temporary tables created on disk: 43% (21K on disk / 48K total)
[OK] Thread cache hit rate: 99% (7 created / 64K connections)
[OK] Table cache hit rate: 72% (3K open / 5K opened)
[OK] Open file limit used: 10% (6K/65K)
[OK] Table locks acquired immediately: 99% (835K immediate / 835K locks)
[!!] InnoDB data size / buffer pool: 9.5M/8.0M
——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Reduce your overall MySQL memory footprint for system stability
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
*** MySQL’s maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
tmp_table_size (> 32M)
max_heap_table_size (> 16M)
innodb_buffer_pool_size (>= 9M)
最后一个部分给出了优化简易。
这里整理一些获取硬件基本信息的技巧。Debin的硬件信息都保存在 /proc/下,读取相关信息就可以获得硬件信息了。
获取系统内存容量
debian:/# cat /proc/meminfo
MemTotal: 2068860 kB
MemFree: 1177380 kB
上面清楚地说明当前系统是2G内存,1G空闲状况。