Archive for the '旧的回忆' Category

squid基本安装运行

星期一, 十二月 5th, 2005

1、下载一个可编译的稳定版本,目前版本应为2.5
ftp://www.squid-cache.org/pub/squid-2/STABLE/


2、安装squid-2.5.STABLE5.tar.gz
        % tar xzf squid-2.5.STABLE5.tar.gz
        % cd squid-2.5.STABLE5
        % ./configure –prefix=/usr/local/squid
        % make
        % make install


附configure options


  –prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/squid]
  –enable-dlmalloc[=LIB] Compile & use the malloc package by Doug Lea
  –enable-gnuregex       Compile GNUregex
  –enable-splaytree      Use SPLAY trees to store ACL lists
  –enable-xmalloc-debug  Do some simple malloc debugging
  –enable-xmalloc-debug-trace
                          Detailed trace of memory allocations
  –enable-xmalloc-statistics
                          Show malloc statistics in status page
  –enable-carp           Enable CARP support
  –enable-async-io       Do ASYNC disk I/O using threads
  –enable-icmp           Enable ICMP pinging
  –enable-delay-pools    Enable delay pools to limit bandwith usage
  –enable-mem-gen-trace  Do trace of memory stuff
  –enable-useragent-log  Enable logging of User-Agent header
  –enable-kill-parent-hack
                          Kill parent on shutdown
  –enable-snmp           Enable SNMP monitoring
  –enable-cachemgr-hostname[=hostname]
                          Make cachemgr.cgi default to this host
  –enable-arp-acl        Enable use of ARP ACL lists (ether address)
  –enable-htpc           Enable HTCP protocol
  –enable-forw-via-db    Enable Forw/Via database
  –enable-cache-digests  Use Cache Digests
                          see http://www.squid-cache.org/Doc/FAQ/FAQ-16.html
  –enable-err-language=lang
                          Select language for Error pages (see errors dir)


3、现在squid安装在/usr/local/squid下
要启动需编辑etc/squid.conf文件
cache_effective_user=squid
cache_effective_group=squid
然后将/usr/local/squid/var/logs目录分配给squid用户
        % chown squid.squid -R /usr/local/squid/var/logs


4、创建swap空间
        % /usr/local/squid/sbin/squid -z

5、检查配置
       % /usr/local/squid/sbin/squid -k parse
如果没有任何提示则表明配置无误。


6、启动
调试模式:
       % /usr/local/squid/sbin/squid -NCd1
服务模式
       % /usr/local/squid/sbin/squid


7、关闭
       % /usr/local/squid/sbin/squid -k shutdown


附录,squid 命令参数


-a

Specify an alternate port number for incoming HTTP requests. Useful for testing a configuration file on a non-standard port.


-d

Debugging level for “stderr” messages. If you use this option, then debugging messages up to the specified level will also be written to stderr.


-f

Specify an alternate squid.conf file instead of the pathname compiled into the executable.


-h

Prints the usage and help message.


-k reconfigure

Sends a HUP signal, which causes Squid to re-read its configuration files.


-k rotate

Sends an USR1 signal, which causes Squid to rotate its log files. Note, if logfile_rotate is set to zero, Squid still closes and re-opens all log files.


-k shutdown

Sends a TERM signal, which causes Squid to wait briefly for current connections to finish and then exit. The amount of time to wait is specified with shutdown_lifetime.


-k interrupt

Sends an INT signal, which causes Squid to shutdown immediately, without waiting for current connections.


-k kill

Sends a KILL signal, which causes the Squid process to exit immediately, without closing any connections or log files. Use this only as a last resort.


-k debug

Sends an USR2 signal, which causes Squid to generate full debugging messages until the next USR2 signal is recieved. Obviously very useful for debugging problems.


-k check

Sends a “ZERO” signal to the Squid process. This simply checks whether or not the process is actually running.


-s

Send debugging (level 0 only) message to syslog.


-u

Specify an alternate port number for ICP messages. Useful for testing a configuration file on a non-standard port.


-v

Prints the Squid version.


-z

Creates disk swap directories. You must use this option when installing Squid for the first time, or when you add or modify the cache_dir configuration.


