Quantcast
Channel: 容器云计算,Devops,DBA,网络安全。
Viewing all 780 articles
Browse latest View live

CentOS7上安装Zabbix3.0

$
0
0
#!/bin/bash

#
#    0、配置无人值守的安装,定义安装过程中需要用到的一些信息
#
mysql_root_pw=root_pw
mysql_zabbix_pw=zabbix_pw
DBPassword=$mysql_zabbix_pw
CacheSize=256M
ZBX_SERVER_NAME=My-Zabbix-Server

#
#    1、配置yum源
#

cat /etc/redhat-release |grep -i centos |grep '7.[[:digit:]]' >/dev/null

if [[ $? != 0 ]]
then
    echo -e "不支持的操作系统,该脚本只适用于CentOS 7.x  x86_64 操作系统"
    exit 1
fi

rpm -i --force http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/$(curl -s http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/ |grep release  |awk -F '>|<' '{print $3}') &>/dev/null

sed -i 's@repo.zabbix.com@mirrors.aliyun.com/zabbix@' /etc/yum.repos.d/zabbix.repo

#
#    2、使用yum安装Zabbix及必备软件
#

yum install -y httpd mariadb-server php gd php-bcmath php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap OpenIPMI libssh2 fping libcurl libxml2 net-snmp
yum install -y gnutls trousers
yum install -y zabbix-get zabbix-server-mysql zabbix-web-mysql

#
#    3、配置MySQL
#

sed -i '/^symbolic-links=0/a character-set-server=utf8\ninnodb_file_per_table=1' /etc/my.cnf
systemctl enable mariadb.service
systemctl start mariadb.service
mysqladmin -uroot password $mysql_root_pw
mysql -h localhost -uroot -p$mysql_root_pw -e "create database zabbix character set utf8;"
mysql -h localhost -uroot -p$mysql_root_pw -e "grant all privileges on zabbix.* to zabbix@localhost identified by '$mysql_zabbix_pw';"
mysql -h localhost -uroot -p$mysql_root_pw -e "flush privileges;"

zcat /usr/share/doc/zabbix-server-mysql-3.0.*/create.sql.gz | mysql -uroot -p$mysql_root_pw zabbix

#
#    4、配置Zabbix
#

sed -i "/^# DBPassword=/a DBPassword=$DBPassword" /etc/zabbix/zabbix_server.conf
sed -i "/^# CacheSize=8M/a CacheSize=$CacheSize" /etc/zabbix/zabbix_server.conf

sed -i 's/# php_value date.timezone Europe\/Riga/php_value date.timezone Asia\/Shanghai/' /etc/httpd/conf.d/zabbix.conf

cp /usr/share/zabbix/conf/zabbix.conf.php.example /etc/zabbix/web/zabbix.conf.php
sed -i "10c \$DB[\"PASSWORD\"]    = '$DBPassword';" /etc/zabbix/web/zabbix.conf.php
sed -i "16c \$ZBX_SERVER_NAME   = '$ZBX_SERVER_NAME';" /etc/zabbix/web/zabbix.conf.php

systemctl enable zabbix-server
systemctl start zabbix-server
systemctl enable httpd
systemctl start httpd

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-port=10051/tcp
firewall-cmd --permanent --zone=public --add-port=162/udp
firewall-cmd --reload

setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux

CentOS 7 yum install Zabbix 2.4.7

$
0
0

1.

RHEL/CentOS 7

# yum install gcc gcc-c++ make openssl-devel curl wget net-snmp net-snmp-utils net-snmp-libs net-snmp-devel gnutls gnutls-devel libxml2 libxml2-devel

Step 2: Install MariaDB Database and Library

# yum install mariadb-server mariadb-client mariadb-devel [On RHEL/CentOS 7

Set MySQL root Password

# mysql_secure_installation

Step 3: Install Apache Web Server and PHP

# yum install httpd php php-mysql php-gd pgp-cli php-xml php-bcmath php-mbstring mod_ssl openssl		[On RHEL/CentOS 7]

5. Next, you need to tune PHP interpreter and adjust some values in order to run Zabbix Server. So, open Apachephp.ini configuration file for editing by issuing the following command:

# nano /etc/php.ini [On RHEL/CentOS 7]

post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Continent/City  
always_populate_raw_post_data = -1

 

# systemctl restart httpd.service			[On RHEL/CentOS 7]

Step 4: Download, Compile and Install Zabbix Server

rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm

# yum install zabbix-server-mysql zabbix-web-mysql

Example for installing Zabbix agent only.

