月度归档:2017年06月

Zabbix Agent配置完成后无法启动Permission denied

今天在节点机器上新安装的Zabbix Agent无法启动。

1.查看Zabbix Agent日志文件才究其原因。

# cat /var/log/zabbix/zabbix_agentd.log

63133:20170601:092700.920 **************************
63133:20170601:092700.920 using configuration file: /etc/zabbix/zabbix_agentd.conf
63133:20170601:092700.920 cannot set resource limit: [13] Permission denied
63133:20170601:092700.920 cannot disable core dump, exiting...
63137:20170601:092711.171 Starting Zabbix Agent [cong171163]. Zabbix 3.2.6 (revision 67849).
63137:20170601:092711.171 **** Enabled features ****
63137:20170601:092711.171 IPv6 support: YES
63137:20170601:092711.171 TLS support: YES
63137:20170601:092711.171 **************************
......

2.此时只需要关闭Selinux,两种方案;

2.1.临时关闭

# setenforce 0

2.2.永久关闭(reboot host)

# vim /etc/selinux/config

SELINUX=enforcing

SELINUX=disabled

3.操作完成后,再次启动zabbix-agent服务

# systemctl start zabbix-agent.service

4.查看端口

# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port 
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:* 
LISTEN 0 128 *:10050 *:*
LISTEN 0 80 :::3306 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::10050 :::*

zabbix agent启动成功,10050端口已经运行。

Zabbix中文监控服务器图形图表显示乱码

zabbix对中文的支持不是很好,但为了管理方面有时候我们还是会选择中文,在zabbix监控的web界面,图形图标下面的中文会显示一个个小方块,这样是不正确的,需要下载字体。例如“微软雅黑”

“微软雅黑.ttf” 命名为 “msyh.ttf”

将下载的字体上传到/zabbix/fonts/字体下

修改/zabbix/include/defines.inc.php文件中的两处

define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans');
define('ZBX_FONT_NAME', 'DejaVuSans');

define('ZBX_GRAPH_FONT_NAME', 'msyh');
define('ZBX_FONT_NAME', 'msyh');

最后重启web服务器即可。

MariaDB MaxScale 2.1.3中间件数据库读写分离安装配置

操作系统:CentOS Linux release 7.3.1611 (Core)
数据库:MariaDB-10.2.6-linux-glibc_214-x86_64
MaxScale服务器:10.200.10.55
主服务器:172.16.8.56
从服务器:172.16.8.57
从服务器:172.16.8.58

1.maxscale的安装方式有很多,例如源码安装、rpm、二进制构建等,我选择二进制进行安装。

根据场景需要下载相对应的版本,下载地址;//mariadb.com/downloads/maxscale

[root@localhost ~]# groupadd maxscale
[root@localhost ~]# useradd -g maxscale maxscale
[root@localhost ~]# cd /usr/local
[root@localhost local]# wget //downloads.mariadb.com/MaxScale/2.1.3/centos/7server/x86_64/maxscale-2.1.3.centos.7.tar.gz
[root@localhost local]# tar zxvf maxscale-2.1.3.centos.7.tar.gz
[root@localhost local]# ln -s maxscale-2.1.3.centos.7 maxscale
[root@localhost local]# cd maxscale
[root@zhu56 maxscale]# chown -R maxscale var

建议创建软连接,这样有助于以后的版本升级及后期维护。

2.首次安装maxscale需要创建日志相关目录

[root@localhost ~]# mkdir /var/log/maxscale
[root@localhost ~]# mkdir /var/lib/maxscale
[root@localhost ~]# mkdir /var/run/maxscale
[root@localhost ~]# mkdir /var/cache/maxscale

3.以下目录必须具备maxscala用户权限

[root@localhost ~]# chown maxscale /var/log/maxscale
[root@localhost ~]# chown maxscale /var/lib/maxscale
[root@localhost ~]# chown maxscale /var/run/maxscale
[root@localhost ~]# chown maxscale /var/cache/maxscale

4.为了能让Maxscale能顺利启动,还需要创建配置文件,在Maxscale目录下有配置文件模板拷贝到etc下即可。

[root@localhost ~]# cp /usr/local/maxscale/etc/maxscale.cnf.template /etc/maxscale.cnf

