标签 Linux管理维护 下的文章

有个用户的MySQL数据库表在phpMyAdmin中显示使用中,提示已经损坏
MySQL的错误日记提示:Table ‘xxx’ is marked as crashed and should be repaired

如果和野草主机一样服务器安装了phpMyAdmin,登入进去,选中有问题的表,滑倒网页底部,有“选中项”的,打开选项,点击“修复表”,即可修复。

1.显示最后20行

tail -n 20 文件名

如tail -n 20 log.txt

2.显示中间20,从1000开始

cat log.txt|tail -n +1000|head -n 20

注:tail -n +行号 意思为 从第多少行开始 ,如果是 tail -n -行 == tail -n 行 意思为文件末尾多少行的数据
head -n 20 前20行的数据

3.也可以用sed命令

如 sed -n '100,120p' log.txt 100 到120行的数据。

参考学习:http://www.cnblogs.com/tuozi001/archive/2013/01/10/2855617.html

[root@localhost ~]# service mysqld start
Another MySQL daemon already running with the same unix socket.
正在启动 mysqld: [失败]

尝试重启,出现如下错误

[root@localhost ~]# /etc/init.d/mysqld status
mysqld 已停

可以执行该命令修复

mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

参考:http://bbs.csdn.net/topics/390662731?page=1#post-396281623

下午在一台centos上折腾,用到mysql的时候发现root密码忘记了,很久没上了……
如果有centos root权限的话,可以尝试跳过验证修密码,具体操作如下。

(mysql如果是通过 yum 安装的,可以用 rpm -ql mysql (usr/bin) 查找安装路径)

# /etc/init.d/mysqld stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password:
mysql>

下载地址:http://pkgs.repoforge.org/p7zip/

CentOS 5.x 32位

# wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el5.rf.i386.rpm
# rpm -ivh p7zip-9.20.1-1.el5.rf.i386.rpm

CentOS 5.x 64位

# wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el5.rf.x86_64.rpm
# rpm -ivh p7zip-9.20.1-1.el5.rf.x86_64.rpm

CentOS 6.x 32位

# wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el6.rf.i686.rpm
# rpm -ivh p7zip-9.20.1-1.el6.rf.i686.rpm

CentOS 6.x 64位

# wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el6.rf.x86_64.rpm
# rpm -ivh p7zip-9.20.1-1.el6.rf.x86_64.rpm

参考: http://teddysun.com/176.html

以root登入,或者su root

# yum install "@Chinese Support"

完成安装后回到桌面进行设置:system -> preferences -> input method

附:在ibus-pinyin里使用搜狗词库

# wget http://hslinuxextra.googlecode.com/files/sougou-phrases-full.7z
# 7za x sougou-phrases-full.7z
# cp ibus/android.db /usr/share/ibus-pinyin/db/android.db
# 输入y确认覆盖

更新系统内核到最新

yum -y update

系统更新后,如果yum安装时提示错误信息,请执行以下命令修复.

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY*

安装Apache,PHP,MySQL,以及扩展

yum -y install httpd php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql

环境 CentOS 6.3 64bit

安装libunwind库(32位系统可省略次步)

wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz

tar zxvf libunwind-0.99-alpha.tar.gz

cd libunwind-0.99-alpha/

CFLAGS=-fPIC ./configure

make CFLAGS=-fPIC

make CFLAGS=-fPIC install

安装Tcmalloc

wget http://gperftools.googlecode.com/files/gperftools-2.0.tar.gz

tar zxvf  gperftools-2.0.tar.gz

cd gperftools-2.0/

./configure

make && make install

echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf

/sbin/ldconfig

编译完成后,我们编辑mysqld_safe文件,加入Tcmalloc部分。

vi /usr/bin/mysqld_safe

# 找到# executing mysqld_safe,在下面加入:
export LD_PRELOAD=/usr/local/lib/libtcmalloc.so

# 保存,退出,重启MySQL。
service mysqld restart

检查是否加载成功,运行:lsof -n | grep tcmalloc
显示如下类似内容即Ok

mysqld 32573 mysql mem REG 9,3 13771446
/usr/local/lib/libtcmalloc.so.4.1.0 (path dev=0,53)

修改配置文件

运行:

vi /etc/my.cnf

全选替换为:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# 12/17/2013 Add
local-infile=0
skip-locking
query_cache_limit=1M
query_cache_size=32M
query_cache_type=1
max_connections=500
interactive_timeout=100
wait_timeout=100
connect_timeout=10
thread_cache_size=128
key_buffer=16M
join_buffer=1M
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M
read_buffer_size=2M
max_connect_errors=10
# Try number of CPU's*2 for thread_concurrency
thread_concurrency=2
myisam_sort_buffer_size=64M
server-id=1

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[myisamchk]
key_buffer=64M
sort_buffer=64M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

以上配置可根据自己服务器情况修改参数!
最后保存退出,运行 service mysqld restart 重启MySQL,完成。