# yum install zabbix-agent
5
安装好LAMP环境,zabbix_server后,创建数据库,然后从官网(http://www.zabbix.com/download.php)下载数据库文件导入到数据库
导入数据库文件的顺序是:schema.sql  data.sql  images.sql
http://12.34.56.78/zabbix/安装页面时才能连接上数据库
连接成功后,默认登录用户名密码是:admin     zabbix
download
3.0
2.4.X

安装zabbix-agent

centos 6  64bit   #根据不同的系统版本选择相应的安装包,要不然无法安装

2.4
# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
yum install zabbix-agent
安装完成后,找到配置文件:
/etc/zabbix/zabbix_agentd.conf
在里面修改两项:
Server=Zabbix Server IP
ServerActive=Zabbix Server IP

保存退出

然后启动zabbix-agent

systemctl start zabbix-agnet.service

然后到/var/log/zabbix/zabbix-agent.log查看是否有错误,没有就说明启动正常

参考:

http://www.tecmint.com/install-and-configure-zabbix-agents-on-centos-redhat-and-debian/

3.0.              

centos 6 32bit  

http://repo.zabbix.com/zabbix/3.0/rhel/6/i386/zabbix-agent-3.0.0-2.el6.i686.rpm

#rpm -ivh zabbix-agent-3.0.0-2.el6.i686.rpm

安装完成后,启动zabbix-agent

#service zabbix-agent start

修改iptables,开放10050端口,重启iptables即可

Centos 6/7 install varnish v4 代理缓存

$
0
0

varnish对静态多的网站缓存效果好,对动态多的网站会有各种问题,也有可能出现张冠李戴,登陆退不出的问题,动态多的网站不推荐使用

Centos 6.6/7最小化安装

先导入第三方源

wget http://www.atomicorp.com/installers/atomic #下载,首先使用默认yum源安装wget命令 yum install wget

sh ./atomic #安装

yum clean all #清除当前yum缓存

yum makecache #缓存yum源中的软件包信息

yum repolist #列出yum源中可用的软件包

yum check-update  #更新yum软件包

Install Varnish

yum install varnish

Enable Varnish on Reboot

chkconfig varnish on

Change Apache Listen Port to 8080

vim /etc/httpd/conf/httpd.conf

Listen 80

##change to

Listen 8080

Configure Varnish

vim /etc/sysconfig/varnish

VARNISH_LISTEN_PORT=6081

##change to

VARNISH_LISTEN_PORT=80

Configure Varnish Backend

vim /etc/varnish/default.vcl

backend default {
  .host = "127.0.0.1";
  .port = "80";
}

##change to

backend default {
  .host = "127.0.0.1";
  .port = "8080";
}

Restart Apache and Varnish to enable changes made to configuration

service httpd start
service varnish start

Make sure Varnish and Apache are listening on the correct ports

netstat -plan | grep 80

Should look like:

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1868/varnishd
tcp        0      0 :::80                       :::*                        LISTEN      1868/varnishd
tcp        0      0 :::8080                     :::*                        LISTEN      1825/httpd
  • You should also be able to verify that Varnish is serving the file:
curl -I http://$IP

HTTP/1.1 200 OK
Server: Apache/2.2.15 (CentOS)
Last-Modified: Tue, 01 Jul 2014 16:33:52 GMT
ETag: "41cf0-5-4fd2457515364"
Content-Type: text/plain; charset=UTF-8
Content-Length: 5
Accept-Ranges: bytes
Date: Tue, 01 Jul 2014 16:36:35 GMT
X-Varnish: 677655568 677655567
Age: 53
Via: 1.1 varnish
Connection: keep-alive

在大部分centos系统,varnish都不能正常启动,一般是因为varnish没有启动脚本,参考下面解决办法

Centos 6.X

Varnish starts if I do this:

bash -x /etc/init.d/varnish start             # 这样是可以启动的

/etc/init.d/varnish start      #这样是不能启动的,还得看下面

[root@6svprx01 ~]# head -1 /etc/init.d/varnish

#! /bin/sh

[root@6svprx01 ~]# rpm -q varnish

varnish-4.0.3-4.el6.art.x86_64

[root@6svprx01 ~]# md5sum /etc/init.d/varnish a69b3b55a8d5da5b9b9c24a62774aa80 /etc/init.d/varnish

[root@6svprx01 ~]# service varnish

Usage: /etc/init.d/varnish {start|stop|status|restart|condrestart|try-restart|reload|force-reload}

[root@6svprx01 ~]# service varnish status

varnishd (pid 6188) is running…

Centos 7

[root@CentOS7 ~]# varnishd -f /etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080

不出错,就已经运行了

[root@CentOS7 ~]# curl -I http://127.0.0.1
HTTP/1.1 403 Forbidden
Date: Tue, 04 Aug 2015 07:47:10 GMT
Server: Apache/2.4.6 (CentOS)
Last-Modified: Thu, 16 Oct 2014 13:20:58 GMT
ETag: “1321-5058a1e728280”
Accept-Ranges: bytes
Content-Length: 4897
Content-Type: text/html; charset=UTF-8
X-Varnish: 98322
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive

当通过访问varnish 80端口和httpd 8080端口得到的页面一样时,说明varnish运行正常

 

参考官方文档:

http://wiki.mikejung.biz/Varnish#Install_Varnish_4.0.2_On_CentOS_6.5

rsync + inotify-tools实时文件同步备份/推荐中小网站采用

$
0
0

现实中,服务器可能会因为各种原因而crash掉,从而造成数据丢失或者服务的暂时不可用。为了提高服务的可用性以及数据的安全性,就需要对数据进行备份,以便数据恢复或者服务的动态切换(将访问请求动态重定向到备份服务器)。

常见的备份方法是定时的rsync任务或者远程拷贝。但这种方式,如果定时的间隔较大,那么服务器宕掉后,还是会丢失部分数据,动态切换的服务也不是宕机前的最新状态。为了支持实时数据同步,Linux 2.6.13 内核中新引入文件系统变化通知机制inotify,一旦对文件系统有改动,就会触发相关事件任务。通过结合rsync,inotify能够很好地完成实时同步任务。

主服务器:1.1.1.1 备份服务器:0.0.0.0

配置步骤

1. 主服务器,备份服务器上安装rsync:

sudo yum install rsync

2. 主服务器上安装inotify-tools:

sudo yum install inotify-tools

3. 备份服务器上添加配置文件/etc/rsyncd.conf

readonly=no
chroot=no
uid=root
gid=root
hosts allow=1.1.1.1
hosts deny=0.0.0.0/32
max connections=10
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsync.lock
auth users=tongbu
secrets file=/etc/rsync.pass

[website1]
path=/home/yongfeng/apps/website1.org/webroot/upload

[website2]
path=/home/yongfeng/apps/website2.com/webroot/upload

[website3]
path=/home/yongfeng/apps/website3.com/webroot/upload

以及配置文件/etc/rsync.pass

tongbu:somesecurepassword

给密码文件赋权:

sudo chmod 400 /etc/rsync.pass

(注:tongbu就是用户名,与rsyncd.conf中auth users的值一致。somesecurepassword是密码,会在后面主服务器上的配置密码文件用到)

4. 在备份服务器上创建需要的目录:

sudo mkdir -p /home/yongfeng/apps/website1.org/webroot/upload
sudo mkdir -p /home/yongfeng/apps/website2.com/webroot/upload
sudo mkdir -p /home/yongfeng/apps/website3.com/webroot/upload

5. 在主服务器上添加配置文件/etc/rsync-client.pass:

somesecurepassword

赋权限:

chmod 600 /etc/rsync-client.pass

6. 在主服务器上添加要执行的脚本/home/autoscript/rsyncInotify.sh:

#!/bin/sh
src[0]='/var/www/apps/website1.org/webroot/upload,website1'
src[1]='/var/www/apps/website2.com/webroot/upload,website2'
src[2]='/var/www/apps/website3.com/webroot/upload,website3'

for item in ${src[@]}; do
    fromdir=`echo $item | awk -F"," '{print $1}'`
    module=`echo $item | awk -F"," '{print $2}'`

    /usr/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T%w%f' --event modify,delete,move,create,attrib ${fromdir} | while read file event
    do
        echo $event'-'$file
        rsync -avz --delete --password-file=/etc/rsync-client.pass ${fromdir}'/' tongbu@0.0.0.0::${module}
        echo "*******************************"
    done &
done

赋可执行权限:

sudo chmod +x rsyncInotify.sh

7. 在备份服务器的防火墙中添加规则以允许rsync服务请求—可通过直接编辑文件/etc/sysconfig/iptables,在文件中添加一行内容:

-A INPUT -s 1.1.1.1 -p tcp -m tcp --dport 873 -j ACCEPT

8. 备份服务器启动rsync服务:

sudo /usr/bin/rsync --daemon

9. 主服务器启动rsync+inotify服务:

sudo /home/autoscript/tongbu/rsyncInotify.sh

10. 在备份服务器上将rsync服务设置为开机自启动服务—直接编辑配置文件/etc/rc.d/rc.local,添加一行内容:

/usr/bin/rsync --daemon

11. 在主服务器上将rsyncInotify.sh设置为开始自启动—直接编辑配置文件/etc/rc.d/rc.local,添加一行内容:

/home/autoscript/tongbu/rsyncInotify.sh >> /home/autoscript/tongbu/tongbu.log

存在的问题

1.由于rsync命令并没有提供start, stop或者restart等选项,所以想关闭rsync服务,可直接使用sudo pkill rsync杀死rsync服务进程(额,这样是不是过分了点?但我想到的最简便的方法就是这个了)

2.同样rsyncInotify.sh也存在这样的问题,即使使用sudo pkill rsyncInotify.sh杀死了进程还不够,因为rsyncInotify.sh脚本中调用了inotifywait命令,所以还得sudo pkill inotifywait,否则可能会因为inotifywait进程开得太多,而无法正常运行rsyncInotify.sh。

参考文献

1.rsync+inotify实现目录实时同步

2.inotify-rsync实时同步脚本

3.rsync常见错误

 

参考:

http://showerlee.blog.51cto.com/2047005/1216455

http://davidbj.blog.51cto.com/4159484/1181388

centos 7 x64 Rsync+sersync数据实时同步

$
0
0

Rsync+sersync

环境:

centos 7 or centos 7.1  x64

前言:

一、为什么要用Rsync+sersync架构?

1、sersync是基于Inotify开发的,类似于Inotify-tools的工具

2、sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的这个文件或者这个目录。

二、Rsync+Inotify-tools与Rsync+sersync这两种架构有什么区别?

1、Rsync+Inotify-tools

(1):Inotify-tools只能记录下被监听的目录发生了变化(包括增加、删除、修改),并没有把具体是哪个文件或者哪个目录发生了变化记录下来;

(2):rsync在同步的时候,并不知道具体是哪个文件或者哪个目录发生了变化,每次都是对整个目录进行同步,当数据量很大时,整个目录同步非常耗时(rsync要对整个目录遍历查找对比文件),因此,效率很低。

2、Rsync+sersync

(1):sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或某一个目录的名字;

(2):rsync在同步的时候,只同步发生变化的这个文件或者这个目录(每次发生变化的数据相对整个同步目录数据来说是很小的,rsync在遍历查找比对文件时,速度很快),因此,效率很高。

操作系统:CentOS 7.x x64

源服务器:192.168.0.32       #推送端

目标服务器:192.168.0.44    #数据接收端

目的:把源服务器上/home/jony目录实时同步到目标服务器的/home/jony下

具体操作:

第一部分:在务器192.168.0.44上操作                 #目标服务器上

1、关闭SELINUX

vi /etc/selinux/config #编辑防火墙配置文件

#SELINUX=enforcing #注释掉

#SELINUXTYPE=targeted #注释掉

SELINUX=disabled #增加

:wq! #保存,退出

setenforce 0 #立即生效

2、开启防火墙tcp 873端口(Rsync默认端口)

vi /etc/sysconfig/iptables #编辑防火墙配置文件

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 873 -j ACCEPT

:wq! #保存退出

systemcl restart iptables.service

3、安装Rsync服务端软件

yum install rsync #安装

systemctl enable rsyncd.service                 #开机启动

systemctl start rsyncd.service

4、创建vi /etc/rsyncd.conf

#日志文件位置,启动rsync后自动产生这个文件,无需提前创建
log file = /var/log/rsyncd.log
#pid文件的存放位置
pidfile = /var/run/rsyncd.pid
#支持max connections参数的锁文件
lock file = /var/run/rsync.lock
#用户认证配置文件,里面保存用户名称和密码,后面会创建这个文件
secrets file = /etc/rsync.pass
#rsync启动时欢迎信息页面文件位置(文件内容自定义
motd file = /etc/rsyncd.Motd
#
#自定义名称
[rsync_file]
#rsync服务端数据目录路径
path = /home/jony/
#
##模块名称与[rsync_file]自定义名称相同
comment = rsync_file
#设置rsync运行权限为root
uid = root
#设置rsync运行权限为root
gid = root
#默认端口
port=873
#默认为true,修改为no,增加对目录文件软连接的备份
use chroot = no
#设置rsync服务端文件为读写权限
read only = no
#不显示rsync服务端资源列表
list = no
#最大连接数
max connections = 200
#设置超时时间
timeout = 600
#执行数据同步的用户名,可以设置多个,用英文状态下逗号隔开
auth users = liujie
#允许进行数据同步的服务器IP地址,可以设置多个,用英文状态下逗号隔开
hosts allow = 192.168.0.32
#禁止数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
#hosts deny = 192.168.0.XX

保存,退出

5、创建用户认证文件

vi /etc/rsync.pass #配置文件,添加以下内容

liujie:liujie    #格式,用户名:密码,可以设置多个,每行一个用户名:密码

:wq!  #保存退出

6、设置文件权限

chmod 600 /etc/rsyncd.conf  #设置文件所有者读取、写入权限

chmod 600 /etc/rsync.pass  #设置文件所有者读取、写入权限

7、启动rsync

systemctl restart rsyncd.service

#######################################################

第二部分   在源服务器上操作  推送服务器

一、安装Rsync客户端

1、关闭SELINUX

vi /etc/selinux/config  #编辑防火墙配置文件

#SELINUX=enforcing  #注释掉

#SELINUXTYPE=targeted  #注释掉

SELINUX=disabled  #增加

:wq!  #保存退出

setenforce 0   #立即生效

2、开启防火墙tcp 873端口(Rsync默认端口,做为客户端的Rsync可以不用开启873端口)

vi /etc/sysconfig/iptables  #编辑防火墙配置文件

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 873 -j ACCEPT

:wq! #保存退出

systemctl restart iptables.service

3、安装Rsync客户端端软件

yum install  rsync

4.vi /etc/rsyncd.conf

#日志文件位置,启动rsync后自动产生这个文件,无需提前创建
log file = /var/log/rsyncd.log
#pid文件的存放位置
pidfile = /var/run/rsyncd.pid
#支持max connections参数的锁文件
lock file = /var/run/rsync.lock
#用户认证配置文件,里面保存用户名称和密码,后面会创建这个文件
secrets file = /etc/rsync.pass
#rsync启动时欢迎信息页面文件位置(文件内容自定义
motd file = /etc/rsyncd.Motd
#
#自定义名称
[rsync_file]
#rsync服务端数据目录路径
path = /home/jony/
#
##模块名称与[home_www.osyunwei.com]自定义名称相同
comment = rsync_file
#设置rsync运行权限为root
uid = root
#设置rsync运行权限为root
gid = root
#默认端口
port=873
#默认为true,修改为no,增加对目录文件软连接的备份
use chroot = no
#设置rsync服务端文件为读写权限
read only = no
#不显示rsync服务端资源列表
list = no
#最大连接数
max connections = 200
#设置超时时间
timeout = 600
#执行数据同步的用户名,可以设置多个,用英文状态下逗号隔开
auth users = liujie
#允许进行数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
hosts allow = 192.168.0.44
#禁止数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
#hosts deny = 192.168.21.254

5、创建认证密码文件

vi /etc/rsync.pass #编辑文件,添加以下内容

liujie #密码   这里只用输入密码,不需要输入用户名

:wq! #保存退出

chmod 600 /etc/passwd.txt  #设置文件权限,只设置文件所有者具有读取、写入权限即可

6、测试源服务器192.168.0.329到两台目标服务器192.168.0.44间的数据同步

rsync -avH –port=873 –progress –delete  /home/jony/  liujie@192.168.0.44::rsync_file –password-file=/etc/rsync.pass            #注意password前面是两个-

sending incremental file list

sent 847 bytes received 12 bytes 572.67 bytes/sec
total size is 715242 speedup is 832.64                                            #说明同步成功,到源服务器上增加,删除文件然后再运行上面同步,看目标服务器是否有变动

到这里,已经可以实现手工或者定时同步功能了,同步速度取决于文件大小及网络速度

########################################################

第三部分:安装sersync工具,实时触发rsync进行同步

1、查看服务器内核是否支持inotify

ll /proc/sys/fs/inotify   #列出文件目录,出现下面的内容,说明服务器内核支持inotify

[root@localhost ~]# ll /proc/sys/fs/inotify
总用量 0
-rw-r–r– 1 root root 0 9月 18 16:09 max_queued_events
-rw-r–r– 1 root root 0 9月 18 16:09 max_user_instances
-rw-r–r– 1 root root 0 9月 18 16:09 max_user_watches

2、修改inotify默认参数(inotify默认内核参数值太小)

查看系统默认参数值:

sysctl -a | grep max_queued_events

结果是:fs.inotify.max_queued_events = 16384

sysctl -a | grep max_user_watches

结果是:fs.inotify.max_user_watches = 8192

sysctl -a | grep max_user_instances

结果是:fs.inotify.max_user_instances = 128

修改参数:

sysctl -w fs.inotify.max_queued_events=”99999999″

sysctl -w fs.inotify.max_user_watches=”99999999″

sysctl -w fs.inotify.max_user_instances=”65535″

vi /etc/sysctl.conf #添加以下代码

fs.inotify.max_queued_events=99999999

fs.inotify.max_user_watches=99999999

fs.inotify.max_user_instances=65535

:wq! #保存退出

参数说明:

max_queued_events:

inotify队列最大长度,如果值太小,会出现”** Event Queue Overflow **”错误,导致监控文件不准确

max_user_watches:

要同步的文件包含多少目录,可以用:find /home/www.osyunwei.com -type d | wc -l 统计,必须保证max_user_watches值大于统计结果(这里/home/www.osyunwei.com为同步文件目录)

max_user_instances:

每个用户创建inotify实例最大值

3、安装sersync

sersync下载地址:https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz

上传sersync2.5.4_64bit_binary_stable_final.tar.gz到/usr/local/src目录下

cd /usr/local/src

tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz  #解压

mv GNU-Linux-x86  /usr/local/sersync  #移动目录到/usr/local/sersync

4、配置sersync

cd  /usr/local/sersync #进入sersync安装目录

cp confxml.xml confxml.xml-bak  #备份原文件

vi confxml.xml  #编辑,修改下面的代码

<?xml version=”1.0″ encoding=”ISO-8859-1″?>

<head version=”2.5″>

<host hostip=”localhost” port=”8008″></host>

<debug start=”false”/>

<fileSystem xfs=”false”/>

<filter start=”false”>

<exclude expression=”(.*)\.svn”></exclude>

<exclude expression=”(.*)\.gz”></exclude>

<exclude expression=”^info/*”></exclude>

<exclude expression=”^static/*”></exclude>

</filter>

<inotify>

<delete start=”true”/>

<createFolder start=”true”/>

<createFile start=”false”/>

<closeWrite start=”true”/>

<moveFrom start=”true”/>

<moveTo start=”true”/>

<attrib start=”false”/>

<modify start=”false”/>

</inotify>

<sersync>

<localpath watch=”/home/jony”>  #同步源目录

<remote ip=”192.168.0.44″ name=”liujie”/>

<remote ip=”192.168.0.xx” name=”xxxx”/>

<!–<remote ip=”192.168.8.40″ name=”tongbu”/>–>

</localpath>

<rsync>

<commonParams params=”-artuz”/>

<auth start=”true” users=”liujie” passwordfile=”/etc/rsync.passt”/>

<userDefinedPort start=”false” port=”874″/><!– port=874 –>

<timeout start=”false” time=”100″/><!– timeout=100 –>

<ssh start=”false”/>

</rsync>

<failLog path=”/tmp/rsync_fail_log.sh” timeToExecute=”60″/><!–default every 60mins execute once–>

<crontab start=”true” schedule=”600“><!–600mins–>

<crontabfilter start=”false”>

<exclude expression=”*.php”></exclude>

<exclude expression=”info/*”></exclude>

</crontabfilter>

</crontab>

<plugin start=”false” name=”command”/>

</sersync>

<plugin name=”command”>

<param prefix=”/bin/sh” suffix=”” ignoreError=”true”/>  <!–prefix /opt/tongbu/mmm.sh suffix–>

<filter start=”false”>

<include expression=”(.*)\.php”/>

<include expression=”(.*)\.sh”/>

</filter>

</plugin>

<plugin name=”socket”>

<localpath watch=”/opt/tongbu”>

<deshost ip=”192.168.138.20″ port=”8009″/>

</localpath>

</plugin>

<plugin name=”refreshCDN”>

<localpath watch=”/data0/htdocs/cms.xoyo.com/site/”>

<cdninfo domainname=”ccms.chinacache.com” port=”80″ username=”xxxx” passwd=”xxxx”/>

<sendurl base=”http://pic.xoyo.com/cms”/>

<regexurl regex=”false” match=”cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images”/>

</localpath>

</plugin>

</head>

:wq!  #保存退出

参数说明:

localpath watch=”/home/jony”:#源服务器同步目录

192.168.0.32,192.168.0.xx:#目标服务器IP地址

name=”rsync_file”: #目标服务器rsync同步目录模块名称

users=”liujie”: #目标服务器rsync同步用户名

passwordfile=”/etc/rsync.pass”: #目标服务器rsync同步用户的密码在源服务器的存放路径

remote ip=”192.168.0.44″:  #目标服务器ip,每行一个

remote ip=”192.168.0.xx”:  #目标服务器ip,每行一个

failLog path=”/tmp/rsync_fail_log.sh”  #脚本运行失败日志记录

start=”true”  #设置为true,每隔600分钟执行一次全盘同步

5、设置sersync监控开机自动执行

vi /etc/rc.d/rc.local  #编辑,在最后添加一行

/usr/local/sersync/sersync2 -d -r -o  /usr/local/sersync/confxml.xml  #设置开机自动运行脚本

:wq!  #保存退出

6、添加脚本监控sersync是否正常运行

vi  /home/crontab/check_sersync.sh  #编辑,添加以下代码

#!/bin/sh

sersync=”/usr/local/sersync/sersync2″

confxml=”/usr/local/sersync/confxml.xml”

status=$(ps aux |grep ‘sersync2’|grep -v ‘grep’|wc -l)

if [ $status -eq 0 ];

then

$sersync -d -r -o $confxml &

else

exit 0;

fi

:wq!  #保存退出

chmod +x /home/crontab/check_sersync.sh #添加脚本执行权限

vi /etc/crontab #编辑,在最后添加下面一行

*/5 * * * * root /home/crontab/check_sersync.sh > /dev/null 2>&1  #每隔5分钟执行一次脚本

service crond reload  #重新加载服务

7、测试sersync实时触发rsync同步脚本是否正常运行

在源服务器192.168.21.129上创建文件inotify_rsync_ceshi

mkdir /home/www.osyunwei.com/inotify_rsync_ceshi

重新启动源服务器:192.168.21.129

等系统启动之后,查看两台目标服务器192.168.21.127,192.168.21.128的/home/www.osyunwei.com下是否有inotify_rsync_ceshi文件夹

然后再在源服务器192.168.21.129创建文件夹inotify_rsync_ceshi_new

mkdir /home/www.osyunwei.com/inotify_rsync_ceshi_new

继续查看两台目标服务器192.168.21.127,192.168.21.128的/home/www.osyunwei.com下是否有inotify_rsync_ceshi_new文件夹

如果以上测试都通过,说明inotify实时触发rsync同步脚本运行正常。

至此,Linux下Rsync+sersync实现数据实时同步完成。

扩展阅读:

sersync开发者网站:http://blog.johntechinfo.com/sersyncguild

rsync参数

-v, –verbose 详细模式输出

-q, –quiet 精简输出模式

-c, –checksum 打开校验开关,强制对文件传输进行校验

-a, –archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD

-r, –recursive 对子目录以递归模式处理

-R, –relative 使用相对路径信息

-b, –backup 创建备份,也就是对于目的已经存在有同样的文件名时,将老的文件重新命名为~filename。可以使用–suffix选项来指定不同的备份文件前缀。

–backup-dir 将备份文件(如~filename)存放在在目录下。

-suffix=SUFFIX 定义备份文件前缀

-u, –update 仅仅进行更新,也就是跳过所有已经存在于DST,并且文件时间晚于要备份的文件。(不覆盖更新的文件)

-l, –links 保留软链结

-L, –copy-links 想对待常规文件一样处理软链结

–copy-unsafe-links 仅仅拷贝指向SRC路径目录树以外的链结

–safe-links 忽略指向SRC路径目录树以外的链结

-H, –hard-links 保留硬链结

-p, –perms 保持文件权限

-o, –owner 保持文件属主信息

-g, –group 保持文件属组信息

-D, –devices 保持设备文件信息

-t, –times 保持文件时间信息

-S, –sparse 对稀疏文件进行特殊处理以节省DST的空间

-n, –dry-run现实哪些文件将被传输

-W, –whole-file 拷贝文件,不进行增量检测

-x, –one-file-system 不要跨越文件系统边界

-B, –block-size=SIZE 检验算法使用的块尺寸,默认是700字节

-e, –rsh=COMMAND 指定使用rsh、ssh方式进行数据同步

–rsync-path=PATH 指定远程服务器上的rsync命令所在路径信息

-C, –cvs-exclude 使用和CVS一样的方法自动忽略文件,用来排除那些不希望传输的文件

–existing 仅仅更新那些已经存在于DST的文件,而不备份那些新创建的文件

–delete 删除那些DST中SRC没有的文件

–delete-excluded 同样删除接收端那些被该选项指定排除的文件

–delete-after 传输结束以后再删除

–ignore-errors 及时出现IO错误也进行删除

–max-delete=NUM 最多删除NUM个文件

–partial 保留那些因故没有完全传输的文件,以是加快随后的再次传输

–force 强制删除目录,即使不为空

–numeric-ids 不将数字的用户和组ID匹配为用户名和组名

–timeout=TIME IP超时时间,单位为秒

-I, –ignore-times 不跳过那些有同样的时间和长度的文件

–size-only 当决定是否要备份文件时,仅仅察看文件大小而不考虑文件时间

–modify-window=NUM 决定文件是否时间相同时使用的时间戳窗口,默认为0

-T –temp-dir=DIR 在DIR中创建临时文件

–compare-dest=DIR 同样比较DIR中的文件来决定是否需要备份

-P 等同于 –partial

–progress 显示备份过程

-z, –compress 对备份的文件在传输时进行压缩处理

–exclude=PATTERN 指定排除不需要传输的文件模式

–include=PATTERN 指定不排除而需要传输的文件模式

–exclude-from=FILE 排除FILE中指定模式的文件

–include-from=FILE 不排除FILE指定模式匹配的文件

–version 打印版本信息

–address 绑定到特定的地址

–config=FILE 指定其他的配置文件,不使用默认的rsyncd.conf文件

–port=PORT 指定其他的rsync服务端口

–blocking-io 对远程shell使用阻塞IO

-stats 给出某些文件的传输状态

–progress 在传输时现实传输过程

–log-format=formAT 指定日志文件格式

–password-file=FILE 从FILE中得到密码

–bwlimit=KBPS 限制I/O带宽,KBytes per second

-h, –help 显示帮助信息

redhat6.5/RHEL6 配置使用centos的yum源

$
0
0
 redhat6.5/RHEL6 配置使用centos的yum源 
 

新安装了redhat6.5.安装后,登录系统,使用yum update 更新系统。提示:

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

无法更新。

redhat 默认自带的 yum 源需要注册,才能更新。我们想不花钱也可以更新,需要替换掉redhat的yum源。

1.检查是否安装yum包

查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:

[root@localhost ~]# rpm -qa |grep yum

yum-metadata-parser-1.0-8.fc6

yum-3.0.1-5.el5

yum-rhn-plugin-0.4.3-1.el5

yum-updatesd-3.0.1-5.el5

2 删除redhat自带的yum包

卸载上面显示的所有yum包:

[root@localhost ~]# rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包)

再用

[root@localhost ~]# rpm -qa |grep yum

[root@localhost ~]# 

查看,无信息显示表示已经卸载完成。

3.下载新的yum包。使用Centos6.5的yum包

1
2
3
# wget http://mirrors.163.com/centos/6.5/os/i386/Packages/yum-metadata-parser-1.1.2-16.el6.i686.rpm
# wget http://mirrors.163.com/centos/6.5/os/i386/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
# wget http://mirrors.163.com/centos/6.5/os/i386/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm


安装yum软件包

注意:单个的安装包可能会依赖其它包(例如yum和yum-fastestmirror会相互依赖),所以我们可以把所有这些包放在一起,用一行命令将它们同时安装即可:

1
# rpm -ivh yum-metadata-parser-1.1.2-16.el6.i686.rpm yum-3.2.29-40.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm

4.更换yum源。使用163的源

1
2
3
# cd /etc/yum.repos.d/
# wget  http://mirrors.163.com/.help/CentOS6-Base-163.repo
# vi CentOS6-Base-163.repo

编辑文件,把文件里面的$releasever全部替换为版本号,即6.5 最后保存!或者直接把下面的内存拷贝到CentOS6-Base-163.repo文件中即可(已经修改好)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#
 
[base]
name=CentOS-6.5 - Base - 163.com
baseurl=http://mirrors.163.com/centos/6.5/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
 
#released updates 
[updates]
name=CentOS-6.5 - Updates - 163.com
baseurl=http://mirrors.163.com/centos/6.5/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that may be useful
[extras]
name=CentOS-6.5 - Extras - 163.com
baseurl=http://mirrors.163.com/centos/6.5/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-6.5 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/6.5/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-6.5 - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/6.5/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.5&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

5.清除原有缓存

1
# yum clean all

重建缓存,以提高搜索安装软件的速度

1
# yum makecache

6.更新系统

1
# yum update

Centos 6/7 yum安装oracle官方mysql5.6/5.7

$
0
0

Table of Contents     



Steps for a Fresh Installation of MySQL

Note

The following instructions assume that MySQL is not already installed on your system using a third-party-distributed RPM package; if that is not the case, follow the instructions given in Replacing a Native Third-Party Distribution of MySQL.

  1. Adding the MySQL Yum Repository

    First, add the MySQL Yum repository to your system's repository list. Follow these steps:

    1. Go to the download page for MySQL Yum repository at http://dev.mysql.com/downloads/repo/yum/.

    2. Select and download the release package for your platform.

    3. Install the downloaded release package with the following command, replacing platform-and-version-specific-package-name with the name of the downloaded package:

      shell> sudo rpm -Uvh platform-and-version-specific-package-name.rpm
      

      For example, for version n of the package for EL6-based systems, the command is:

      shell> sudo rpm -Uvh mysql57-community-release-el6-n.noarch.rpm  
      

    Note

    Once the release package is installed on your system, any system-wide update by the yum update command (or dnf upgrade for dnf-enabled systems) will automatically upgrade MySQL packages on your system and also replace any native third-party packages, if Yum finds replacements for them in the MySQL Yum repository. See Upgrading MySQL with the MySQL Yum Repository and Replacing a Native Third-Party Distribution of MySQL for details.

  2. Selecting a Release Series

    When using the MySQL Yum repository, the latest GA release of MySQL is selected for installation by default. If this is what you want, you can skip to the next step, Installing MySQL with Yum.

    Within the MySQL Yum repository (http://repo.mysql.com/yum/), different release series of the MySQL Community Server are hosted in different subrepositories. The subrepository for the latest GA series (currently MySQL 5.7) is enabled by default, and the subrepositories for all other series (for example, the MySQL 5.6 series) are disabled by default. Use this command to see all the subrepositories in the MySQL Yum repository, and see which of them are enabled or disabled (for dnf-enabled systems, replace yum in the command with dnf):

    shell> yum repolist all | grep mysql
    

    To install the latest release from the latest GA series, no configuration is needed. To install the latest release from a specific series other than the latest GA series, disable the subrepository for the latest GA series and enable the subrepository for the specific series before running the installation command. You can do that by editing manually the /etc/yum.repos.d/mysql-community.repo file. This is a typical entry for a release series' subrepository in the file:

    [mysql57-community]
    name=MySQL 5.7 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    

    Find the entry for the subrepository you want to configure, and edit the enabled option. Specify enabled=0 to disable a subrepository, or enabled=1 to enable a subrepository. For example, to install MySQl 5.6, make sure you have enabled=0 for the above subrepository entry for MySQL 5.7, and have enabled=1 for the entry for the 5.6 series:

    # Enable to use MySQL 5.6
    [mysql56-community]
    name=MySQL 5.6 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
    enabled=1
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    

    You should only enable subrepository for one release series at any time. When subrepositories for more than one release series are enabled, the latest series will be used by Yum.

    Verify that the correct subrepositories have been enabled and disabled by running the following command and checking its output (for dnf-enabled systems, replace yum in the command with dnf):

    shell> yum repolist enabled | grep mysql
    

  3. Installing MySQL

    Install MySQL by the following command (for dnf-enabled systems, replace yum in the command with dnf):

    shell> sudo yum install mysql-community-server 
    

    This installs the package for the MySQL server, as well as other required packages.

  4. Starting the MySQL Server

    Start the MySQL server with the following command:

    shell> sudo service mysqld start

    You can check the status of the MySQL server with the following command:

    shell> sudo service mysqld status

    For MySQL 5.7 only: At the initial start up of the server, the following happens, given that the data directory of the server is empty:

    • The server is initialized.

    • An SSL certificate and key files are generated in the data directory.

    • The validate_password plugin is installed and enabled.

    • A superuser account 'root'@'localhost' is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:

      shell> sudo grep 'temporary password' /var/log/mysqld.log
      

      Change the root password as soon as possible by logging in with the generated, temporary password and set a custom password for the superuser account:

      shell> mysql -uroot -p 
      
      mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!'; 
      
    Note

    MySQL's validate_password plugin is installed by default. This will require that passwords contain at least one upper case letter, one lower case letter, one digit, and one special character, and that the total password length is at least 8 characters.

  5. Securing the MySQL Installation (for MySQL 5.6 only)

    The program mysql_secure_installation allows you to perform important operations like setting the root password, removing anonymous users, and so on. Always run it to secure your MySQL 5.6 installation:

    shell> mysql_secure_installation

    It is important to remember the root password you set. See mysql_secure_installation — Improve MySQL Installation Security for details.

    Do not run mysql_secure_installation after an installation of MySQL 5.7, as the function of the programe has already been performed by the Yum repository installation.

Note

For EL7-based platforms: See Compatibility Information for EL7-based platforms.

Installing Additional MySQL Products and Components

You can use Yum to install and manage individual components of MySQL. Some of these components are hosted in subrepositories of the MySQL Yum repository. Use the following command to list the packages for all the MySQL components available for your platform from all subrepositories in the MySQL Yum repository (for dnf-enabled systems, replace yum in the command with dnf):

shell> yum --disablerepo=\* --enablerepo='mysql*-community*' list available

Install any packages of your choice with the following command, replacing package-name with name of the package (for dnf-enabled systems, replace yum in the command with dnf):

shell> sudo yum install package-name 

For example, to install MySQL Workbench on Fedora 22:

shell> sudo dnf install mysql-workbench-community

Upgrading MySQL with the MySQL Yum Repository

Note
  • Before performing any update to MySQL, follow carefully the instructions in Upgrading MySQL. Among other instructions discussed there, it is especially important to back up your database before the update.

Use the MySQL Yum repository to perform an in-place update (that is, replacing the old version and then running the new version off the old data files) for your MySQL installation by following these steps (they assume you have installed MySQL with the MySQL Yum repository or with an RPM package directly downloaded from MySQL Developer Zone's MySQL Download page; if that is not the case, following the instructions in Replacing a Native Third-Party Distribution of MySQL instead):

  1. Selecting a Target Series

    By default, the MySQL Yum repository updates MySQL to the latest version in the release series you have chosen during installation (see Selecting a Release Series for details), which means, for example, a 5.6.x installation will NOT be updated to a 5.7.x release automatically. To update to another release series, you need to first disable the subrepository for the series that has been selected (by default, or by yourself) and enable the subrepository for your target series. To do that, see the general instructions given in Selecting a Release Series for editing the subrepository entries in the/etc/yum.repos.d/mysql-community.repo file. For upgrading from MySQL 5.6 to 5.7, perform the reverse of the steps illustrated in Selecting a Release Series, disabling the subrepository for the MySQL 5.6 series and enabling that for the MySQL 5.7 series.

    As a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series. For example, if you are currently running MySQL 5.5 and wish to upgrade to 5.7, upgrade to MySQL 5.6 first before upgrading to 5.7.

    Important

    For important information about upgrading from MySQL 5.6 to 5.7, see Upgrading from MySQL 5.6 to 5.7.

  2. Upgrading MySQL

    Upgrade MySQL and its components by the following command, for platforms that are not dnf-enabled:

    shell> sudo yum update mysql-server

    For dnf-enabled systems:

    shell> sudo dnf --refresh upgrade mysql-server

    Alternatively, you can update MySQL by telling Yum to update everything on your system, which might take considerably more time; for platforms that are not dnf-enabled:

    shell> sudo yum update

    For dnf-enabled systems:

    shell> sudo dnf upgrade

  3. Restarting MySQL

    The MySQL server always restarts after an update by Yum. Once the server restarts, run mysql_upgrade to check and possibly resolve any incompatibilities between the old data and the upgraded software. mysql_upgrade also performs other functions; see mysql_upgrade — Check and Upgrade MySQL Tables for details.

You can also update only a specific component. Use the following command to list all the installed packages for the MySQL components (for dnf-enabled systems, replace yum in the command with dnf):

shell> sudo yum list installed | grep "^mysql"

After identifying the package name of the component of your choice, for platforms that are not dnf-enabled, update the package with the following command, replacing package-name with the name of the package:

shell> sudo yum update package-name

For dnf-enabled systems:

shell> sudo dnf upgrade package-name

Replacing a Native Third-Party Distribution of MySQL

To replace third-party distributions of MySQL that were installed from the supported Linux platforms' native software repositories with the latest GA release (from the MySQL 5.7 series currently) from the MySQL Yum repository, follow these steps:

  1. Backing Up Your Database

    To avoid loss of data, always back up your database before trying to replace your MySQL installation using the MySQL Yum repository. See Backup and Recovery on how to back up your database.

  2. Adding the MySQL Yum Repository

    Add the MySQL Yum repository to your system's repository list by following the instructions given in Adding the MySQL Yum Repository.

  3. Replacing the Native Third-Party Distribution by a Yum Update or a DNFUpgrade

    By design, the MySQL Yum repository will replace your native, third-party MySQL with the latest GA release (from the MySQL 5.7 series currently) from the MySQL Yum repository when you perform a yum update command (or dnf upgrade for dnf-enabled systems) on the system, or a yum update mysql-server (or dnf upgrade mysql-server for dnf-enabled systems).

After updating MySQL using the Yum repository, applications compiled with older versions of the shared client libraries should continue to work. However, if you want to recompile applications and dynamically link them with the updated libraries, see Upgrading the Shared Client Libraries for some special considerations.

Notes

Further Readings

More information on the MySQL Yum repository can be found at the following sections in the MySQL server's reference manual:

Legal Notices

Copyright © 1997, 2016, Oracle and/or its affiliates. All rights reserved.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website at http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.

Oracle customers that have purchased support have access to electronic support through My Oracle Support. For information, visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info or visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=trs if you are hearing impaired.

This documentation is NOT distributed under a GPL license. Use of this documentation is subject to the following terms:

You may create a printed copy of this documentation solely for your own personal use. Conversion to other formats is allowed as long as the actual content is not altered or edited in any way. You shall not publish or distribute this documentation in any form or on any media, except if you distribute the documentation in a manner similar to how Oracle disseminates it (that is, electronically for download on a Web site with the software) or on a CD-ROM or similar medium, provided however that the documentation is disseminated together with the software on the same medium. Any other use, such as any dissemination of printed copies or use of this documentation, in whole or in part, in another publication, requires the prior written consent from an authorized representative of Oracle. Oracle and/or its affiliates reserve any and all rights to this documentation not expressly granted above.

Centos7.2安装weblogic12c

$
0
0
Centos7.2安装weblogic12c

首先安装图形界面.

#: yum groupinstall "GNOME Desktop" "Graphical Administration Tools" -y

删除系统自带java软件包
#:yum remove java-1.8.0-openjdk*
#:yum remove java-1.7.0-openjdk*

安装jdk-8u91软件

#:wget http://download.oracle.com/otn-pub/java/jdk/8u91-b14/jdk-8u91-linux-x64.rpm
#:rpm -ivh jdk-8u91-linux-x64.rpm

检查java版本如下:
# java -version
java version "1.8.0_91"
Java(TM) SE Runtime Environment (build 1.8.0_91-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.91-b14, mixed mode)


添加weblogic用户与组:
#:useradd weblogic
#:usermod weblogic -G weblogic


登陆到weblogic图形界面,准备安装weblogic12c,这里我下载的是通用版fmw_12.1.3.0.0_wls.jar

打开终端执行命令。
#: java -jar fmw_12.1.3.0.0_wls.jar

正常打开安装图形界面,具体安装过程序,这里不再讲了。

安装完成后,开始配置域。

#:cd /home/weblogic/Oracle/Middleware/Oracle_Home/oracle_common/common/bin
#:./config.sh

具体配置过程,这里不讲了。

安装完成后,就可以启动项目了。

#:cd /home/weblogic/Oracle/Middleware/Oracle_Home/user_projects/domains/base_domain
#: ./startWebLogic.sh

启动完成后,就可以打开后台管理端了。







 


Centos6.7 yum配置squid3反向代理内网多web服务器

$
0
0

安装好Centos6.7最新版系统,然后防火墙上作映射80映射口到内网机器

IP: 192.168.1.16    Centos6.7 系统,安装squid代理

IP: 192.168.1.17  安装内网OA与网站

IP: 192.168.1.11  安装网站


服务器都放于内网,所以需要路由器或防火墙作映射。

先保证内网可以正常访问服务器网站,然后配置squid。

安装squid很简单。

#: yum install squid  -y


然后配置相关域名的转发代理,具体配置如下。


[root@localhost ~]# cat /etc/squid/squid.conf
#
# Recommended minimum configuration:
#
acl manager proto cache_object
acl localhost src 127.0.0.1/32 ::1
acl to_localhost dst 127.0.0.0/8 0.0.0.0/32 ::1

# Example rule allowing access from your local networks.
# Adapt to list your (internal) IP networks from where browsing
# should be allowed
acl localnet src 10.0.0.0/8     # RFC1918 possible internal network
acl localnet src 172.16.0.0/12  # RFC1918 possible internal network
acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
acl localnet src fc00::/7       # RFC 4193 local private network range
acl localnet src fe80::/10      # RFC 4291 link-local (directly plugged) machines

acl SSL_ports port 443
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443         # https
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT

#
# Recommended minimum Access Permission configuration:
#
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager

# Deny requests to certain unsafe ports
http_access deny !Safe_ports

# Deny CONNECT to other than secure SSL ports
http_access deny CONNECT !SSL_ports

# We strongly recommend the following be uncommented to protect innocent
# web applications running on the proxy server who think the only
# one who can access services on "localhost" is a local user
#http_access deny to_localhost

#
# INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
#

# Example rule allowing access from your local networks.
# Adapt localnet in the ACL section to list your (internal) IP networks
# from where browsing should be allowed
http_access allow localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access allow all

# Squid normally listens to port 3128
http_port 80 vhost vport

# Uncomment and adjust the following to add a disk cache directory.
#cache_dir ufs /var/spool/squid 1024 16 256
cache_mem 1024 MB

maximum_object_size 10240 KB
maximum_object_size_in_memory 1024 KB

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

cache_peer 192.168.1.17 parent 80 0 no-query originserver name=web1

cache_peer 192.168.1.11 parent 80 0 no-query originserver name=web2

cache_peer_domain web1 www.lyjcart.cn test.lyjcart.cn lyjcart.cn mrlujo.lyjcart.

cache_peer_domain web2 www.greatsunfoods.com

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320








主要是修改了以下内容,当然也添加了内存与其它的参数,这里只是作个简单的能用就行配置。

具体看自己怎么优化与配置。


# And finally deny all other access to this proxy
http_access allow all

# Squid normally listens to port 3128
http_port 80 vhost vport

cache_peer 192.168.1.17 parent 80 0 no-query originserver name=web1

cache_peer 192.168.1.11 parent 80 0 no-query originserver name=web2

cache_peer_domain web1 www.lyjcart.cn test.lyjcart.cn lyjcart.cn mrlujo.lyjcart.

cache_peer_domain web2 www.greatsunfoods.com




如果是squid 采用了round-robin,使用轮询后台服务器,实现,高可用与CDN功能。

可以使用以下方法配置


cache_peer 192.168.1.18 parent 80 0 originserver round-robin weight=1 
cache_peer 192.168.1.19 parent 80 0 originserver round-robin weight=1 
visible_hostname squid.david.dev 
cache_mgr mchina_tang@qq.com


阿里云Linux系统安装routeos/ros

$
0
0
您所在的组无权查看该日志

Centos6 Linux修改网卡MAC/different MAC address than expected, ignoring

$
0
0
Centos6.6 64位服务器修改MAC地址

/etc/sysconfig/network-scripts/ifcfg-eth0
HWADDR=00:24:E8:63:7A:05
修改为:
HWADDR=00:24:E8:63:7A:08

这里重启网络,会有如下提示,实际修改未成功:
[root@ns1 ~]# /etc/init.d/network restart
Shutting down interface eth0:  Device eth0 has MAC address 00:24:E8:63:7A:05, instead of configured address 00:24:E8:63:7A:08. Ignoring.
                                                           [FAILED]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Device eth0 has different MAC address than expected, ignoring.


解决方法:
HWADDR=00:24:E8:63:7A:05
修改为:
MACADDR=00:24:E8:63:7A:08


原因:
HWADDR和MACADDR的不同之处,前者是用来根据HWADDR绑定ethX名称的,后者才是真正用来修改MAC地址的

注:32位服务器,
/etc/sysconfig/network-scripts/ifcfg-eth0 中已经是MACADDR,修改对应值后重启网络即可。

Ubuntu14配置apache/mysql/php/phpmyadmin/vsftp/ioncube环境

$
0
0

安装LAMP环境,以下是命令。

apt-get install apache2 libapache2-mod-php5 php5 php5-gd mysql-server php5-mysql phpmyadmin

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl


安装伪静态环境。

#:  a2enmod rewrite

重启web服务器
/etc/init.d/apache2 restart


wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

tar zxvf ioncube_loaders_lin_x86-64.tar.gz

#:vim.tiny /etc/php5/apache2/php.ini

       [ionCube Loader]
             zend_extension = /usr/local/ioncube/ioncube_loader_lin_5.3.so

 

       注意:
                     如果以前装有Zend Guard,为了避免ionCube和Zend Guard发生冲突,
                     需将上面的内容添加到Zend Guard代码之前就可以了。

    4、重启web服务器
/etc/init.d/apache2 restart

配置好后,就可以到phpinfo中检查环境,也可以登陆phpmyadmin 操作数据库mysql.


下面是配置vsftpd,

apt-get install   vsftpd

修改配置文件/etc/pam.d/vsftpd:

vi /etc/pam.d/vsftpd   #注释掉下面一行

#auth   required        pam_shells.so

以上不操作的话,登陆vsftpd  出现 530 500错误。


修改:/etc/vsftpd.conf

#vi /etc/vsftpd.conf

将配置文件中”anonymous_enable=YES “改为 “anonymous_enable=NO”

取消如下配置前的注释符号:

local_enable=YES

write_enable=YES

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd.chroot_list

local_umask=002

这里就是将上传文件配置成775权限

添加vsftp本地账号账号:

#:  vim.tiny /etc/vsftpd.chroot_list

ftpuuser

配置ftp目录权限:

useradd -d /var/www -s /sbin/nologin ftpuser

passwd ftpuser

usermod ftpuser -G www-data -g www-data



#:  chown -R ftpuser:www-data /var/www


最后测试网站与ftp都可以正常使用。


RedHat7.1系统配置pptp client客户端拨号VPN

$
0
0

 RedHat7.1系统配置pptp client客户端拨号VPN


由于 RedHat7.1系统非常古老,所以连系统盘基本上都找不到了。


好在找到了pptp client的安装源码包。


wget http://downloads.sourceforge.net/project/pptpclient/pptp/pptp-1.8.0/pptp-1.8.0.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fpptpclient%2Ffiles%2Fpptp%2Fpptp-1.8.0%2F&ts=1462894082&use_mirror=tenet


从这里下载好软件安装包,查看安装包的install安装说明


Installation Instructions - Brief

    1.  install pppd (with MPPE if you require it),
    2.  if pppd is not in /usr/sbin, edit Makefile, variable PPPD,
    3.  'make'
    4.  'make install'


Installation Instructions - Detailed

    1.  install PPP, and make sure it is working.

        On most distributions, use the package called ppp or pppd.

        If your PPTP server requires MPPE, make sure the pppd program
        has been built with MPPE and MS-CHAP support.  PPP from
        version 2.4.2 onwards has this support.  PPP may require
        kernel support for MPPE, which may require patching your
        kernel.

    2.  verify that the pppd program is in the /usr/sbin/ directory.

        On some distributions, it is in /usr/bin, or somewhere else.
        If it isn't in the default directory, edit the Makefile, and
        change the PPPD variable to point at the pppd program.

        You may even want to run a separate pppd program with MPPE
        support.

    3.  compile

        Type 'make'.  This should generate the 'pptp' executable.

    4.  install binaries

    Type 'make install' to have the program and the manual page
    installed.

 


检查安装说明,来安装软件。

1,先查看pppd,程序是否在/usr/sbin/ 目录下。

检查通过,

如果不在此目录,那就要修改Makefile中的变量位置了。

if pppd is not in /usr/sbin, edit Makefile, variable PPPD,
    3.  'make'
    4.  'make install'

最后执行make 与make install 命令,测试执行正常。


配置pptp客户端:

# pptpsetup --create vpn名称 --server ip地址 --username vpn账号 --password vpn密码 --start

# pptpsetup --create vpn名称 --server ip地址 --username vpn账号 --password vpn密码 --encrypt --start

测试VPN正常分的IP与账号密码


ubuntu配置屏摸屏驱动

$
0
0

Touchscreen

This page is a documentation of my dealings with various touchscreen devices I've encountered. In my experience, most modern devices work out of the box with both 10.04 LTS or 12.04 LTS, but lack the proper calibration or configuration. Some older devices, especially those embedded in laptops such as GD Itronix line of rugged computers, use serial interfaces which lack the configuration to work in Linux. The methods documented here should work with other distros as well.

Global Dynamics Itronix GoBook XR-1

This is a rugged laptop I picked up from ebay for a good price, which the seller wiped with Ubuntu 10.04 due to the expense of Microsoft's Windows relicensing fee. The device has an integrated serial touchscreen, and the manufacturer is notorious for hiding any and all documentation on legacy devices such as this one. With a little trial and error however, it's relatively simple to configure this and similar devices. This method should work for most GD products, including the newer GD8000 which replaced this device. Skip to the section for configuring serial devices for these machines.

Checking for touchscreen connectivity

When encountering a new device, the first order of business is to determine how the touchscreen is connected to your computer. If the touchscreen produces no events out of the box, check to see if it's an USB device or not:

lsusb

USB connection

Check the output for any reference to a touchscreen. If your touchscreen has an USB interface, and it isn't working, then you may need to blacklist the usbtouchscreen driver for it to work:

sudo modprobe -r usbtouchscreen

If your touchscreen begins to produce events, then you can permanently blacklist the usbtouchscreen driver:

echo "blacklist usbtouchscreen" | sudo tee -a /etc/modprobe.d/blacklist.conf

Some touchscreens might already have good or perfect calibrations, otherwise you'll need to continue to the calibration section.

Serial connection

If there is no reference to a touchscreen device in your lsusb output, the connection is most likely through one of your serial ports. The actual IRQ mapping varies between manufacturers. In the case of Itronix devices, the default is /dev/ttyS3. A simple way to check for connections is to check each one for events:

screen /dev/ttyS0

Touch anywhere on your screen to check for any character output. If nothing happens, quit screen by pressing Ctrl+A and then the '\' key to quit. Continue with /dev/ttyS1, etc. until you get a response. Once you've determined the device, we can try a few different drivers. In the case of Itronix (and most other devices using the Touchkit driver), the correct driver is touchit213.

sudo inputattach --touchit213 /dev/ttyS3  

Will work for most touchkit screens. The calibration or one or more axes may be swapped, but if the calibration is approximate then it's probably the correct driver. Press Ctrl+C to try a new mode. inputattach supports any of the following modes, which includes external touchscreens which may attach through a physical serial port:

  --h3600ts        -ipaq     Ipaq h3600 touchscreend
  --elotouch       -elo      ELO touchscreen, 10-byte mode
  --elo4002        -elo6b    ELO touchscreen, 6-byte mode
  --elo271-140     -elo4b    ELO touchscreen, 4-byte mode
  --elo261-280     -elo3b    ELO Touchscreen, 3-byte mode
  --mtouch         -mtouch   MicroTouch (3M) touchscreen
  --touchit213     -t213     Sahara Touch-iT213 Tablet PC
  --touchright     -tr       Touchright serial touchscreen
  --touchwin       -tw       Touchwindow serial touchscreen
  --penmount       -pm       Penmount touchscreen
  --fujitsu        -fjt      Fujitsu serial touchscreen

If your device is built into a laptop, you'll have the best luck with the mtouch, touchright, touchwin, or touchit213 drivers. Likewise, non-Elo external touchscreens will most likely use touchit213. If your device is a tablet with stylus-only input, fujitsu is a popular maker of embedded tablet devices.

To attach the touchscreen at startup, edit your /etc/rc.local to look like the following:

/usr/bin/inputattach --daemon --always -t213 /dev/ttyS3
exit 0

Replace -t213 with your appropriate driver and /dev/ttyS3 with the correct device.

Again, don't worry if the calibration isn't perfect, or if an axis is inverted or reversed - this will be addressed in the calibration section.

Calibration

Thanks to the wonderful work of the freedesktop.org developers, calibration is no longer a black art in Linux. The calibration utility is included in Ubuntu 12.04 and later:

sudo apt-get install xinput-calibrator

And for 10.04, there's a ppa available:

sudo add-apt-repository ppa:tias/xinput-calibrator-ppa
sudo apt-get update && sudo apt-get install xinput-calibrator

Packages and source files are available for other distros here.

The use is pretty straight forward. I had issues getting it to work properly with HAL, however this will work regardless:

xinput_calibrator --output-type xinput

Follow the instructions pressing each target, and the calibration output will be printed to the terminal. The calibration will be set immediately, but will not survive reboots. If you're using GDM, you can put the calibration command in your /etc/gdm/Init/Default. I placed calibration values for my XR-1 in both GDM and as a gnome startup script, since it uses automatic login:

/usr/bin/xinput set-prop "Sahara Touch-iT213 Serial TouchScreen" "Evdev Axis Inversion" 0 1
/usr/bin/xinput set-int-prop "Sahara Touch-iT213 Serial TouchScreen" "Evdev Axis Calibration" 32 27 2027 39 1977

Inverted/reversed axes

If your axes are swapped or reversed with the calibration output from xinput_calibrator (after a reboot or X restart), you may need to invert them explicitly, as I did with the XR-1.

xinput set-prop "Sahara Touch-iT213 Serial TouchScreen" "Evdev Axis Inversion" 0 1

The 0 and 1 in the above command enables axis inversion for the x or y axis (0=normal, 1=invert).

If your x and y axis are swapped, use the "Evdev Axis Swap" 1 verb:

xinput set-prop "Sahara Touch-iT213 Serial TouchScreen" "Evdev Axis Swap" 1

When you're satisfied with the result, you may need to perform calibration again with xinput-calibrator.

Troubleshooting

Different modes and drivers accept different xinput options. To get your touchscreen's device name, use xinput list. Individual driver options can be obtained by using xinput list-props <device name>, where <device name> is either the device name as a string or the id= number.


eGalax Touchscreens in 14.04LTS

After fighting with USB eGalaxy Touchscreens for a week or so the solution turned out to be quite simple. I've documented everything with photos here on Google Drive

Files

You can get the files here on the website of EETI eGalax

http://www.eeti.com.tw/drivers_Linux.html

Unzip the file

Just unzip the file in the current directory

gunzip /home/$USER/Downloads/eGTouch_v2.5.4330.L-x.zip

Here is a quick rundown of the steps

Ensure the Kernel Modules start on boot

Modify the file /etc/modules to add the modules usbtouchscreen and usbhid. These must come after lp and before rtc.

/etc/modules

切换行号显示
   1  # /etc/modules: kernel modules to load at boot time.
   2  #
   3  # This file contains the names of kernel modules that should be loaded
   4  # at boot time, one per line. Lines beginning with "#" are ignored.
   5  
   6  loop
   7  lp
   8  usbtouchscreen
   9  usbhid 
  10  rtc

=====================

Load the Kernel Modules (only the 1st time)

Then load the modules by hand the 1st time (or reboot)

sudo modprobe usbtouchscreen usbhid

Move the Daemon and Calibration Files

Move al the files in the folder /home/user/Downloads/eGalax/eGTouch_v2.5.4330.L-x/eGTouch64/eGTouch64withX to /usr/local/bin/ *Note the following command is one line

sudo rsync -avz /home/$USER/Downloads/eGalax/eGTouch_v2.5.4330.L-x/eGTouch64/eGTouch64withX /usr/local/bin/

Place Upstart Job

place the following Upstart job in /etc/init

/etc/init/egalaxtouch.conf

切换行号显示
   1 #!/bin/bash
   2 
   3 description "Start the egalax touchscreen daemon on boot"
   4 author  "globeone  Damiön la Bagh"
   5 
   6 start on runlevel 2
   7 
   8 exec /usr/local/bin/eGTouchD

=========================

Start the Touchscreen Daemon

Start the touchscreen daemon with the following command

sudo service egalaxtouch start

Calibration

Calibrate the Touchscreen with eGTouchU

sudo /usr/local/bin/eGTouchU

For Dual Screen Configurations:

Follow the onscreen prompts of the config program for dual screen setup choose Left or Right mode!






最后附件中的内容是eGtouch驱动的安装与图形调试




How to install Ioncube Loader PHP on Linux Ubuntu

$
0
0

How to install Ioncube Loader PHP on Linux Ubuntu

Ioncube Loader Extenion allows to run encoded PHP scripts by Ioncube Encoder.

  • Ioncube Loader Extension – extension which starts witch PHP process that can read and run encoded files. The extension is free.
  • Ioncube Encoder – software that allows encode and obfulscate PHP scripts using license key to description.

This tutorial shows how to install Ioncube Loader Extension.

1. Download Ioncube loader extension.

Go to the http://www.ioncube.com/loaders.php url and locate your proper platofrm version.

If you are not sure what platform (x86 or 64-bit, TS or NTS ) you need, just run phpinfo() and read from “System” and “PHP Extension Build”. For example this entry looks like:

System: Linux athlan-VirtualBox 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64

PHP Extension Build: API20121212,NTS

I am using 64-bit platform, NTS (non-thread safe).

So copy proper link and call:

wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Extract the package

tar xvfz ioncube_loaders_lin_x86-64.tar.gz

athlan@athlan-VirtualBox:~/tmp/ioncube$ ls -1
ioncube_loader_lin_4.1.so
ioncube_loader_lin_4.2.so
ioncube_loader_lin_4.3.so
ioncube_loader_lin_4.3_ts.so
ioncube_loader_lin_4.4.so
ioncube_loader_lin_4.4_ts.so
ioncube_loader_lin_5.0.so
ioncube_loader_lin_5.0_ts.so
ioncube_loader_lin_5.1.so
ioncube_loader_lin_5.1_ts.so
ioncube_loader_lin_5.2.so
ioncube_loader_lin_5.2_ts.so
ioncube_loader_lin_5.3.so
ioncube_loader_lin_5.3_ts.so
ioncube_loader_lin_5.4.so
ioncube_loader_lin_5.4_ts.so
ioncube_loader_lin_5.5.so
ioncube_loader_lin_5.5_ts.so
ioncube_loader_lin_5.6.so
ioncube_loader_lin_5.6_ts.so
LICENSE.txt
loader-wizard.php
README.txt
USER-GUIDE.txt

2. Copy extension to PHP extension dir

Locate your extenion dir:

athlan@athlan-VirtualBox:~/tmp/ioncube$ php -i | grep extension_dir
extension_dir => /usr/lib/php5/20121212 => /usr/lib/php5/20121212

Copy here your proper loader, in my case:

cp ./ioncube_loader_lin_5.5.so /usr/lib/php5/20121212

3. Add extension to php.ini file

You must add Ioncube Loader to php.ini file pointing proper file:

zend_extension=ioncube_loader_lin_5.5.so

Make sure that extension is the first loaded extension for PHP, because the error will appear:

PHP Fatal error: Unable to start ionCube Loader module in Unknown on line 0

In my Ubuntu the extensions directory are under: /etc/php5/mods-available directory – one per extension. So define ioncube.ini file. In php+apache2 for ubuntu there are configuratios groupped by environment, one is apache2, so I make symbolic link to include my .ini file:

ln -s .etc/php5/mods-available/ioncube.ini /etc/php5/apache2/conf.d/01-ioncube.ini

I named my file by prefix 01- to make sure that it will be the first included extension.

4. Check configuration

Make file with phpinfo() and check if Ioncube is loaded under “Additional Modules” and “with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.0.11, Copyright (c) 2002-2015, by ionCube Ltd.”:

ioncube-phpinfo

ioncube-phpinfo2

Done!

Known issues:

Apache hangs while start

The apache2 instance did not start within 20 seconds. Please read the log files to discover problems

Probably you have not proper version of your extension included (TS or NTS). Please verify that comparing to your phpinfo() “System” and “PHP Extension Build”.

Invalid extension definition

[Sat Jul 11 15:44:24 2015] [warn-phpd] The ionCube Loader is a Zend-Engine extension and not a module (pid 3038)
[Sat Jul 11 15:44:24 2015] [warn-phpd] Please specify the Loader using ‘zend_extension’ in php.ini (pid 3038)

You have included Ioncube by extension= while zend_extension= should be used.

Ioncube Loader is loaded after another extensions

PHP Fatal error: [ionCube Loader]
The Loader must appear as the first entry in the php.ini file in Unknown on line 0

You have to specify zend_extension directive in php.ini as a first extension loaded. To make sure, just place it as a first line.


MySQL配置读写分离

$
0
0

MySQL配置读写分离

在这里你再也不用担心高手省略了大段代码了,因为我也是新手。

下面开整

先安装lua

Lua 是一个小巧的脚本语言。Lua由标准C编写而成,代码简洁优美,几乎在所有操作系统和平台上都可以编译,运行。
一个完整的Lua解释器不过200k,在目前所有脚本引擎中,Lua的速度是最快的。这一切都决定了Lua是作为嵌入式脚本的最佳选择。

先安装可能的依赖包

  1. [root@bogon ~]# yum -y install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libmcrypt* libtool* flex* pkgconfig*  
  2. libevent* glib* readline-devel  
  3.   
  4.   
  5. [root@bogon ~]# mkdir /opt/install/  
  6.   
  7. [root@bogon ~]# cd /opt/install/  
  8.   
  9. [root@bogon install]# wget http://www.lua.org/ftp/lua-5.1.4.tar.gz  
  10.   
  11. [root@bogon install]# tar zxvf lua-5.2.3.tar.gz  
  12.   
  13. [root@bogon install]# cd lua-5.2.3  
  14.   
  15. [root@bogon install]# make linux  


此时如果出现

lua.c:67:31: fatal error: readline/readline.h: No such file or directory
说明缺少libreadline-dev依赖包

  1. [root@bogon install]# make install  
  2.   
  3. [root@bogon install]# export LUA_CFLAGS="-I/usr/local/include" LUA_LIBS="-L/usr/local/lib -llua -ldl" LDFLAGS="-lm"  


这行代码我也不知道啥作用,好像是的指定环境变量。


下面开始安装mysql-proxy

安装之前先看一下自己机器是否是64位系统
查看centos内核的版本

  1. [root@bogon install]# cat /etc/issue  


查看linux版本
  1. [root@bogon install]# cat /proc/version  
  2. [root@bogon install]# lsb_release -a  


如果以上命令都没有出现64字眼说明是32位系统,这里主要是确定你将要下载的mysql-proxy版本应该是哪个。

下载地址:http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/

  1. [root@bogon install]# cd /opt/install  
  2.   
  3. [root@bogon install]# wget http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/mysql-proxy-0.8.4-linux-rhel5-x86-32bit.tar.gz  
  4.   
  5. [root@bogon install]# tar zxvf  mysql-proxy-0.8.4-linux-rhel5-x86-32bit.tar.gz  
  6.   
  7. [root@bogon install]# mkdir /opt/mysql-proxy/  
  8.   
  9. [root@bogon install]# cp /opt/install/mysql-proxy-0.8.4-linux-rhel5-x86-32bit/* /opt/mysql-proxy/  
  10.   
  11. [root@bogon install]# cd /opt/mysql-proxy/  
  12.   
  13. [root@bogon install]# export PATH=$PATH:/opt/mysql-proxy/bin/  


编辑mysql-proxy配置文件

  1. [root@bogon install]# cp doc/mysql-proxy/rw-splitting.lua  ./  
  2.   
  3. [root@bogon install]# vi rw-splitting.lua  


找到:

  1. if not proxy.global.config.rwsplit then  
  2.         proxy.global.config.rwsplit = {  
  3.                 min_idle_connections = 4,  
  4.                 max_idle_connections = 8,  
  5.   
  6.                 is_debug = false  
  7.         }  
  8. end  


这里的4、8是指定链接数,大家可以在做试验时调整为1。

ok,保存,退出。

  1. [root@bogon install]# mysql-proxy --proxy-read-only-backend-addresses=192.168.23.132:3306 --proxy-backend-addresses=192.168.2.131:3306 --proxy-lua-script=/opt/mysql-proxy/share/rw-splitting.lua&  


这里的192.168.23.131与192.168.23.132是主从数据库。参见http://blog.csdn.net/e421083458/article/details/19574049

以上命令后缀追加&表示为后端任务。

  1. [root@bogon install]# bg  


将正在执行命令隐藏到后端

  1. [root@bogon install]# jobs  


查看正在后端运行的命令

  1. [richard@bogon ~]$ fg 1  


将后端命令显示到前台


打开4040端口防火墙端口,因为mysql-proxy监听端口是4040再也不是3306了。正好做以区分。

  1. [root@bogon install]# /sbin/iptables -I INPUT -p tcp --dport 4040 -j ACCEPT  
  2.   
  3. [root@bogon install]#  /etc/rc.d/init.d/iptables save  
  4.   
  5. [root@bogon install]# service iptables save  


查看监听情况:

  1. [root@bogon install]# netstat -tlp | grep mysql-proxy  
  2.   
  3. tcp        0      0 *:yo-main                   *:*                         LISTEN      13364/mysql-proxy  


yo-main很奇怪吧,对我也奇怪,不管它了,下面我们测试一下功能吧。


刚刚我们提到的192.168.23.131与192.168.23.132两台服务器,131是主,132是从,131是读写,132是只读。myql-proxy的IP是192.168.23.130

创建用于读写分离的数据库连接用户

在131服务器上操作以下命令:

  1. [root@bogon ~]# mysql -uroot  -p123456  
  2.   
  3. mysql> grant all on *.* to 'proxy1'@'192.168.23.130' identified by '123456';  


由于我们设置了131与132的主从复制,所以此时132也执行了以上命令,我们可以确定一下。

在132服务上操作以下命令:

  1. mysql> select user,password,host from mysql.user;  
  2.   
  3. +--------+-------------------------------------------+----------------+  
  4. | user   | password                                  | host           |  
  5. +--------+-------------------------------------------+----------------+  
  6. | root   | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | localhost      |  
  7. | root   |                                           | bogon          |  
  8. | root   |                                           | 127.0.0.1      |  
  9. | proxy1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | 192.168.23.130 |  
  10. +--------+-------------------------------------------+----------------+  
  11. 4 rows in set (0.00 sec)  


没错结果存在。

但是我们要做的试验是测试读写分离,所以要让这两台服务器有误差才行。所以暂停132的从服务:

  1. mysql> slave stop;  


下面我们在131服务器上操作以下命令:

  1. mysql> insert into first_tb values (007,’first’);  
  2. mysql> insert into first_tb values (110,’second’);  


最后再到132上确认一下数据是否有误差,下面试验开始。

在131上打开4个终端,依次敲以下的命令:

  1. [root@bogon ~]# mysql -uproxy1 -p'123456' -h192.168.23.130 -P4040  
  2.   
  3. mysql> select * from first_db.first_tb;  


你会发现结果会有不一样,那证明配置试验成功。也可以多此尝试以上两行代码直到得到结果。

试验结束记得将slave start,方法参照http://blog.csdn.net/e421083458/article/details/19574049

追加内容:设置mysql-proxy服务脚本。

  1. #!/bin/sh  
  2.   
  3. #  
  4. # mysql-proxy This script starts and stops the mysql-proxy daemon  
  5. #  
  6. # chkconfig: - 78 30  
  7. # processname: mysql-proxy  
  8. # description: mysql-proxy is a proxy daemon to mysql  
  9.   
  10. # Source function library.  
  11. . /etc/rc.d/init.d/functions  
  12.   
  13. #PROXY_PATH=/usr/local/bin  
  14. PROXY_PATH=/opt/mysql-proxy/bin  
  15.   
  16. prog="mysql-proxy"  
  17.   
  18. # Source networking configuration.  
  19. . /etc/sysconfig/network  
  20.   
  21. # Check that networking is up.  
  22. [ ${NETWORKING} = "no" ] && exit 0  
  23.   
  24. # Set default mysql-proxy configuration.  
  25. #PROXY_OPTIONS="--daemon"  
  26.   
  27. PROXY_OPTIONS="--proxy-read-only-backend-addresses=192.168.23.132:3306 --proxy-backend-addresses=192.168.23.131:3306 --proxy-lua-script=/opt/mysql-proxy/share/rw-splitting.lua"  
  28.   
  29. PROXY_PID=/opt/mysql-proxy/run/mysql-proxy.pid  
  30.   
  31. # Source mysql-proxy configuration.  
  32. if [ -f /etc/sysconfig/mysql-proxy ]; then  
  33.         . /etc/sysconfig/mysql-proxy  
  34. fi  
  35.   
  36. PATH=$PATH:/usr/bin:/usr/local/bin:$PROXY_PATH  
  37. # By default it's all good  
  38. RETVAL=0  
  39.   
  40. # See how we were called.  
  41. case "$1" in  
  42.   start)  
  43.         # Start daemon.  
  44.         echo -n $"Starting $prog: "  
  45.         $NICELEVEL $PROXY_PATH/mysql-proxy $PROXY_OPTIONS --daemon --pid-file=$PROXY_PID --user=root --log-level=debug --log-file=/opt/mysql-proxy/log/mysql-proxy.log  
  46.         RETVAL=$?  
  47.         echo  
  48.         if [ $RETVAL = 0 ]; then  
  49.                 touch /var/lock/subsys/mysql-proxy]  
  50.                 echo "ok"  
  51.         fi  
  52.        ;;  
  53.   stop)  
  54.         # Stop daemons.  
  55.         echo -n $"Stopping $prog: "  
  56.         killproc $prog  
  57.         RETVAL=$?  
  58.         echo  
  59.         if [ $RETVAL = 0 ]; then  
  60.                 rm -f /var/lock/subsys/mysql-proxy  
  61.                 rm -f $PROXY_PID  
  62.         fi  
  63.        ;;  
  64.   restart)  
  65.         $0 stop  
  66.         sleep 3  
  67.         $0 start  
  68.        ;;  
  69.   condrestart)  
  70.        [ -e /var/lock/subsys/mysql-proxy ] && $0 restart  
  71.       ;;  
  72.   status)  
  73.         status mysql-proxy  
  74.         RETVAL=$?  
  75.        ;;  
  76.   *)  
  77.         echo "Usage: $0 {start|stop|restart|status|condrestart}"  
  78.         RETVAL=1  
  79.        ;;  
  80. esac  
  81. exit $RETVAL  

