分类“操作系统”下的文章

linux install Memcache and libevent

1、下载
Memcache用到了libevent这个库用于Socket的处理,所以还需要安装libevent
libevent
官网地址:http://www.monkey.org/~provos/libevent/
下载地址:http://www.monkey.org/~provos/libevent-2.0.10-stable.tar.gz
Memcache
官网地址:http://memcached.org/
下载地址:http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
2、安装
a)安装libevent
cd libevent-2.0.10-stable/
./configure -prefix=/usr
make
make install
检查是否安装成功
ls -al /usr/lib|grep libevent
b)安装memcached
cd memcached-1.4.5
./configure -with-libevent=/usr
检查是否安成功
ls -al /usr/local/bin/mem*
3、配置Memcache
a.启动Memcache的服务器端:
/usr/local/bin/memcached -d -m 1024 -u root -l 192.168.126.23 -p 12000 -c 1024 -P /tmp/memcached.pid
    -d选项是启动一个守护进程,
    -m是分配给Memcache使用的内存数量,单位是MB,我这里是10MB,
    -u是运行Memcache的用户,我这里是root,
    -l是监听的服务器IP地址,如果有多个地址的话,我这里指定了服务器的IP地址192.168.0.200,
    -p是设置Memcache监听的端口,我这里设置了12000,最好是1024以上的端口,
    -c选项是最大运行的并发连接数,默认是1024,我这里设置了256,按照你服务器的负载量来设定,
    -P是设置保存Memcache的pid文件,我这里是保存在 /tmp/memcached.pid,
如果出现:
/usr/local/bin/memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory
查看文件
find / -name libevent-2.0.so.5
查找结果:
/usr/lib/libevent-2.0.so.5
查看DEBUG以后文件的路径
LD_DEBUG=libs /usr/local/bin/memcached -v
做软链接
ln -s /usr/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5

b.如果要结束Memcache进程,执行:
    # kill `cat /tmp/memcached.pid`
也可以启动多个守护进程,不过端口不能重复。

tcpdump-print-analysis

使用以下命令,监听15001端口的tcp连接,-X 表示以16进制显示报文,-s 0 表示显示整个ip报的内容(默认为68bytes),但如果太长的话,tcpdump的缓冲区可能不够用而引发丢失报文:

$ tcpdump ‘port 15001 and tcp’ -X -s 0

例如,使用telnet发起连接:
yunkai@lsyp1002:~/tmp $ telnet 60.191.115.7 15001
Trying 60.191.115.7…
Connected to 60.191.115.7 (60.191.115.7).
Escape character is ‘^]’.
$W2,53,100,200,057181932602,13656645563,85022088,#
$X2,14,100,1,#^]
telnet> quit

Connection closed.
Continue reading ‘tcpdump-print-analysis’ »

How to backup and restore your database with SSH

由于大数据量的时候phpmyadmin处理起来很吃力,还可能出错,所以通常会在命令行下面备份或者恢复数据库,恰好公司的服务器给了我ssh的root权限,正巧在phpbb的论坛看到了一篇How to backup and restore your database with SSH 的文章,希望对大家有用,另外putty.exe是一个很好的windows下的远程管理工具,可以到各大软件下载站下载

How to backup and restore your database with SSH
原文地址:http://www.phpbb.com/kb/article/how-to-backup-and-restore-your-database-with-ssh/

How to backup and restore your database with SSH

  • Ok, so a lot of people are having trouble backing up and restoring…reasons varying from the query taking longer than the server upload time, corrupted files, improperly split files, etc. Anyway, here is how to do it through SSH.
  • First, you need an ssh client. PuTTY is an easy one to use and works well. Search for it on google and download it.
    1. Under session, put your website name into the host name box. Use port 22, and make sure SSH is selected. Under SSH in the left menu, you may have to select a different protocol. I use 2. Click open.
      在putty客户端中输入你的域名或者是ip地址,选择ssh(如果你是其他的Telnet也可以),端口22,通常不用更改,单击open
    2. Input your site administration username into the shell prompt. It will prompt you for a password. Enter this too. Use the cd command to change directories to where you want your backup to be stored.
      To confirm the directory, type "pwd" without the quotes.
      Input "mysqldump -u [username] -p –opt [databasename] > [backupfilename.sql]" substituting the correct username for your database, database name, and filename for the backup. It will prompt you for a password. Enter your SQL password. If it returns with a prompt and no errors, you successfully made a backup.
      输入你的管理员账户确认之后输入你的密码,使用cd命令进入你想要存放备份的目录,然后输入mysqldump -u [username] -p –opt [databasename] > [backupfilename.sql],注意括号不用输入,username是你的数据库管理用户名,databasename是你想要备份的数据 库,backupfilename.sql是你想要导出的数据库sql文件名,如果没有错误,一段事件之后你将会获得一个sql备份
    3. To restore the database, login as usual. Use the cd command to change directories to where your sql backup is stored. Use the ls command to verifty that the file is there and you have the correct name. Type "mysql -u[username] -p[password] [databasename] < [backupfilename.sql]" and press enter. do not put a space between u and your username, or p and your password. If it returns with a prompt, you successfully restored your database.
      还原数据库亦然,输入命令mysql -u[username] -p[password] [databasename] < [backupfilename.sql]

我的ubuntu初始化布署笔记

更新更新源
deb http://tw.archive.ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb http://tw.archive.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb http://tw.archive.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb http://tw.archive.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb http://tw.archive.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu jaunty main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu jaunty-security main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu jaunty-updates main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu jaunty-backports main restricted universe multiverse
deb-src http://tw.archive.ubuntu.com/ubuntu jaunty-proposed main restricted universe multiverse