-D

Do not make initial DNS tests. Normally, Squid looks up some well-known DNS hostnames to ensure that your DNS name resolution service is working properly.


-F

If the swap.state logs are clean, then the cache is rebuilt in the “foreground” before any requests are served. This will decrease the time required to rebuild the cache, but HTTP requests will not be satisified during this time.


-N

Do not automatically become a background daemon process.


-R

Do not set the SO_REUSEADDR option on sockets.


-V

Enable virtual host support for the httpd-accelerator mode. This is identical to writing httpd_accel_host virtual in the config file.


-X

Enable full debugging while parsing the config file.


-Y

Return ICP_OP_MISS_NOFETCH instead of ICP_OP_MISS while the swap.state file is being read. If your cache has mostly child caches which use ICP, this will allow your cache to rebuild faster.



原文参考:http://www.squid-cache.org/Doc/FAQ/FAQ.html

squid: part of Access Control configuration

星期四, 十二月 1st, 2005

ACL elements


Note: The information here is current for version 2.5.


Squid knows about the following types of ACL elements:


  • src: source (client) IP addresses
  • dst: destination (server) IP addresses
  • myip: the local IP address of a client’s connection
  • srcdomain: source (client) domain name
  • dstdomain: destination (server) domain name
  • srcdom_regex: source (client) regular expression pattern matching
  • dstdom_regex: destination (server) regular expression pattern matching
  • time: time of day, and day of week
  • url_regex: URL regular expression pattern matching
  • urlpath_regex: URL-path regular expression pattern matching, leaves out the protocol and hostname
  • port: destination (server) port number
  • myport: local port number that client connected to
  • proto: transfer protocol (http, ftp, etc)
  • method: HTTP request method (get, post, etc)
  • browser: regular expression pattern matching on the request’s user-agent header
  • ident: string matching on the user’s name
  • ident_regex: regular expression pattern matching on the user’s name
  • src_as: source (client) Autonomous System number
  • dst_as: destination (server) Autonomous System number
  • proxy_auth: user authentication via external processes
  • proxy_auth_regex: user authentication via external processes
  • snmp_community: SNMP community string matching
  • maxconn: a limit on the maximum number of connections from a single client IP address
  • req_mime_type: regular expression pattern matching on the request content-type header
  • arp: Ethernet (MAC) address matching
  • rep_mime_type: regular expression pattern matching on the reply (downloaded content) content-type header. This is only usable in the http_reply_access directive, not http_access.
  • external: lookup via external acl helper defined by external_acl_type




Access Lists


There are a number of different access lists:


  • http_access: Allows HTTP clients (browsers) to access the HTTP port. This is the primary access control list.
  • http_reply_access: Allows HTTP clients (browsers) to receive the reply to their request. This further restricts permissions given by http_access, and is primarily intended to be used together with the rep_mime_type acl type for blocking different content types.
  • icp_access: Allows neighbor caches to query your cache with ICP.
  • miss_access: Allows certain clients to forward cache misses through your cache. This further restricts permissions given by http_access, and is primarily intended to be used for enforcing sibling relations by denying siblings from forwarding cache misses through your cache.
  • no_cache: Defines responses that should not be cached.
  • redirector_access: Controls which requests are sent through the redirector pool.
  • ident_lookup_access: Controls which requests need an Ident lookup.
  • always_direct: Controls which requests should always be forwarded directly to origin servers.
  • never_direct: Controls which requests should never be forwarded directly to origin servers.
  • snmp_access: Controls SNMP client access to the cache.
  • broken_posts: Defines requests for which squid appends an extra CRLF after POST message bodies as required by some broken origin servers.
  • cache_peer_access: Controls which requests can be forwarded to a given neighbor (peer).

resin安装

星期三, 十一月 30th, 2005

blank

[ZT]通用线程: 高级文件系统实现者指南,第 3 部分

星期三, 十一月 30th, 2005

使用虚拟内存(virtual memory,VM)文件系统和绑定安装

Daniel Robbins
总裁/首席执行官, Gentoo Technologies, Inc.
2001 年 9 月


