Cacti+Nagios(一):安装环境
系统版本:CentOS-6.5-x86_64
创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、网站制作、成都外贸网站建设、浮山网络推广、小程序开发、浮山网络营销、浮山企业策划、浮山品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联公司为所有大学生创业者提供浮山建站搭建服务,24小时服务热线:18982081108,官方网址:www.cdcxhl.com
一、系统环境
1、主机名
[root@nagios ~]# hostname nagios.ewin.com [root@nagios ~]# vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=nagios.ewin.com
2、yum源
(1)使用本地源
挂载光盘或ISO文件并配置源:
[root@nagios ~]# mkdir /media/cdrom [root@nagios ~]# mount /dev/cdrom /media/cdrom/ [root@nagios ~]# cd /etc/yum.repos.d [root@nagios yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak [root@nagios yum.repos.d]# vi CentOS-Base.repo [base] name=Base baseurl=file:///media/cdrom/ gpgcheck=0 enabled=1
(2)添加163的源
[root@nagios yum.repos.d]# wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
(3)更新列表
[root@nagios yum.repos.d]# yum clean all [root@nagios yum.repos.d]# yum list
(4)解除锁定状态
使用yum安装时可能会出现锁定状态,报错如下:
Another app is currently holding the yum lock; waiting for it to exit...
解决方法:
[root@nagios ~]# rm -f /var/run/yum.pid
3、X桌面环境
查看是否安装了桌面环境的组件,没有则进行组安装:
[root@nagios ~]# yum grouplist | more [root@nagios ~]# yum groupinstall -y "Desktop" "Desktop Platform" "Desktop Platform Development" "Fonts" "General Purpose Desktop" "Graphical Administration Tools" "Graphics Creation Tools" "Input Methods" "X Window System" "Chinese Support [zh]" "Internet Browser"
修改启动级别为5后重启服务器:
[root@nagios ~]# vi /etc/inittab id:5:initdefault: [root@nagios ~]# reboot
4、网卡配置
查看网络配置:
[root@nagios ~]# ifconfig -a eth0 Link encap:Ethernet HWaddr 00:15:5D:01:2C:00 inet addr:10.188.1.103 Bcast:10.188.1.255 Mask:255.255.255.0 inet6 addr: fe80::215:5dff:fe01:2c00/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:20570650 errors:0 dropped:0 overruns:0 frame:0 TX packets:23909757 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1997534214 (1.8 GiB) TX bytes:1952904919 (1.8 GiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:1691114 errors:0 dropped:0 overruns:0 frame:0 TX packets:1691114 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:96615865 (92.1 MiB) TX bytes:96615865 (92.1 MiB)
手动设置网卡:
[root@nagios ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 #接口名称 TYPE=Ethernet #接口类型:以太网 ONBOOT=yes #开机启动 BOOTPROTO=static #静态IP HWADDR=00:15:5D:01:2C:00 #MAC地址 IPADDR=10.188.1.103 #IP地址 PREFIX=24 #子网掩码位数,或使用NETMASK=255.255.255.0 GATEWAY=10.188.1.1 #网关地址 DNS1=10.188.1.2 #DNS服务器地址,我这是内网的DNS DNS2=202.101.224.68 #公网DNS服务器地址
重启网卡:
[root@nagios ~]# ifdown eth0 && ifup eth0
5、vnc远程桌面
安装及启动进程1(端口号是5900+1):
[root@nagios ~]# yum install -y tigervnc-server [root@nagios ~]# vncserver :1 #输入密码123456
配置启动脚本,使用Gnome会话模式:
[root@nagios ~]# vi /root/.vnc/xstartup unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc #twm& gnome-session
重启vnc进程:
[root@nagios ~]# vncserver -kill :1 [root@nagios ~]# vncserver :1
设置开机自动启动:
[root@nagios ~]# vi /etc/sysconfig/vncservers VNCSERVERS="1:root" VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared " [root@nagios ~]# chkconfig vncserver on
6、selinux安全项
[root@nagios ~]# vi /etc/selinux/config SELINUX=disabled [root@nagios ~]# setenforce 0
7、ntpupdate时间同步
[root@nagios ~]# crontab -e 0 * * * * /usr/sbin/ntpdate 65.55.56.206 #1小时同步一次 [root@nagios ~]# service crond restart [root@nagios ~]# ntpdate 65.55.56.206 18 Nov 10:07:49 ntpdate[8567]: step time server 65.55.56.206 offset -0.743765 sec
8、FTP文件传输
[root@nagios ~]# yum install -y vsftpd [root@nagios ~]# vi /etc/vsftpd/vsftpd.conf anonymous_enable=NO #禁止匿名访问 userlist_deny=NO #(手动添加)使用FTP用户表 [root@nagios ~]# useradd ywzhou [root@nagios ~]# passwd ywzhou #输入密码123456 [root@nagios ~]# vi /etc/vsftpd/user_list ywzhou [root@nagios ~]# /etc/init.d/vsftpd start [root@nagios ~]# chkconfig vsftpd on
9、防火墙
[root@nagios ~]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT [root@nagios ~]# iptables -I INPUT -p tcp --dport 21 -j ACCEPT [root@nagios ~]# iptables -I INPUT -p tcp --dport 5901 -j ACCEPT [root@nagios ~]# service iptables save
二、LAMP环境
1、安装Apache
[root@nagios ~]# yum install -y httpd [root@nagios ~]# vi /etc/httpd/conf/httpd.conf DirectoryIndex index.php index.html AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps [root@nagios ~]# service httpd start [root@nagios ~]# chkconfig httpd on
2、安装PHP
[root@nagios ~]# yum -y install php php-devel php-snmp php-gd php-MySQL
访问测试:
[root@nagios ~]# vi /var/www/html/index.php
http://localhost
结论:会显示php的相关信息表示php+apache整合成功
3、安装Mysql
[root@nagios ~]# yum install mysql mysql-server mysql-devel [root@nagios ~]# service mysqld start [root@nagios ~]# chkconfig mysqld on [root@nagios ~]# mysqladmin -u root password '123456'
当主机断电重启后zabbix无法连接mysql,报错如下:
Another MySQL daemon already running with the same unix socket
要先删除mysql.sock文件才能启动mysqld,因此在执行下面的命令开机重启mysql:
[root@nagios ~]# echo "rm -f /var/lib/mysql/mysql.sock && service mysqld restart" >> /etc/rc.local
三、编译环境
1、安装gcc
[root@nagios ~]# yum install gcc
2、安装glibc
[root@nagios ~]# yum install glibc glibc-common
3、安装gd
[root@nagios ~]# yum install gd gd-devel
4、安装pcap
[root@nagios ~]# yum install libtool libpcap libpcap-devel gdbm gdbm-devel zlib zlib-devel
标题名称:Cacti+Nagios(一):安装环境
标题路径:http://hbruida.cn/article/jejohi.html