5.在修改配置文件之前,需要在主服务器上创建一个用户并给予授权,而这个用户用于MySQL监控、路由功能

MariaDB [(none)]> create user 'jiankongdb'@'%' identified by 'jiankong123';
MariaDB [(none)]> grant SELECT on mysql.user to 'jiankongdb'@'%';
MariaDB [(none)]> GRANT SELECT ON mysql.db TO 'jiankongdb'@'%';
MariaDB [(none)]> GRANT SELECT ON mysql.tables_priv TO 'jiankongdb'@'%';
MariaDB [(none)]> GRANT SHOW DATABASES ON *.* TO 'jiankongdb'@'%';
MariaDB [(none)]> grant REPLICATION CLIENT on *.* to 'jiankongdb'@'%';

MariaDB [(none)]> GRANT replication slave, replication client,SELECT ON *.* TO jiankongdb@'%';

6.查看授权情况

MariaDB [(none)]> SHOW GRANTS FOR'jiankong'@'%';

7.接下来就开始修改maxscale.cnf配置文件,否则无法启动。

[root@localhost ~]# vim /etc/maxscale.cnf

# MaxScale documentation on GitHub:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Documentation-Contents.md

# Global parameters
#
# Complete list of configuration options:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Getting-Started/Configuration-Guide.md
#全局配置
[maxscale]
threads=1

# Server definitions
#
# Set the address of the server to the network
# address of a MySQL server.
#

[server1]
type=server
address=172.16.8.56
port=3306
protocol=MySQLBackend
serv_weight=1

[server2]
type=server
address=172.16.8.57
port=3306
protocol=MySQLBackend
serv_weight=3

[server3]
type=server
address=172.16.8.58
port=3306
protocol=MySQLBackend
serv_weight=3


# Monitor for the servers
#
# This will keep MaxScale aware of the state of the servers.
# MySQL Monitor documentation:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Monitors/MySQL-Monitor.md
#MariaDB状态监控
[MySQL Monitor]
type=monitor
module=mysqlmon
servers=server1,server2,server3
user=jiankong
passwd=jiankong123
monitor_interval=10000
detect_stale_master=true #即使从全挂掉,保证主担任读写

# Service definitions
#
# Service Definition for a read-only service and
# a read/write splitting service.
#

# ReadConnRoute documentation:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Routers/ReadConnRoute.md
#读
[Read-Only Service]
type=service
router=readconnroute
servers=server1,server2,server3
user=jiankong
passwd=jiankong123
router_options=slave
enable_root_user=1 #允许root用户登录执行
weightby=serv_weight #主从权重

# ReadWriteSplit documentation:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Routers/ReadWriteSplit.md
#写
[Read-Write Service]
type=service
router=readwritesplit
servers=server1,server2,server3
user=jiankong
passwd=jiankong123
max_slave_connections=100%
use_sql_variables_in=master #保证会话的一致性
enable_root_user=1 #允许root登录
max_slave_replication_lag=3600 #允许从超出主的同步时间,超出则不路由

# This service enables the use of the MaxAdmin interface
# MaxScale administration guide:
# //github.com/mariadb-corporation/MaxScale/blob/2.1/Documentation/Reference/MaxAdmin.md

[MaxAdmin Service]
type=service
router=cli

# Listener definitions for the services
#
# These listeners represent the ports the
# services will listen on.
#

[Read-Only Listener]
type=listener
service=Read-Only Service
protocol=MySQLClient
port=4008

[Read-Write Listener]
type=listener
service=Read-Write Service
protocol=MySQLClient
port=4006

[MaxAdmin Listener]
type=listener
service=MaxAdmin Service
protocol=maxscaled
socket=default

保存并退出。
8.下面创建启动脚本

[root@localhost ~]# cp /usr/local/maxscale-2.1.3.centos.7/share/maxscale.service /usr/lib/systemd/system/
[root@localhost ~]# vim /usr/lib/systemd/system/maxscale.service

9.修改maxscale.service中的ExecStart=///bin/maxscale为ExecStart=/usr/local/maxscale/bin/maxscale

[root@localhost ~]# chmod 755 /usr/lib/systemd/system/maxscale.service
[root@localhost ~]# systemctl enable maxscale
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl start maxscale

10.添加变量值

[root@localhost ~]# vi /etc/profile //最后一行添加以下内容保存退出!