启动脚本:[root@bogon init.d]# /opt/mysql-proxy/init.d/mysql-proxy start

MySQL、Oracle、MongoDB、Redis数据库监控系统 Lepus

$
0
0

Lepus(天兔) 是数据库企业监控系统,针对互联网企业开发的一款专业、强大的企业数据库监控管理系统,企业通过Lepus可以对数据库的实时健康和各种性能指标进行全方位的监控。目前已经支持MySQL、Oracle、MongoDB、Redis数据库的全面监控. Lepus可以在数据库出现故障或者潜在性能问题时,根据用户设置及时将数据库的异常进行报警通知到数据库管理员进行处理和优化,帮助企业解决数据库性能监控问题,及时发现性能和瓶颈,避免由数据库潜在问题造成的直接经济损失。Lepus能够查看各种实时性能状态指标,并且对监控、性能数据进行统计分析,从运维者到决策者多个层面的视角,查看相关报表。帮助决策者对未来数据库容量进行更好的规划,从而降低了硬件成本。

Lepus 是一个真正的能够帮助企业解决数据库监控和运维的问题,主要可以帮企业解决如下问题:

1.帮助企业解决数据库性能监控问题,及时发现性能和瓶颈,避免由数据库潜在问题造成的直接经济损失

 "Lepus数据库企业监控系统"是针对互联网企业开发的一款专业、强大的企业数据库监控管理系统,企业通过Lepus可以对数据库的实时健康和各种性能指标进行全方位的监控。目前已经支持MySQL、Oracle、MongoDB、Redis数据库的全面监控. Lepus可以在数据库出现数据库无法连通、会话数、进程数、等待事件、同步、延时等故障或者潜在性能问题时,根据用户设置阀值及时将数据库的异常进行报警通知到数据库管理员进行处理和优化,避免因数据库故障或性能瓶颈造成直接的经济损失。