伴随着 Linux 2.4 版本的发行,出现了大量的文件系统可能性,其中包括 ReiserFS、XFS、GFS 和其它文件系统。这些文件系统听起来的确都很酷,但是它们真正能做些什么呢,擅长在哪些方面,以及在 Linux 产品环境下如何才能安全地使用它们呢?Daniel Robbins 通过向您展示如何在 Linux 2.4 的环境下建立这些新的高级文件系统来回答以上的问题。在这个部分,Daniel 简单地介绍了 tmpfs,一个基于 VM 的文件系统,还向您介绍了 2.4 版本的“绑定”安装功能带来的新的可能。

在本系列我以前的文章中,我 介绍了创建日志和使用 ReiserFS 的好处,并 展示了如何安装一个稳固的基于 Linux 2.4 的 ReiserFS 系统。在本文中,我们要谈论几个相对次要的主题。首先,我们会简单地介绍一下 tmpfs,也就是我们知道的虚拟内存(virtual memory,VM)文件系统。Tmpfs 可能是现在 Linux 可以使用的最好的类似于 RAM 磁盘的系统,而且是 2.4 内核的一个新功能。然后,我们将简单地介绍另一个 2.4 内核的新功能,叫做“绑定安装”,它在安装(和重新安装)文件系统的时候带来了很大的灵活性。在下一篇文章中,我们会把重点集中在 devfs 上,之后,我们会花点时间来进一步熟悉新的 ext3 文件系统。


介绍 tmpfs
如果我必须一下子说清楚 tmpfs,我会说 tmpfs 就象虚拟磁盘(ramdisk),但不一样。象虚拟磁盘一样,tmpfs 可以使用您的 RAM,但它也可以使用您的交换分区来存储。而且传统的虚拟磁盘是个块设备,并需要一个

1
mkfs

之类的命令才能真正地使用它,tmpfs 是一个文件系统,而不是块设备;您只是安装它,它就可以使用了。总而言之,这让 tmpfs 成为我有机会遇到的最好的基于 RAM 的文件系统。


tmpfs 和 VM
让我们来看看 tmpfs 更有趣的一些特性吧。正如我前面提到的一样,tmpfs 既可以使用 RAM, 可以使用交换分区。刚开始这看起来可能有点武断,但请记住 tmpfs 也是我们知道的“虚拟内存文件系统”。而且,您可能也知道,Linux 内核的虚拟内存资源同时来源于您的 RAM 和交换分区。内核中的 VM 子系统将这些资源分配到系统中的其它部分,并负责在后台管理这些资源,通常是透明地将 RAM 页移动到交换分区或从交换分区到 RAM 页。


tmpfs 文件系统需要 VM 子系统的页面来存储文件。tmpfs 自己并不知道这些页面是在交换分区还是在 RAM 中;做这种决定是 VM 子系统的工作。tmpfs 文件系统所知道的就是它正在使用某种形式的虚拟内存。


不是块设备
这里是 tmpfs 文件系统另一个有趣的特性。不同于大多数“标准的”文件系统,如 ext3、ext2、XFS、JFS、ReiserFS 和其它一些系统,tmpfs 并不是存在于一个底层块设备上面。因为 tmpfs 是直接建立在 VM 之上的,您用一个简单的 mount 命令就可以创建 tmpfs 文件系统了。





1
# mount tmpfs /mnt/tmpfs -t tmpfs


执行这个命令之后,一个新的 tmpfs 文件系统就安装在 /mnt/tmpfs,随时可以使用。注意,不需运行

1
mkfs.tmpfs

;事实上,那是不可能的,因为没有这样的命令存在。在

1
mount

命令执行之后,文件系统立即就被安装并且可以使用了,类型是

1
tmpfs

。这和 Linux 虚拟磁盘如何使用大相径庭;标准的 Linux 虚拟磁盘是 块设备,所以在使用它们之前必须用您选择的文件系统将其格式化。相反,tmpfs 一个文件系统。所以,您可以简单地安装它就可以使用了。


Tmpfs 的优势


