存档

‘linux相关’ 分类的存档

centos6下挂载nfs

2011年10月7日 没有评论

其实和以前的centos5没啥区别,只不过centos的安装是选mini的还真够mini的,啥都要自己yum。这不连nfs都默认不装了。
mount -t nfs 192.168.1.1:/nfs1 /mnt/nfs
直接提示

mount: wrong fs type, bad option, bad superblock on 192.168.1.1:/nfs1,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

需要安装下相关的软件包
yum -y install nfs-utils nfs-utils-lib

这时再尝试依然会出错

mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd.
mount.nfs: an incorrect mount option was specified

原因是rpcbind没启动
chkconfig –list看见是默认启动的,应该是刚装后没启动,手工启动下。
/etc/rc.d/init.d/rpcbind start
然后再
mount -t nfs 192.168.1.1:/nfs1 /mnt/nfs 就正常了

分类: linux相关, 只谈技术 标签: , ,

关闭centos6的ipv6

2011年10月7日 没有评论

新增文件 /etc/modprobe.d/ipv6-off.conf  内容:

alias net-pf-10 off
alias ipv6 off

编辑 /etc/sysconfig/network 增加内容:

NETWORKING_IPV6=no

关闭自动启动ip6tables

chkconfig ip6tables off
重启即可

分类: linux相关 标签: ,

克隆centos6虚拟机后网络无法启动问题解决

2011年10月7日 1 条评论

在克隆centos6的虚拟机后会发现启动网络的时候有报错

Bringing up interface eth0:  Device eth0 does not seem to be present, delaying initialization.

查看配置文件发现并没有像centos5那样克隆后会把原先的ifcfg-eth0备份成ifcfg-eth0.bak然后生成新的初始化的ifcfg-eth0

上网查了查资料,原来centos6会对mac地址和网卡设备名进行绑定,克隆前网卡的mac地址已经绑定了eth0,在克隆后生成的新的mac地址被顺延绑定到了eth1,但是我们又没有对应eth1

的配置文件所以启动就提示出错了。

只需要编辑

vi /etc/udev/rules.d/70-persistent-net.rules

将原来eth0那行删除,把新生成的eth1那行里面的eth1改成eth0 然后修改或者删除下配置文件里面的mac地址和uuid和最后重启下即可。

分类: linux相关, 只谈技术 标签:

完美解决nginx环境下服务器上多站点WebShell访问限制问题

2011年7月6日 没有评论

完美解决nginx环境下服务器上多站点WebShell访问限制问题

http://www.discuz.net/thread-1497466-1-1.html


wget http://www.php.net/get/php-5.2.10.tar.gz/from/this/mirror
wget http://php-fpm.org/downloads/php-5.2.10-fpm-0.5.13.diff.gz
tar zxvf php-5.2.10.tar.gz
gzip -cd php-5.2.10-fpm-0.5.11.diff.gz | patch -d php-5.2.10 -p1
cd php-5.2.10/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-ftp --without-pear


vi main/fopen_wrappers.c