开始配置
1 、 编码
执行 sudo gconf-editor
选择 apps/gedit-2/preferences/encodings
找到 auto_detected 编辑,在Values中分别加入 GB18030,GBK,GB2312,BIG5
2、挂载 
 在添加删除程序中  查找 storage device manager
3、安装java环境
apt-get install sun-java6-jdk
JAVA乱码
sudo ln -s /usr/share/fonts/truetype/arphic/uming.ttc /usr/share/fonts/truetype/arphic/uming.ttf
4、oracle
deb http://oss.oracle.com/debian unstable main non-free
/etc/apt/source.list
apt-get update 命令之前
还需要将该源服务器的公钥添加在本地 apt 系统的密钥库中。首先下载公钥:
wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle
下载完成之后添加该公钥到密钥库中:
sudo apt-key add RPM-GPG-KEY-oracle
再执行
sudo apt-get update
oracle-xe – Oracle Database 10g Express Western European Edition
oracle-xe-client – Oracle Client 10g Express Edition
oracle-xe-universal – Oracle Database 10g Express Universal Edition

wine+ie4s
编辑"ies4linux-2.99.0.l/lib/messages.txt"档案
把"tw . zhtw TW"改成"zh tw zhtw TW"
编辑"ies4linux-2.99.0.l/lib/functions.sh"档案
line 98的"pid=$(wget …)"改成"pid=$(LANG=C wget …)"
执行"sudo apt-get install python-gtk2-dev"
不用 gui安装
/ies4linux –no-gui –beta-install-ie7 –locale CN –install-corefonts

Storage Device Manager

FTP软件
‘javaws http://www.crossftp.com/crossftp.jnlp

ssh -l username host.name.domain

flash乱码
cd /etc/fonts/conf.d/
sudo cp 49-sansserif.conf 49-sansserif.conf_backup
sudo rm 49-sansserif.conf
以上命令的功能是先备份49-sansserif.conf文件,再删除,经测试

Redhat Server配置XAMPP+Apache+Php+Mysql+Tomcat+Jsp技术备注

 前2天客户上了一台服务器,机房给做的操作系统是redhat3,郁闷 好老的版本

本来想叫装一个debian/freebad/Ubuntu Server 机房说这个系统是他们那里最稳定的系统,机房的管理员也熟悉这个系统,如果是其他的系统他们不负责日常的故障处理,没办法就讲究了

OK 开始配置。

1、安装apche+php+mysql

我使用的是xampp套件,这个套件不错,整合的很好,不用我还去编译

下载和技术支持页面:http://www.apachefriends.org/zh_cn/xampp-linux.html#1677

下载xampp-linux-1.7.1.tar.gz 解压:tar xvfz xampp-linux-1.7.1.tar.gz -C /opt

这样就安装了xampp到/opt

下面进行xampp的配置:

启用httpd-vhost.conf

参考下面的规则:

<VirtualHost *:88>
        ServerAdmin webmaster@localhost
        DocumentRoot /home/icefox/phpmyadmin/ #该虚拟机的目录
        <Directory /home/icefox/phpmyadmin/> #该目录的配置
                Options FollowSymLinks
                AllowOverride All #开启地址重写
                Order allow,deny #设置访问规则
                allow from all
        </Directory>
        ErrorLog /var/log/apache2/error.log #设置改虚拟机的错误日志文件的存放地址
</VirtualHost>

如果和tomcat 整合参考:

<VirtualHost *:80>
    ServerAdmin mackjieson@gmail.com
    ProxyPass / ajp://localhost:8019/
    ProxyPassReverse / ajp://localhost:8019/
    ServerName www.laolang.cn
    ServerAlias
www.laolang.cn
</VirtualHost>

这里的 ajp://localhost:8019需要我们配置tomcat的server.xml,多站点 需要写多个支持,我测试了子站点,但是测试不成功!

2、安装java的支持环境和安装tomcat

下载jdk

chmod -R 777

./jdk-xxxxxxxxxxxxxxxxxx.bin

我的安装目录:/usr/local/jdk1.5.0_13

注意这里的安装目录,最好规划一下,因为后面的环境变量需要使用

安装tomcat  用tar到 你的目录

我的安装目录:/usr/local/tomcat-5.0.28

接下来配置环境变量

新建一个java.sh到/etc/profile.d/

使用命令:vi /etc/profile.d/java.sh

增加环境变量:
  #set java environment
  JAVA_HOME=/usr/local/jdk1.5.0_13
  CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
  PATH=$JAVA_HOME/bin:$PATH
  TOMCAT_HOME=/usr/local/tomcat-5.0.28
  export JAVA_HOME TOMCAT_HOM CLASSPATH PATH

接下来将  xampp 和tomcat加到系统启动中:

修改 /etc/rc.local ,加入

    sleep 30
    /usr/local/tomcat-5.0.28/bin/startup.sh
    /opt/lampp/lampp start

OK!这样就集成完了

中途测试的时候遇到一个防火墙的问题

修改 vi /etc/sysconfig/iptables

在类似行下面添加如下打开都端口的语句(一般为倒数第二行)

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p --dprot 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p --dprot 3306 -j ACCEPT

备注一些服务器有用的地址

下载远程整个站点通过FTP

lftp ip -u user
mirror wwwroot/

大容量的.SQL的导入,我推荐使用Navicat Lite for MySQL

将数据库生成sql 然后在初始化执行sql 遇到错误的时候跳过

这样就不会出现中途导入出错的问题

技术参考资料:

http://zglsje.blog.163.com/blog/static/294085772008325012028/

http://l–w.blog.sohu.com/54069281.html