其他分享
首页 > 其他分享> > zabbix3.4-4.2编译部署脚本,部分交互

zabbix3.4-4.2编译部署脚本,部分交互

作者:互联网

#!/bin/bash
#create for install zabbix4.2
#date 2019/08/01

#检查操作系统版本
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
#仅root用户可运行脚本
[ $UID -ne 0 ] && echo "the script need to root" && exit 1 

apache () {
		yum install httpd libxml2-devel net-snmp-devel libcurl-devel
		sed -i "s/#ServerName www.example.com:80/ServerName 127.0.0.1:80/g" /etc/httpd/conf/httpd.conf
#ps:常见问题:启动apache的时候,会有输出如下: Could not reliably determine the server's ully qualified domain name, using 127.0.0.1 for ServerName
#处理方法:1,可以不做任何处理;2,指定/etc/httpd/conf/httpd.conf中的ServerName
}

Mysql () {
		rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
		yum install -y mysql-server mysql-devel
		echo "default-storage-engine = innodb" >>/etc/my.cnf
		echo "innodb_file_per_table" >>/etc/my.cnf
		echo "collation-server = utf8_general_ci" >>/etc/my.cnf
		echo "init-connect = 'SET NAMES utf8'">>/etc/my.cnf
		echo "character-set-server = utf8" >>/etc/my.cnf
		service mysqld start
#Mysql安全设置
		mysql_secure_installation
#PS:一路回车,设置密码
		mysql -e "create database zabbix character set utf8 collate utf8_bin;"
		mysql -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
		mysql -e "flush privileges;"
#创建zabbix数据库
#mysql -uroot -p
#CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
# GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbix';
#FLUSH PRIVILEGES;
		chkconf mysqld on
}	

php () {
		 rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
		 yum install php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml
		 echo "date.timezone = Asia/Shanghai" >>/etc/php.ini
		 echo "post_max_size = 32M" >>/etc/php.ini
		 echo "max_execution_time = 300" >>/etc/php.ini
		 echo "max_input_time = 300" >>/etc/php.ini
		 echo "always_populate_raw_post_data = -1" >>/etc/php.ini
}

zabbix () {
		rpm -Uvh https://repo.zabbix.com/zabbix/4.2/rhel/6/x86_64/zabbix-release-4.2-1.el6.noarch.rpm
		http://repo.zabbix.com/zabbix/3.4/rhel/6/x86_64/zabbix-release-3.4-1.el6.noarch.rpm
		yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
		zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
		mkdir /var/www/html/zabbix &&cp -r /usr/share/zabbix/* /var/www/html/zabbix
		cd /var/www/html/zabbix/assets/fonts/
}

kercannot initialize database cache: cannot get private shared memory of size 1073741824 for history cache: [22] Invalidargument

解决方式:

nel.shmall = 268435456
kernel.shmmax=68719476736

标签:etc,utf8,4.2,echo,编译,zabbix,zabbix3.4,mysql,rpm
来源: https://blog.csdn.net/linux_s2018/article/details/98221256