2.帮助企业运维领导决策者更好的统筹数据库容量资源,降低企业硬件成本

Lepus采用列式方式呈现监控指标,适合中大型互联网公司大规模数据库的监控管理。通过WEB界面,企业运维人员和决策者可以进行任意几台主机或所有主机监控的数据库性能、系统资源使用情况对比,并提供数据库性能资源按不同维度排序功能,以及系统资源Top信息图表,帮助决策者更好的发现哪些数据库性能开销大,哪些比较空闲,从运维者到决策者多个层面的视角,查看相关报表。帮助决策者对未来数据库容量进行更好的规划,从而降低了硬件成本。

3.帮助企业DBA运维人员解决重复和枯燥的工作,提高运维人员工作效率

面对几时台甚至上百台数据库服务器,如果没有统一的数据库的基础信息,将会使数据库运维管理变的无序,如果想了解数据库的基本健康状态信息,则需要登录数据库或登录服务器。重复的工作容易使人疲惫和厌倦。Lepus提供数据库的基础数据指标采集,比如数据库版本,运行时间,基本健康状态,核心配置参数等基础数据,有了这些基础数据,无需登录机器即可通过系统集中查询,减少了DBA运维人员的重复性工作和枯燥的敲命令工作。

4.慢查询推送和AWR性能报告,降低数据库运维人员和开发人员的沟通成本

