标签 Debian 下的文章

开启Debian/Ubuntu root账户远程ssh登录

Debian 8.0(Jessie)安装完成后默认root账户是无法通过SSH远程登录到主机的。需要修改配置文件 vi /etc/ssh/sshd_config 搜索/PermitRootLogin

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

PermitRootLogin without-password

修改为

PermitRootLogin yes

保存退出:wq

重启sshd服务

/etc/init.d/ssh restart

然后就可以远程root登录Debian/Ubuntu了。这是系统默认的一个安全的设置,为了防止他人通过暴力破解主机的root密码。

DigitalOcean 512MB小内存主机MySQL服务经常崩溃的原因

这段时间在DigitalOcean上面的Web服务器架设好了。但是过几天发现网站频繁的出现WordPress报错:“数据库连接失败”。SSH登录上服务器发现MySQL服务已经停了。重启MySQL service mysql restart 之后过几天又出现了同样的问题,网站服务访问,显示“数据库连接失败”。看来每次手动重启MySQL不是个办法,必须找到出错的原因。

首先考虑既然是MySQL出的问题,我就修改配置文件,把MySQL错误日志打开,一般出错,日志里面应该有我需要的报错详细信息。修改 /etc/mysql/my.cnf

[mysqld_safe]
log-error=/var/log/mysql/tunps.com.err
[mysqld]
log-error=/var/log/mysql/tunps.com.err

加入log-error指定错误日志文件路径。过了几天网站又打不开了,赶紧的查看 /var/log/mysql/tunps.com.err 文件

141222 20:08:50 [Note] Plugin 'FEDERATED' is disabled.
141222 20:08:50 InnoDB: The InnoDB memory heap is disabled
141222 20:08:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
141222 20:08:50 InnoDB: Compressed tables use zlib 1.2.7
141222 20:08:50 InnoDB: Using Linux native AIO
141222 20:08:50 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
141222 20:08:50 InnoDB: Completed initialization of buffer pool
141222 20:08:50 InnoDB: Fatal error: cannot allocate memory for the buffer pool
141222 20:08:50 [ERROR] Plugin 'InnoDB' init function returned error.
141222 20:08:50 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
141222 20:08:50 [ERROR] Unknown/unsupported storage engine: InnoDB
141222 20:08:50 [ERROR] Aborting

发现如上内容。Fatal error: cannot allocate memory for the buffer pool。看来是申请内存失败。网上搜索发现很多人都出现过这个问题。一般会出现在内存较小的VPS主机上。比如我这台主机只有512MB的内存。解决方法是利用Linux的swap交换分区虚拟部分硬盘当内存来使用。具体操作步骤如下

  1. dd if=/dev/zero of=/swapfile bs=1M count=1024

  2. mkswap /swapfile

  3. swapon /swapfile

  4. /etc/fstab 文件新建一行写入 /swapfile swap swap defaults 0 0

这样一个1GB的swap分区就建立成功了,重启MySQL,以后MySQL服务运行得很稳定,再也没有无故停止过。

dpkg error: trying to overwrite X, which is also in package Y

今天ubuntu9.10 alpha4 升级出现了点问题:

