Zabbix5.0LTS 安装脚本

Install_Zabbix5.0LTS

 

#install.sh
#yum安装zabbix-server-mysql存在写入/usr/share/doc目录失败的情况(dockerfile和容器内执行均存在)
#dockerfile构建时无法启动mariadb,通过命令启动会话挂起)
#zabbix图形中文
#docker cp /root/2Build/simkai.ttf $container_name:/usr/share/fonts/dejavu/simkai.ttf
#docker exec -it $container_name /bin/bash -c 'ln -b -s /usr/share/fonts/dejavu/simkai.ttf /etc/alternatives/zabbix-web-font'
#docker stop $container_name && docker commit $container_name zabbix5_img

#添加wget和which组件
yum -y install wget which; \
#更改时区
timedatectl set-timezone "Asia/Shanghai"; \
#更新阿里源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo; \
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo; \
#安装zabbix5源
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm; \
#更新zabbix源指向阿里源
sed -i "s/http:\/\/repo.zabbix.com\//https:\/\/mirrors.aliyun.com\/zabbix\//g" /etc/yum.repos.d/zabbix.repo
#安装中文字符集
yum -y install epel-release kde-l10n-Chinese crontabs; \
localedef -c -f UTF-8 -i zh_CN zh_CN.utf8; \
sed -i '$a\export LANG="en_US.UTF-8"' /etc/bashrc; \
sed -i -e '/MAILTO=root/a\LANG="en_US.UTF-8"' /etc/crontab; \
#安装zabbix和python3组件
yum -y install httpd zabbix-server-mysql zabbix-agent redis mariadb-server python36; \
yum -y install centos-release-scl; \
#修改  /etc/yum.repos.d/zabbix.repo and enable zabbix-frontend repository.
sed -i '0,/enabled=0/{s/enabled=0/enabled=1/}' /etc/yum.repos.d/zabbix.repo; \
yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl; \
#卸载zabbix-server-mysql后单独安装,yum存在/usr/share/doc生成初始化数据库脚本写入失败的问题
rpm -qa|grep zabbix-server-mysql|xargs rpm -e; \
rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-server-mysql-5.0.2-1.el7.x86_64.rpm; \
#启动MySQL后创建zabbix账号(密码zabbix),更新授权并初始化数据库
systemctl start mariadb; \
echo "create database zabbix character set utf8 collate utf8_bin;" | mysql; \
echo "create user zabbix@localhost identified by 'zabbix2020';" | mysql; \
echo "grant all privileges on zabbix.* to zabbix@localhost;" | mysql; \
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix; \
#修改server配置中的数据库密码和时区设置
sed -i '/# DBPassword=/a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf; \
sed -i '/; php_value\[date.timezone\] = Europe\/Riga/a\php_value[date.timezone] = Asia\/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf; \
#修改redis地址绑定
sed -i 's/^bind 127.0.0.1/bind 0.0.0.0/g' /etc/redis.conf; \
#redis启动设置,通过dockerfile初始化时使用
#sed -i '$a\/usr/bin/redis-server /etc/redis.conf' /etc/rc.d/rc.local; \
#chmod +x /etc/rc.d/rc.local; \
#安装Pyhton虚拟环境并切换到v36环境
curl https://bootstrap.pypa.io/get-pip.py|python; \
pip install virtualenv virtualenvwrapper fabric --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com; \
sed -i '$a\source /usr/bin/virtualenvwrapper.sh' /etc/bashrc; \
source /usr/bin/virtualenvwrapper.sh; \
mkvirtualenv -p `which python3.6` v36; \
#安装python组件
pip install requests bs4 flask flask-bootstrap flask_restful flask-admin paramiko pymssql pymysql redis scrapy pillow numpy pandas --no-cache-dir -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com; \
#清理yum缓存
yum clean all; \
#启动服务并设置开机启动
systemctl enable zabbix-server zabbix-agent httpd mariadb redis crond rh-php72-php-fpm;
systemctl restart zabbix-server zabbix-agent httpd redis crond; 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值