动态文件系统的大小
您可能想知道我们前面在 /mnt/tmpfs 安装的 tmpfs 文件系统有多大。这个问题的答案有点意外,特别是在和基于磁盘的文件系统比较的时候。/mnt/tmpfs 最初会只有很小的空间,但随着文件的复制和创建,tmpfs 文件系统驱动程序会分配更多的 VM,并按照需求动态地增加文件系统的空间。而且,当 /mnt/tmpfs 中的文件被删除时,tmpfs 文件系统驱动程序会动态地减小文件系统并释放 VM 资源,这样做可以将 VM 返回到循环当中以供系统中其它部分按需要使用。因为 VM 是宝贵的资源,所以您一定不希望任何东西浪费超出它实际所需的 VM,tmpfs 的好处之一就在于这些都是自动处理的。 请参阅 参考资料


速度
tmpfs 的另一个主要的好处是它闪电般的速度。因为典型的 tmpfs 文件系统会完全驻留在 RAM 中,读写几乎可以是瞬间的。即使用了一些交换分区,性能仍然是卓越的,当更多空闲的 VM 资源可以使用时,这部分 tmpfs 文件系统会被移动到 RAM 中去。让 VM 子系统自动地移动部分 tmpfs 文件系统到交换分区实际上对性能上是 的,因为这样做可以让 VM 子系统为需要 RAM 的进程释放空间。这一点连同它动态调整大小的能力,比选择使用传统的 RAM 磁盘可以让操作系统有好得多的整体性能和灵活性。


没有持久性
这看起来可能不象是个积极因素,tmpfs 数据在重新启动之后不会保留,因为虚拟内存本质上就是易失的。我想您可能猜到了 tmpfs 被称为“tmpfs”的一个原因,不是吗?然而,这实际上可以是一件好事。它让 tmpfs 成为一个保存您不需保留的数据(如临时文件,可以在 /tmp 中找到,还有 /var 文件系统树的某些部分)的卓越的文件系统。


使用 tmpfs
为了使用 tmpfs,您所需要的就是启用了“Virtual memory file system support(以前是 shm fs)”选项的 2.4 系列内核;这个选项在内核配置选项的“File systems”部分。一旦您有了一个启用了 tmpfs 的内核,您就可以开始安装 tmpfs 文件系统了。其实,在您所有的 2.4 内核中都打开 tmpfs 选项是个好主意,不管您是否计划使用 tmpfs。这是因为您需要内核 tmpfs 支持来使用 POSIX 共享的内存。然而, System V共享的内存不需要内核中有 tmpfs 就 可以工作。注意,您 需要为了让 POSIX 共享的内存工作而安装 tmpfs 文件系统;您只需要在内核中支持 tmpfs 就可以了。POSIX 共享的内存现在使用得不太多,但这种情况可能会随着时间而改变。


避免低 VM 情况
tmpfs 根据需要动态增大或减小的事实让人疑惑:如果您的 tmpfs 文件系统增大到它耗尽了 所有虚拟内存的程度,而您没有剩余的 RAM 或交换分区,这时会发生什么?一般来说,这种情况是有点讨厌。如果是 2.4.4 内核,内核会立即锁定。如果是 2.4.6 内核,VM 子系统已经以很多种方式得到了修正,虽然耗尽 VM 并不是一个美好的经历,事情也不会完全地失败。如果 2.4.6 内核到了无法分配更多 VM 的程度,您显然不愿意不能向 tmpfs 文件系统写任何新数据。另外,可能会发生其他一些事情。首先,系统的其他一些进程会无法分配更多的内存;通常,这意味着系统多半会变得 极度缓慢而且几乎没有响应。这样,超级用户要采取必要的步骤来缓解这种低 VM 的情况就会很困难,或异常地耗时。


另外,内核有一个内建的最终防线系统,用来在没有可用内存的时候释放内存,它会找到占用 VM 资源的进程并终止该进程。不幸的是,这种“终止进程”的解决方案在 tmpfs 的使用增加引起 VM 耗尽的情况下通常会导致不良后果。以下是原因。tmpfs 本身不能(也不应该)被终止,因为它是内核的一部分而非一个用户进程,而且也没有容易的方法可以让内核找出是那个进程占满了 tmpfs 文件系统。所以,内核会错误地攻击它能找到的最大的占用 VM 的进程,通常会是 X 服务器(X server),如果您碰巧在使用它。所以,您的 X 服务器会被终止,而引起低 VM 情况的根本原因(tmpfs)却没有被解决。Ick.