/* {{{ php_check_open_basedir
*/
PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC)
{
/* Only check when open_basedir is available */
if (PG(open_basedir) && *PG(open_basedir)) {
char *pathbuf;
char *ptr;
char *end;

下面加上:
char *env_document_root = sapi_getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC);
if (php_check_specific_open_basedir(ptr, path TSRMLS_CC) == 0) {
efree(env_document_root);
return 0;
}

然后保存,退出。

php.in的open_basedir配置:
修改:
;open_basedir =

open_basedir = “/tmp/:/var/tmp/”

重启
/usr/local/php/sbin/php-fpm restart

pureftpd如何刷新用户目录已使用的总容量

2010年9月8日 没有评论

今天一个部门打电话来说文件传不上ftp,看了下提示是空间满了,结果扫描了下实际容量似乎没满,感觉是quota的识别容量错了。
说实话这pureftpd用的还很少在安装目录里面逛了圈发现了pure-quotacheck这个命令,应该就是了。
试了试使用格式如下:
/usr/local/pureftpd/sbin/pure-quotacheck -u www -d /www/aaa.com

-u 是你指定pure-quotacheck运行时以系统的什么用户去扫描
-d 就是你ftp站点的目录

RHEL5/CentOS5 上支持 Ext4

2010年8月4日 没有评论

根据我以前的测试 Ext4 的性能好过 Ext3,在 RHEL5 上的 2.6.18-110 也有加入 Ext4 了。但默认没有让我们使用,怎么样才能不重起,能使用这个啦。
其实我们只要加入一个包e4fsprogs 就行,它其实和 e2fsprogs 是一样的功能,这 RHEL-6 中,会变成一个默认的包的。所以我们目前还只能使用这个包来调整和设置Ext4.

yum -y install e4fsprogs

在 RHEL 和 Centos5 中使用 Ext4 前,很多想可能想先给现有的文件系统转换成 Ext4 ,只要运行下面的命令就行了

tune4fs -O extents,uninit_bg,dir_index,flex_bg /dev/sdb1

在重起前,我还要让内核支持 Ext4 的文件系统,需要修改 initrd 的文件本身的内容。如下命令来生成 支持 Ext4 的 initrd。

mkinitrd --with=ext4 --with=ext3 -f /boot/initrd-2.6.18-194.8.1.el5.img 2.6.18-194.8.1

转载自:扶凯[http://www.php-oa.com]

分类: linux相关 标签:

php开启open_basedir后启用eaccelerator时File() on line 0报错解决

2010年6月14日 没有评论

open_basedir是php提升安全性的重要功能,eaccelerator是提速php的扩展模块,但是似乎默认环境下他们2一起用只要有require就会造成大量的php错误。


PHP Warning: Unknown: open_basedir restriction in effect. File() is not within the allowed path(s): (/www/:/tmp/) in Unknown on line 0

要解决这个问题的话在编译eaccelerator时 加上一个参数就行 –without-eaccelerator-use-inode
官方也说将在0.9.6.1的下一个release中默认启用这个参数。

linux下如何在一台机器上安装多个mysql实例

2010年4月27日 没有评论

最近再做个mysql一从多主的配置,需要在一台机器上安装多个mysql。
起先是按照复制了多了mysql 同时起,在琢磨如何做启动脚本的时候发现support-files目录下有个mysqld_multi.server文件,一查发现原来是现成的多实例管理工具。
首先得新建个data目录给新的实例,可以把原来的data目录复制个新的 只需要mysql库,也可以用工具部属个

1
./scripts/mysql_install_db --basedir=/usr/local/mysql3307 --datadir=/mysql/mysql3307/data --user=mysql

然后修改下my.cnf
主要增加

1
2
3
4
5
6
[mysqld_multi]
mysqld = /usr/local/mysql/bin/mysqld_safe
mysqladmin = /usr/local/mysql/bin/mysqladmin
user = shutdown
password = 123456
log = /mysql/mysqld_multi.log

然后把原来的 [mysqld] 改为 [mysqld1]
在新增新的实例配置

1
2
3
4
5
6
[mysqld2]
port = 3307
socket = /tmp/mysql3307.sock
datadir = /storage/mysql/data3307
............
............

然后把 mysqld_multi.server 做成启动服务

1
2
3
4
5
6
cp ./support-files/mysqld_multi.server /etc/rc.d/init.d/mysqld
chown root:root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 3 mysqld on
chkconfig --level 5 mysqld on

启动和关闭全部mysql实例
启动:service mysqld start
关闭:service mysqld stop

对单台数据库的启动和关闭
启动: service mysqld start 1
关闭: service mysqld stop 1

也可以同时启动和关闭多个数据库实例
启动: service mysqld start 1-2
关闭: service mysqld stop 1-2

如果启动的时候提示出错信息:
WARNING: my_print_defaults command not found.
Please make sure you have this command available and
in your path. The command is available from the latest
MySQL distribution.
ABORT: Can’t find command ‘my_print_defaults’.
This command is available from the latest MySQL
distribution. Please make sure you have the command
in your PATH.

先添加
export PATH=/usr/local/mysql/bin:$PATH
然后在启动mysql

linux执行脚本提示: No such file or directory

2009年12月31日 4 条评论

今天在装sphinx,收尾准备做个增量的脚本放crontab里面去,结果每次执行都是提示: No such file or directory。搞来搞去最后发现文本格式忘了改成unix的了,汗

分类: linux相关 标签: ,

Nginx+keepalived负载均衡篇

2009年11月6日 3 条评论

由于nginx的url hash功能可以很好的提升squid的性能,所以我把squid前端的负载均衡器更换为nginx,但是一台nginx就形成了单点,现在使用keepalived来解决这个问题,keepalived的故障转移时间很短(<1s),而且配置简单,这也是选择keepalived的一个主要原因,建议日PV值小的中小型企业web均可采用如下方案实行,下面直接上安装步骤:

一、环境:
centos5.3、nginx-0.7.51、keepalived-1.1.19
主nginx负载均衡器:192.168.0.154
辅nginx负载均衡器:192.168.9.155
vip:192.168.0.188

二、安装keepalived

#tar zxvf keepalived-1.1.19.tar.gz
#cd keepalived-1.1.19
#./configure --prefix=/usr/local/keepalived
#make
#make install
#cp /usr/local/keepalived/sbin/keepalived /usr/sbin/
#cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/
#cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/
#mkdir /etc/keepalived
#cd /etc/keepalived/
vim keepalived.conf

! Configuration File for keepalived
global_defs {
notification_email {
yuhongchun027@163.com
}
notification_email_from keepalived@chtopnet.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state MASTER
interface eth0
virtual_router_id 51
mcast_src_ip 192.168.0.155 <==辅nginx的IP地址
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass chtopnet
}
virtual_ipaddress {
192.168.0.188 <==vip地址
}
}
#service keepalived start
我们来看一下日志:
[root@ltos ~]# tail /var/log/messages
Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.188 on eth0.
Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.154 on eth0.
Oct 6 03:25:03 ltos avahi-daemon[2306]: Registering HINFO record with values 'I686'/'LINUX'.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Withdrawing address record for fe80::20c:29ff:feb9:eeab on eth0.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Withdrawing address record for 192.168.0.154 on eth0.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Host name conflict, retrying with
Oct 6 03:25:23 ltos avahi-daemon[2306]: Registering new address record for fe80::20c:29ff:feb9:eeab on eth0.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.188 on eth0.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Registering new address record for 192.168.0.154 on eth0.
Oct 6 03:25:23 ltos avahi-daemon[2306]: Registering HINFO record with values ‘I686′/’LINUX’.

很显然vrrp已经启动,我们还可以通过命令:#ip a 来检查

[root@ltos html]# ip a
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:ba:9b:e7 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.154/24 brd 192.168.0.255 scope global eth0
inet 192.168.0.188/32 scope global eth0
inet6 fe80::20c:29ff:feba:9be7/64 scope link
valid_lft forever preferred_lft forever
3: sit0: mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0

说明vip已经启动,这样主服务器就配置好了,辅机的配置大致一样,除了配置文件有少部分的变化,下

面贴出辅机的配置文件:

! Configuration File for keepalived
global_defs {
notification_email {
yuhongchun027@163.com
}
notification_email_from keepalived@chtopnet.com
smtp_server 127.0.0.1
smtp_connect_timeout 30
router_id LVS_DEVEL
}

vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
mcast_src_ip 192.168.0.154 <==主nginx的IP的地址
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass chtopnet
}
virtual_ipaddress {
192.168.0.188
}
}

检查其配置
[root@ltos html]# ip a
1: lo: mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:0c:29:ba:9b:e7 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.155/24 brd 192.168.0.255 scope global eth0
inet 192.168.0.188/32 scope global eth0
inet6 fe80::20c:29ff:feba:9be7/64 scope link
valid_lft forever preferred_lft forever
3: sit0: mtu 1480 qdisc noop
link/sit 0.0.0.0 brd 0.0.0.0

测试其效果方法很简单,分别在主辅机上建立不同的主页,index.html分别为192.168.0.154,192.168.0.155,然后用客户机上elinks http://192.168.0.188,主机down掉后辅机会马上接替提供服务,间隔时间几乎无法感觉出来,这个环境准备再进行下压力测试,用于我杭州网跃朋友的web服务器,如有疑问请联系yuhongchun027@163.com(抚琴煮酒)

转载至 http://hi.baidu.com/yuhongchun027/blog/item/25eca12c3442e9e68a13998c.html