Lepus拥有创新的MySQL慢查询分析,TopSQL自动推送,基于时间范围的MySQL AWR性能报告功能。打破了数据库管理人员被动的联系开发人员解决SQL问题的常规低效率现象。Lepus会定时收集影响数据库稳定性的慢SQL,并根据计划任务定时推送查询次数最多,查询时间最长的TopSQL给相关开发人员,开发人员也可以通过有限的权限自主查询任意时间内的慢SQL语句。也可以通过在线AWR性能报告功能查询数据库历史任意时间的数据库性能问题和瓶颈。降低数据库运维人员和开发人员的沟通成本。

openssl又被爆出新漏洞(CVE-2016-2107)(升级脚本)

$
0
0

openssl又被爆出新漏洞(CVE-2016-2107)(升级脚本)

OpenSSl 密码库的维护人员发布了一个高危安全漏洞的补丁(CVE-2016-2107),这个漏洞可以让攻击者在web服务器上解密登录证书或者执行恶意代码。

当连接使用AES CBC加密并且服务器支持AES-NI的情况下,中间人攻击者可以使用padding oracle攻击来解密流量。

填充检测被重写来确保读取的字节总是相同的,并且对MAC和填充字节进行比较。但它不再检查是否有足够的数据来包含MAC和填充字节。