低 VM:解决方案
幸运的是,tmpfs 允许您在安装或重新安装文件系统的时候指定文件系统容量的最大值上限。实际上,从 2.4.6 内核到 2.11g 内核,这些参数只能在 安装时设置,而不是重新安装时,但我们可以期望在不久的将来可以在重新安装时设置这些参数。tmpfs 容量最大值的最佳设置依赖于资源和您特定的 Linux 主机的使用模式;这个想法是要防止一个完全使用资源的 tmpfs 文件系统耗尽所有虚拟内存结果导致我们前面谈到的糟糕的低 VM 情况。寻找好的 tmpfs 上限值的一个好方法是使用

1
top

来监控您系统的交换分区在高峰使用阶段的使用情况。然后,确保指定的 tmpfs 上限稍小于所有这些高峰使用时间内空闲交换分区和空闲 RAM 的总和。


创建有最大容量的 tmpfs 文件系统很容易。要创建一个新的最大 32 MB 的 tmpfs 文件系统,请键入:





1
# mount tmpfs /dev/shm -t tmpfs -o size=32m


这次,我们没有把 tmpfs 文件系统安装在 /mnt/tmpfs,而是创建在 /dev/shm,这正好是 tmpfs 文件系统的“正式”安装点。如果您正好在使用 devfs,您会发现这个目录已经为您创建好了。


还有,如果我们想将文件系统的容量限制在 512 KB 或 1 GB 以内,我们可以分别指定

1
size=512k

1
size=1g

。除了限制容量,我们还可以通过指定

1
nr_inodes=x

参数限制索引节点(文件系统对象)。在使用

1
nr_inodes

时,

1
x

可以是一个简单的整数,后面还可以跟一个

1
k

1
m

1
g

指定千、百万或十亿(!)个索引节点。


而且,如果您想把上面的

1
mount tmpfs

命令的等价功能添加到 /etc/fstab,应该是这样:





1
tmpfs   /dev/shm    tmpfs   size=32m    0   0


在现存的安装点上安装
在以前使用 2.2 的时候,试图在 已经安装了东西的安装点再次安装任何东西都会引发错误。然而,重写后的内核安装代码使多次使用安装点不再成为问题。这里是一个示例的情况:假设我们有一个现存的文件系统安装在 /tmp。然而,我们决定要开始使用 tmpfs 进行 /tmp 的存储。过去,您唯一的选择就是卸载 /tmp 并在其位置重新安装您新的 tmpfs/tmp 文件系统,如下所示:





1
2
3
#  umount /tmp

#  mount tmpfs /tmp -t tmpfs -o size=64m


可是,这种解决方案也许对您不管用。可能有很多正在运行的进程在 /tmp 中有打开的文件;如果是这样,在试图卸载 /tmp 时,您就会遇到如下的错误:





1
umount: /tmp: device is busy


然而,使用最近的 2.4 内核,您可以安装您新的 /tmp 文件系统,而不会遇到“device is busy”错误:





1
# mount tmpfs /tmp -t tmpfs -o size=64m


用一条命令,您新的 tmpfs /tmp 文件系统就被安装在 /tmp,并安装在已经安装的不能再被直接访问的分区 之上。然而,虽然您不能访问原来的 /tmp,任何在原文件系统上还有打开文件的进程都可以继续访问它们。而且,如果您

1
unmount

基于 tmpfs 的 /tmp,原来安装的 /tmp 文件系统会重新出现。实际上,您在相同的安装点上可以安装任意数目的文件系统,安装点就象一个堆栈;卸载当前的文件系统,上一个最近安装的文件系统就会重新出现。


绑定安装


使用绑定安装,我们可以将所有甚至 部分已经安装的文件系统安装到另一个位置,而在两个安装点可以同时访问该文件系统。例如,您可以使用绑定安装来安装您现存的根文件系统到 /home/drobbins/nifty,如下所示:





1
#  mount --bind / /home/drobbins/nifty


现在,如果您观察 /home/drobbins/nifty 的内部,您就会看到您的根文件系统(/home/drobbins/nifty/etc、/home/drobbins/nifty/opt 等)。而且,如果您在根文件系统修改文件,您在 /home/drobbins/nifty 中也可以看到所作的改动。这是因为它们是同一个文件系统;内核只是简单地为我们将该文件系统映射到两个不同的安装点。注意,当您在另一处安装文件系统时,任何安装在绑定安装文件系统 内部的安装点的文件系统都不会随之移动。换句话说,如果您在单独的文件系统上有 /usr,我们前面执行的绑定安装就会让 /home/drobbins/nifty/usr 为空。您会需要附加的绑定安装命令来使您能够浏览位于 /home/drobbins/nifty/usr 的 /usr 的内容:





1
#  mount --bind /usr /home/drobbins/nifty/usr


绑定安装部分文件系统
绑定安装让更妙的事情成为可能。假设您有一个 tmpfs 文件系统安装在它的传统位置 /dev/shm,您决定要开始在当前位于根文件系统的 /tmp 使用 tmpfs。虽然可以在 /tmp(这是可能的)安装一个新的 tmpfs 文件系统,您也可以决定让新的 /tmp 共享当前安装的 /dev/shm 文件系统。然而,虽然您可以在 /tmp 绑定安装 /dev/shm 就完成了,但您的 /dev/shm 还包含一些您不想在 /tmp 出现的目录。所以,您怎么做呢?这样如何:





1
2
3
4
5
6
7
8
9
# mkdir /dev/shm/tmp



# chmod 1777 /dev/shm/tmp



# mount --bind /dev/shm/tmp /tmp


在这个示例中,我们首先创建了一个 /dev/shm/tmp 目录,然后给它

1
1777

权限,对 /tmp 适当的许可。既然我们的目录已经准备好了,我们可以安装,也只能安装 /dev/shm/tmp 到 /tmp。所以,虽然 /tmp/foo 会映射到 /dev/shm/tmp/foo,但您没有办法从 /tmp 访问 /dev/shm/bar 文件。


正如您所见,绑定安装非常强大,让您可以轻易地修改文件系统设计,丝毫不必忙乱。下一篇文章,我们会谈到 devfs,至于现在,您也许会想看看下面的参考资料。


参考资料







关于作者
Daniel Robbins 是 Gentoo Technologies,Inc. 的总裁/首席执行官,住在新墨西哥州的 Albuquerque,他是 Gentoo Linux(一种 PC 机上的高级 Linux)和 Portage系统(Linux 的下一代移植系统)的创建者。他还是 Macmillan 的书籍 Caldera OpenLinux UnleashedSuSE Linux UnleashedSamba Unleashed的特约作者。Daniel 从他二年级时接触到 Logo 编程语言和 Pac Man 游戏的潜在危险魔力后就被这股热流卷进了计算机中。这或许可以解释他为什么曾经是 SONY 电子出版/游戏公司的首席图形设计师了。Daniel 喜欢花时间和他的妻子 Mary 还有他刚出生的宝贝女儿 Hadassah 在一起。您可以通过 drobbins@gentoo.org联系他。


原文:http://www-128.ibm.com/developerworks/cn/linux/filesystem/l-fs3/index.html

JVM Heap Space问题

星期二, 十月 25th, 2005

Java Heap Size Options


You achieve best performance by individually tuning each of your applications. Configuring the JVM heap size options listed in Table 2-2 increases performance for most applications.


The options listed in Table 2-2 may differ depending on your architecture and operating system. See your vendor’s documentation for platform-specific JVM tuning options.




Table 2-2 Java Heap Size Options





























Task


Option


Description


Setting the New generation heap size


-XX:NewSize


Use this option to set the New generation Java heap size. Set this value to a multiple of 1024 that is greater than 1MB. As a general rule, set -XX:NewSize to be one-fourth the size of the maximum heap size. Increase the value of this option for larger numbers of short-lived objects.


Be sure to increase the New generation as you increase the number of processors. Memory allocation can be parallel, but garbage collection is not parallel.