Preparing to replace language-pack-zh 1:9.10 (using .../language-pack-zh_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-zh ...
Preparing to replace language-pack-zh-base 1:9.10 (using .../language-pack-zh-base_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-zh-base ...
dpkg: error processing /var/cache/apt/archives/language-pack-zh-base_1%3a9.10+20090805_all.deb (--unpack):
trying to overwrite `/usr/share/locale-langpack/zh_TW/LC_MESSAGES/sed.mo', which is also in package language-pack-zh-hant-base
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Preparing to replace language-pack-gnome-zh 1:9.10 (using .../language-pack-gnome-zh_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-gnome-zh ...
Preparing to replace language-pack-gnome-zh-base 1:9.10 (using .../language-pack-gnome-zh-base_1%3a9.10+20090805_all.deb) ...
Unpacking replacement language-pack-gnome-zh-base ...
dpkg: error processing /var/cache/apt/archives/language-pack-gnome-zh-base_1%3a9.10+20090805_all.deb (--unpack):
trying to overwrite `/usr/share/locale-langpack/zh_TW/LC_MESSAGES/gnome-settings-daemon.mo', which is also in package language-pack-gnome-zh-hant-base

中文的显示是这样:

(正在读取数据库 ... 系统当前总共安装有 123909 个文件和目录。)
正在解压缩 language-pack-gnome-zh-hans-base (从 .../language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb) ...
dpkg:处理 /var/cache/apt/archives/language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb (--unpack)时出错:
正试图覆盖“/usr/share/locale-langpack/zh_CN/LC_MESSAGES/gnome-settings-daemon.mo”,它属于软件包 language-pack-gnome-zh-base
dpkg-deb: 子进程 粘贴 被信号(Broken pipe)终止了
正在解压缩 language-pack-gnome-zh-hant-base (从 .../language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb) ...
dpkg:处理 /var/cache/apt/archives/language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb (--unpack)时出错:
正试图覆盖“/usr/share/locale-langpack/zh_TW/LC_MESSAGES/gnome-settings-daemon.mo”,它属于软件包 language-pack-gnome-zh-base
dpkg-deb: 子进程 粘贴 被信号(Broken pipe)终止了
在处理时有错误发生:
/var/cache/apt/archives/language-pack-gnome-zh-hans-base_1%3a9.10+20090819_all.deb
/var/cache/apt/archives/language-pack-gnome-zh-hant-base_1%3a9.10+20090819_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

类似这样的错误:

dpkg: error processing /var/cache/apt/archives/AAA (--unpack):
trying to overwrite `/usr/lib/BBB', which is also in package CCC
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
AAA
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决方法:

sudo dpkg -i --force-overwrite AAA

(give full path of AAA), and then run

sudo apt-get -f install

again.

[via(翻墙的需要..)]

debian amd64安装flashplayer

debian amd64安装flashplayer

7/30/09之前64位的机子一直都是用nspluginwrapper来模拟运行32位的浏览器插件,不过7/30/09那天,adobe发布了flashplayer 64bit for linux alpha, 可以从这个页面下载:http://labs.adobe.com/downloads/flashplayer10.html 。直接下载(最新版本是10.0.32.18)。

Download 64-bit Plugin for Linux (TAR.GZ, 3.64 MB)

下载下来后

tar zxvf libflashplayer-10.0.32.18.linux-x86_64.so.tar.gz
mkdir /usr/bin/iceweasel/plugins/
cp libflashplayer.so /usr/bin/iceweasel/plugins/

重启iceweasel,搞定。在youku, tudou , vimeo上溜达了一圈没有任何问题。

grub2调整debian字符界面分辨率

我的debian 5默认安装完成之后分辨率是640x480,非常的不方便,并且我安装了grub 2 而不是grub legacy,毕竟喜欢尝试点新东东,配置文件由menu.lst转到了gurb.cfg,我的机子是19寸宽屏,最佳分辨率是1400x900,贴一个grub.cfg文件:

#  
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/update-grub using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd0,1)
search --fs-uuid --set f4695aac-a0bb-468f-8fe1-a88cbe979f49
if font /usr/share/grub/unicode.pff; then
set gfxmode="1024x768x32;800x600x32;640x480x32;1024x768;800x600;640x480"
insmod gfxterm
insmod vbe
terminal gfxterm
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=cyan/black
set menu_color_highlight=white/black
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_hurd ###
### END /etc/grub.d/10_hurd ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Debian GNU/Linux, linux 2.6.26-1-amd64" {
set root=(hd0,1)
search --fs-uuid --set f4695aac-a0bb-468f-8fe1-a88cbe979f49
linux    /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda1 ro vga=36D
initrd    /boot/initrd.img-2.6.26-1-amd64
}
menuentry "Debian GNU/Linux, linux 2.6.26-1-amd64 (single-user mode)" {
set root=(hd0,1)
search --fs-uuid --set f4695aac-a0bb-468f-8fe1-a88cbe979f49
linux    /boot/vmlinuz-2.6.26-1-amd64 root=/dev/sda1 ro single
initrd    /boot/initrd.img-2.6.26-1-amd64
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file is an example on how to add custom entries
### END /etc/grub.d/40_custom ###

unicode.pff是用来添加cjk字体支持的,默认是ascii.pff,

set gfxmode="1024x768x32;800x600x32;640x480x32;1024x768;800x600;640x480"  是用来添加gfx的模式,默认是640x480,格式是:width x height x depth , 多加一些值,用分号括起来,引号引起来,最后又两menuentry,就是grub的启动菜单,修改第一个正常模式启动菜单,后面加个vga=36D ,36D就表示1400x900x32 , vga的值可以通过这里得到:http://en.wikipedia.org/wiki/VESA_BIOS_Extensions#VBE_mode_numbers

不过我发现这个不准确,有时候启动不起,启动系统的时候提示vga的值为未知,然后点enter 列出所有vga的值,这个时候你就记下你所需要的值然后写入grub.cfg就可以了。。。

最后要说的就是grub 2加入了module,需要的功能都必须先insmod ,比如背景图片支持png : insmod png ,支持图形终端:insmod gfxterm 等,现在grub 2的版本是1.96 ,最新的消息可以移步到grub 2 wiki (官方)http://grub.enbug.org/