影响:高危

修复方案:

OpenSSL 1.0.2 用户请更新到1.0.2h版本

OpenSSL 1.0.1 用户请更新到1.0.1t版本

https://www.openssl.org/news/vulnerabilities.html#y2016


----------------------------分割线

登录SSH上操作

wget http://down.wdlinux.cn/in/openssl201605.sh

sh openssl201605.sh

如果能顺利执行完成,不出什么错,就升级完了

Centos6 安装KVM虚拟机NAT模式映射端口方法

$
0
0

安装完KVM后,并建议了虚拟机,nat网络,windows系统,作远程桌面映射时,一直不通。

虚拟机可以正常上网,192.168.122.152 是虚拟机的IP。

这里将45.34.20.84 的10389映射到内网虚拟机 192.168.122.152 的10389 远程桌面端口上。

具体配置命令我就不说了。直接上iptables 配置文件信息。


# Generated by iptables-save v1.4.7 on Tue May 24 23:11:39 2016

*filter
:INPUT ACCEPT [529921:444599212]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [379301:1237760976]
-A INPUT -i virbr0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 10389 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 30290 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 13799 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5555 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 5901 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 2078 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 10389 -j ACCEPT
-A FORWARD -d 192.168.122.0/24 -o virbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 192.168.122.0/24 -i virbr0 -j ACCEPT
-A FORWARD -i virbr0 -o virbr0 -j ACCEPT
COMMIT
# Completed on Tue May 24 23:11:39 2016
# Generated by iptables-save v1.4.7 on Tue May 24 23:11:39 2016
*nat
:PREROUTING ACCEPT [2397:342226]
:POSTROUTING ACCEPT [4640:280043]
:OUTPUT ACCEPT [4640:280043]
-A PREROUTING -d 45.34.20.84/32 -p tcp -m tcp --dport 10389 -j DNAT --to-destination 192.168.122.152:10389
-A POSTROUTING -d 192.168.122.152/32 -p tcp -m tcp --dport 10389 -j SNAT --to-source 192.168.122.1:10389
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p tcp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -p udp -j MASQUERADE --to-ports 1024-65535
-A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE
COMMIT
# Completed on Tue May 24 23:11:39 2016
# Generated by iptables-save v1.4.7 on Tue May 24 23:11:39 2016
*mangle
:PREROUTING ACCEPT [530057:444624339]
:INPUT ACCEPT [530001:444609065]
:FORWARD ACCEPT [38:6091]
:OUTPUT ACCEPT [379306:1237764698]
:POSTROUTING ACCEPT [379329:1237770029]
-A POSTROUTING -o virbr0 -p udp -m udp --dport 68 -j CHECKSUM --checksum-fill
COMMIT
# Completed on Tue May 24 23:11:39 2016