PATH=$PATH:/usr/local/maxscale/bin
export PATH

[root@localhost ~]# source /etc/profile //使其变量立即生效

11.接下来就可以使用MaxAdmin进行管理。MaxAdmin是一个简单的客户端管理界面,可用于与MariaDB MaxScale服务器进行交互,可以显示MariaDB MaxScale内部的统计信息状态以及对MariaDB MaxScale操作的控制。详情:
//mariadb.com/kb/en/mariadb-enterprise/maxadmin-admin-interface/

[root@localhost ~]# maxadmin //回车
MaxScale> list servers
Servers.
---------------+--------------+-------+-------------+-----------------
Server | Address | Port | Connections | Status 
---------------+--------------+-------+-------------+-----------------
server1 | 172.16.8.56 | 3306 | 0 | Master, Running
server2 | 172.16.8.57 | 3306 | 0 | Slave, Running
server2 | 172.16.8.58 | 3306 | 0 | Slave, Running
---------------+--------------+-------+-------------+-----------------

12.至此MaxScale已经配置完成。现在就可以使用客户端连接Maxscale服务器端 端口为4006。

DirectAdmin更换ID以及换IP地址解决方案

一、

登录DirectAdmin服务器

# cd /usr/local/directadmin/scripts
# ./getLicense.sh 7353 12345
# service directadmin restart

其中7353是客户ID,12345是授权ID

如果你的服务器有多个不同的ip可以强制指定一个ip授权 如:10.200.200.26

# cd /usr/local/directadmin/scripts
# ./getLicense.sh 7353 12345 127.0.0.1
# service directadmin restart

二、

更新授权后需要更换IP,那么按照以下步骤操作

# cd /usr/local/directadmin/scripts
# ./ipswap.sh 10.200.10.26 10.200.200.26

其中10.200.10.26为原IP,10.200.200.26为新IP。之后按以下命令重启所有服务即可(或重启服务器省略以下操作)

# /etc/init.d/httpd restart
# /etc/init.d/proftpd restart
# /etc/init.d/exim restart
# /etc/init.d/dovecot restart

三、

irectAdmin 启动失败,查看2222端口是否运行;

# netstat -antp

若没有2222端口运行说明DirectAdmin并无启动,再次重启;

# service directadmin restart
Stopping DirectAdmin: [FAILED]
Starting DirectAdmin: [ OK ]
# service directadmin restart
Stopping DirectAdmin: [FAILED]
Starting DirectAdmin: [ OK ]
# service directadmin restart
Stopping DirectAdmin: [FAILED]

每次启动提示OK,闪退FAILED,无法打开directadmin控制面板。进directadmin安装目录:

# whereis directadmin
# cd /usr/local/directadmin
# ./directadmin
The ip of this machine (10.200.10.26) does not match the ip in the license file
Check the value of your ethernet_dev=venet0:1 setting in your /usr/local/directadmin/conf/directadmin.conf file and the output of /sbin/ifconfig

根据提示是DA授权失败或IP指定错误,发现客户说的授权IP是在venet0:0,而directadmin 的配置文件里指定的是venet0:1

# ifconfig -a
# vi conf/directadmin.conf
ethernet_dev=venet0:1
改
ethernet_dev=venet0:0

再次执行;

# ./directadmin
[root@hip directadmin]# ./directadmin
Bind Error: Make sure there aren't any copies running in the background
Address already in use

打开//ip:2222 成功显示登录窗口

四、

在使用DA过程中你会遇到dataskq进程占用CPU高达100%的情况,导致网站打开非常缓慢。dataskq这个进程是一个动作响应进程,在 /etc/cron.d/directadmin_cron任务里每分钟都会执行一次,查看
/var/log/directadmin/errortaskq.log日志反馈,dataskq一直检查到named没启动从而导致不断重启,所以可能是机器中的named在升级中卸载了,修复方法如下:

# yum install bind dbus dbus-libs -y
# mv /etc/init.d/named /etc/init.d/named.bak
# wget //www.directadmin.com/named
# chmod 755 /etc/init.d/named
# /sbin/chkconfig named reset
# /etc/init.d/named restart

如果以上方案并没有解决此问题,那就直接将dataskq进程killall掉即可。
更多帮助;//help.directadmin.com/