Setting the maximum New generation heap size


-XX:MaxNewSize


Use this option to set the maximum New generation Java heap size. Set this value to a multiple of 1024 that is greater than 1MB.


Setting New heap size ratios


-XX:SurvivorRatio


The New generation area is divided into three sub-areas: Eden, and two survivor spaces that are equal in size.


Use the -XX:SurvivorRatio=X option to configure the ratio of the Eden/survivor space size. Try setting this value to 8 and then monitor your garbage collection.


Setting minimum heap size


-Xms


Use this option to set the minimum size of the memory allocation pool. Set this value to a multiple of 1024 that is greater than 1MB. As a general rule, set minimum heap size (-Xms) equal to the maximum heap size (-Xmx).


Setting maximum heap size


-Xmx


Use this option to set the maximum Java heap size. Set this value to a multiple of 1024 that is greater than 1MB.



 

MYSQL REPLICATION 简易配置过程

星期一, 十月 24th, 2005

2台mysql server:
192.168.0.11 (master)
192.168.0.12 (slave)


如果要在master-slave之间复制bbs库,首先


在master上创建replication用户(赋予‘复制’权限):
mysql>GRANT REPLICATION SLAVE ON *.*
TO ‘repl’@'%’ IDENTIFIED BY ‘slavepass’;


mysql>GRANT FILE ON *.* TO ‘repl’@'%’ IDENTIFIED BY ‘slavepass’;


锁定只能操作读权限
mysql>FLUSH TABLES WITH READ LOCK;


在master上创建bbs库的快照(snapshot)
tar -cvf /tmp/bbs.tar ./bbs


在slave上还原快照:
tar -xvf /tmp/bbs.tar


mysql> UNLOCK TABLES;


修改slave上/etc/my.cnf
[mysqld]
master-host=192.168.0.11
master-user=repl
master-password=slavepass
master-port=3306
server-id=2
master-connect-retry=60
replicate-do-db=bbs
log-slave-updates


master服务器修改my.cnf文件,一般路径在/etc/my.cnf,添加如下内容:
[mysqld]
log-bin
server-id=1  #分配一个id
sql-bin-update-same 
binlog-do-db=bbs #要同步的库名


master
mysql > SHOW MASTER STATUS;


slave
mysql > SHOW SLAVE STATUS;

MySQL安装

星期四, 八月 18th, 2005

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db –user=mysql
shell> chown -R root  .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe –user=mysql &


创建用户
CREATE USER user [IDENTIFIED BY [PASSWORD] ‘password’]
    [, user [IDENTIFIED BY [PASSWORD] ‘password’]] …


修改密码
SET PASSWORD FOR ‘USER’@'HOST’=OLD_PASSWORD(‘XXX’);

挤字

星期二, 十一月 2nd, 2004

  这几天上班时忙里偷闲的时候都在在这里翻以前写过的东西,原来已经是这么长的时间。秋天,好像是里面提到最多的季节,也许秋天是比较容易叫人产生那些无聊情绪的激素,也许需要冬天终结我的胡思乱想。


  统统看完一遍,发现自己竟然没有什么改变,那时困住我的问题依旧是现在的问题,但这些时间里又发生了那么多事,甚至一直在为爱情呻吟的带鱼结婚了,好像永远不可能毕业的老鸡也终于工作了。我想我还真是个耐的住寂寞的人,或是一直昏昏沉沉不知道自己在做什么。时间没有凝固,是我凝固了。


  第101次戒烟终于以越抽越多光荣告一段落,我是否真的有下决心干过什么事,明知不可为还要做可能是我做人最不明智的地方,不过我的信念不就是这样么,想到什么就做什么,不计后果,但有些事情却总也做不到,有些糊涂了,我还没体会到自己浪费生命理论的快感。还是有些事不敢做也不能做,我这言行不一的混帐。


  最近忙的一塌糊涂,托老爸带回来的几本书也一直没时间看,公司的事自己的事别人的事,每天只睡4、5个小时是常事。我是个不会拒绝别人的人,何况是无法拒绝的事,但稀里糊涂答应了之后又一直拖拖拉拉,直到有人对我发飙。我的臭毛病啊,默数十下,再恢复清醒什么也没改变。我已经不再想下什么决心了,可不自觉的想到这是否也是个决心,我呆的地方是个龙卷风的中心,闭上眼一切平静,睁开眼混乱不堪。


  带鱼结婚那天竟然因为张艺谋这废柴导演和麦道骂起来,不知道怎么就说到了工作,我是个不讲理的人,可怜的麦道一定当天郁闷了一晚上,后来MSN上道了个歉,SB竟然说我是SB,说我俗,我只不过不希望看着这哥几个都渐渐失去青年的血性,我实在怕他们变成了面对现实的中年人,不要跟我说什么手段,什么实效,如果说这就是愤青,那我情愿这么不知好歹一辈子。对于工作,干了大半年,不管公司怎么操蛋,我还是想看个结果,任何事情都有挫折我想,毕竟对手是浩方,我还不想还什么都没看到的时候就随便说离开。


  早上,会议室地上的睡袋中爬起来的我发现手背上多了一道细细的伤痕,也许是在梦里又发生了什么战斗,梦中似乎总发生追杀争斗,记不清记不清,醒来忘了梦,梦里忘了现实,2004年发生了什么,虽然没什么文字的记载,但还是有值得记住的和应该忘记的。

