在centos7 上面安装zabbix5.0&apache(脚本安装)

centos 7 版本 + apache

[root@modelmachine ~] # mysql_secure_installation       (安全初始化)简单的进行数据库优化,移除不必要的数据库和表
5.7之后的版本就没有test数据库了
​
Securing the MySQL server deployment.
​
Enter password for user root:       //当前root用户密码
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.
​
Estimated strength of the password: 0 
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n
//是否改变当前root用户密码
                                
 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
​
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y       //是否移除匿名用户
Success.
​
​
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
​
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y     //禁用root用户远程登录
Success.
​
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
​
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y        //是否删除test数据库并访问它
 - Dropping test database...
Success.
​
 - Removing privileges on test database...
Success.
​
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
​
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y      //是否立即重新加载权限表
Success.
​
All done!  

可以使用脚本安装

[root@modelmachine ~] # vim zabbixinstall.sh
#!/usr/bin/bash 
#httpd + zabbix 安装脚本
yum makecache fast
yum -y install 
systemctl start mysqld
echo "validate_password=off" >> /etc/my.cnf
systemctl restart mysqld
passwd=$(cat /var/log/mysqld.log | grep password | awk 'NR==1{print $11}')
mysqladmin -uroot -p"$passwd" password 1
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
yum makecache fast
yum install zabbix-server-mysql zabbix-agent -y         
yum install centos-release-scl -y
sed -i '11s/0/1/' /etc/yum.repos.d/zabbix.repo
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
mysql -uroot -p1 -e "create database zabbix character set utf8 collate utf8_bin;"
mysql -uroot -p1 -e "create user zabbix@localhost identified by 'password';"
mysql -uroot -p1 -e "grant all privileges on zabbix.* to zabbix@localhost;"
mysql -uroot -p1 -e "set global log_bin_trust_function_creators = 1;"
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -ppassword zabbix
mysql -uroot -p1 -e "set global log_bin_trust_function_creators = 0;"
echo "DBPassword=password" >>  /etc/zabbix/zabbix_server.conf
sed -i 's/Europe\/Riga/Asia\/Shanghai/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
​

以下是脚本解释

#!/usr/bin/bash 
#httpd + zabbix 安装脚本    
#首先自行安装MySQL
systemctl start mysqld              #启动服务
echo "validate_password=off" >> /etc/my.cnf     #修改弱密码策略
systemctl restart mysqld                        #重启服务
passwd=$(cat /var/log/mysqld.log | grep password | awk 'NR==1{print $11}')      #将密码设置为变量
mysqladmin -uroot -p"$passwd" password 1            #更改密码
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm                       #配置zabbix的yum源
yum clean all                       #清理缓存
yum install zabbix-server-mysql zabbix-agent -y         
yum install centos-release-scl -y
sed -i '11s/0/1/' /etc/yum.repos.d/zabbix.repo          //修改为enabled为1,开启状态
yum install zabbix-web-mysql-scl zabbix-apache-conf-scl -y
mysql -uroot -p1 -e "create database zabbix character set utf8 collate utf8_bin;"       #创建数据库设置语言格式
mysql -uroot -p1 -e "create user zabbix@localhost identified by 'password';"        #创建用户并设置密码
mysql -uroot -p1 -e "grant all privileges on zabbix.* to zabbix@localhost;"         #给zabbix用户授权
mysql -uroot -p1 -e "set global log_bin_trust_function_creators = 1;"           #启用 MySQL 中的 log_bin_trust_function_creators 全局系统变量。MySQL 会信任函数/存储过程的创建者,
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -ppassword zabbix       #解压缩并导入数据
mysql -uroot -p1 -e "set global log_bin_trust_function_creators = 0;"       #导入数据之后再将其禁用
echo "DBPassword=password" >>  /etc/zabbix/zabbix_server.conf       #给配置文件中加入密码选项
sed -i 's/;Europe\/Riga/Asia\/Shanghai/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf     #修改时区
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm        #重启服务
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm

agent端安装

# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# yum clean all
# yum install zabbix-agent
# systemctl restart zabbix-agent
# systemctl enable zabbix-agent
修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
Server=server端的IP地址
ServerActive=server端的IP地址
Hostname=agent的主机名
UnsafeUserParamete
  • 27
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值