How To Install Zabbix3 on CentOS 7

$
0
0

How To Install Zabbix on CentOS 7


Install Zabbix on CentOS 7

In this tutorial we will show you how to install and configuration of Zabbix on your CentOS 7 server. For those of you who didn’t know, Zabbix is an open source monitoring tool that is ideal for monitoring your cloud servers. Zabbix is very flexible, information can be retrieved using HTTP/SNMP or by installing a Zabbix agent on the machines to monitor, and allows a lot of customization.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Zabbix on a CentOS 7 server.

Install Zabbix on CentOS 7

Step 1. First of all make sure that all packages are up to date.

Step 2. Install LAMP server.

A CentOS 7 LAMP server is required. If you do not have LAMP installed, you can follow our guide here. Also install required PHP modules:

Step 3. Installing Zabbix.

Besides the Zabbix-repository, you will also need the EPEL repository for some dependencies. If you haven’t done so, add that repo too:

After adding zabbix apt repository in your system, Now update package lists and install Zabbix using commands:

Step 4. Configure MariaDB Database for Zabbix.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. you should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB.

Next we will need to log in to the MariaDB console and create a database for Zabbix. Run the following command:

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for the Zabbix software:

Now that the database and user are ready, it’s time to create the database schema for Zabbix in the DB which we just added:

Next, edit zabbix server configuration file:

Step 5. Configure Apache web server.

Created a file for Apache in /etc/httpd/conf.d/zabbix.conf:

Edit this file to look similar to this:

Edit timezone in /etc/httpd/conf.d/zabbix to read this, or your own time zone:

We should adjust php.ini file as per zabbix recommended settings:

Save and close the file. Start/Restart zabbix and httpd services and make them to start automatically on every reboot:

Finally, adjust Firewall and SELinux settings:

Step 6. Accessing Zabbix.

Zabbix will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://yourdomain.com/zabbix or http://server-ip/zabbix and complete the required the steps to finish the installation. If you are using a firewall, please open port 80 to enable access to the control panel.

Install Zabbix on CentOS 7

Congratulation’s! You have successfully installed Zabbix. Thanks for using this tutorial for installing Zabbix Monitoring Tool on your CentOS 7 system. For additional help or useful information, we recommend you to check the official Zabbix web site
Viewing all 780 articles
Browse latest View live