指针表示法

星期五, 九月 17th, 2004

char * — 非常量数据的非常量指针


const char * — 常量数据的非常量指针


char * const — 非常量数据的常量指针


const char * const — 常量数据的常量指针


const char * v[] — 指针数组,指针指向数据为常量


bool (*)(int, int) — 函数指针,bool(* compare)(int i, int j),

地铁站台上的徘徊与等待

星期四, 九月 9th, 2004

    公司搬去了城市的另一端,上班的路途也随之变的遥远,以前可以9点上班8点40起床的日子不再有了,换成的是每天7点起床,换几次车挤一身臭汗跌跌撞撞爬上五层的办公楼。人生如果每天有3个小时花在路途上,而且没有风景和新鲜空气,只有污浊的上班族身上混合的气味和喧扰嘈杂,我觉得真是一种浪费和折磨。时间,奇怪的东西,别人浪费你的时间的时候你却可以大声喊这是变向谋杀,自己浪费等同于自杀的时候却浑然不觉。我在说虾米……


    地铁,安全快捷的交通方式,而且价格尚可接受,更可以让冷漠的都市人零距离亲密接触,随时可以嗅到对方洒了香水还是风油精,或是几天没洗过澡。但,从没想过有一天自己会每天坐地铁上下班的生活,可这次,没办法,实在太他妈远了,没有别的选择,其实这个距离上大学的时候我可以每天骑车来回,但今不如昔,不是没有那份体力而是没有了那种单纯的心情。


    有人形容人生如同开往远方的火车载满了希望和欢乐,不知道这个人坐没坐过,或者说站没站过北京的地铁,反正我很少坐,现在乘地铁的唯一乐趣就在于站在车厢中,不扶任何东西随着车厢的颠簸保持身体的平衡纹丝不动,跑题了,那么这个人他也许会把希望的火车改成绝望的地铁,每天早上,我很绝望,看到地铁里人头攒动,绝望加倍,挤进还差一人缝的车厢,我让还没上车的人绝望,回家的时候,我已经开始为第二天绝望。每天站在站台前,总想起大暴走里的情节,几个小孩在火车进站的时候跳入地铁轨道,拼命的跑,直到火车停住靠站,这种事可能never happened,因为对面的墙上写着小心轨道触电。偶尔有一两次可以在地铁里看到那个流浪歌手,吉他弹的很大声音,虽然只是把木吉他,可能是他利用了甬道里的风,否则怎么也想不明白怎么会在嘈杂的人群里还仍然听的那么清晰,弹起大约在冬季的时候我想起了高中毕业那次的元旦联欢会,8年以前了,勾起了回忆,脚步却不会放慢,在繁忙的时候谁又会站在那听他唱完一首完整的歌。


    Why??!! 生活怎会是这样的??


    我不是悲观的人,但也不要再继续酱缸似的生活。