(四)LNMP环境源码编译安装zabbix-4.0.x——编译安装zabbix-server

版权声明:欢迎转载与交流。https://blog.youkuaiyun.com/one2more/article/details/115318868

(四)LNMP环境源码编译安装zabbix-4.0.x——编译安装zabbix-server

1、软件包列表

序号软件包名称下载地址
01zabbix-4.0.28.tar.gzhttps://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.28.tar.gz
02simkai.ttf中文字体包

2、编译安装Zabbix-server

# 安装相关依赖包
yum install -y expect wget gcc gcc-c++ mariadb-devel \
libcurl libcurl-devel libxml2 libxml2-devel net-snmp net-snmp-devel \
libevent libevent-devel

# 下载zabbix源码包
# wget -c https://cdn.zabbix.com/zabbix/sources/stable/4.0/zabbix-4.0.28.tar.gz -O /usr/local/src/zabbix-4.0.28.tar.gz

# 解压zabbix源码包
tar -xzf /usr/local/src/zabbix-4.0.28.tar.gz -C /opt

# 创建zabbix_server用户
groupadd --system zabbix_server

useradd --system -g zabbix_server -d /opt/zabbix_server_home -s /sbin/nologin -c "Zabbix Monitoring System" zabbix_server

mkdir -m u=rwx,g=rwx,o= -p /opt/zabbix_server_home

chown zabbix_server:zabbix_server /opt/zabbix_server_home

## 执行预编译和编译安装zabbix-server
cd /opt/zabbix-4.0.28
./configure --prefix=/opt/zabbix-server --enable-server --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2

make install

3、导入zabbix初始化相关数据

# 创建zabbix库
mysql -uroot -e "create database zabbix character set utf8 collate utf8_bin"

# 创建zabbix用户并授权访问
mysql -uroot -e "grant all privileges on zabbix.* to zabbix@localhost identified by '123456'"

# 导入zabbix初始数据
mysql -uzabbix -p123456 zabbix < /opt/zabbix-4.0.28/database/mysql/schema.sql

mysql -uzabbix -p123456 zabbix < /opt/zabbix-4.0.28/database/mysql/images.sql

mysql -uzabbix -p123456 zabbix < /opt/zabbix-4.0.28/database/mysql/data.sql

4、配置zabbix-server

## 配置systemd管理zabbix-server
cat > /usr/lib/systemd/system/zabbix-server.service <<-EOF
[Unit]
Description=Zabbix Server with MariaDB
Documentation=man:zabbix_server
After=syslog.target network.target mariadb.service

[Service]
Type=simple
User=zabbix_server
Group=zabbix_server
ExecStart=/opt/zabbix-server/sbin/zabbix_server -f
ExecReload=/opt/zabbix-server/sbin/zabbix_server -R config_cache_reload
Restart=on-abnormal

[Install]
WantedBy=multi-user.target
EOF


## 配置 zabbix-server 主配置文件
sed -i s/'^# ListenPort=10051'/'ListenPort=10051'/g /opt/zabbix-server/etc/zabbix_server.conf

sed -i s/'^# DBHost=localhost'/'DBHost=localhost'/g /opt/zabbix-server/etc/zabbix_server.conf

sed -i s/'^# DBPassword='/DBPassword=123456/g /opt/zabbix-server/etc/zabbix_server.conf
sed -i s/'^# DBPort='/'DBPort=3306'/g /opt/zabbix-server/etc/zabbix_server.conf

## 启动zabbix-server服务并设置开机自启
systemctl daemon-reload
systemctl start zabbix-server.service
systemctl enable zabbix-server.service

## 配置环境变量使zabbix_server命令可用
cat > /etc/profile.d/zabbix-server.sh <<-EOF
export PATH=\$PATH:/opt/zabbix-server/sbin
EOF

source /etc/profile.d/zabbix-server.sh

  用文字分享技术,记录成长! 持续更新中! 欢迎留言、评论交流!

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值