|
OCSNG服务端安装文档
系统环境:
全新安装debian-7.9.0-amd64-DVD-1.iso
安装选项如下图:
系统启动
使其联网 ,获取的IP:192.168.79.129
1
2
3
4
5
6
7
8
9
10
| chunli@debian:~$ su root
Password:
root@debian:/home/chunli#
root@debian:/home/chunli# cd /etc/apt/
root@debian:/etc/apt# wget http://mirrors.163.com/.help/sources.list.wheezy
root@debian:/etc/apt# cp sources.list.wheezy sources.list
root@debian:/etc/apt# apt-get update
root@debian:/etc/apt# apt-get install -y vim
root@debian:/etc/apt# sed -i 's#"syntax on#syntax on#g' /etc/vim/vimrc
|
安装OCSNG依赖1
2
3
| root@debian:/etc/apt# aptitude install -y libxml-simple-perl libcompress-zlib-perl libdbi-perl libdbd-mysql-perl libapache-dbi-perl libnet-ip-perl libsoap-lite-perl
root@debian:/etc/apt# echo $?
0
|
安装Apache2,PHP5,MySQL1
2
3
4
5
6
7
8
| root@debian:~# aptitude install -y apache2 php5 php5-gd php5-mysql mysql-server
MySQL账号root
MySQL密码 sa
root@debian:/etc/apt# echo $?
0
root@debian:/home/chunli# rm -f /var/www/index.html
root@debian:/home/chunli# echo '<?php echo mysql_connect(localhost,root,sa)?"mysql_connect success":"mysql_connec tfail"; echo phpinfo();?>' >/var/www/index.php
|
访问测试 浏览器访问:192.168.79.129
安装OCS服务端程序setup.sh
安装OCSNG服务端容易出错,一般是前面的依赖没有解决。
我把完整的过程贴出来。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
| root@debian:/home/chunli# md5sum OCSNG_UNIX_SERVER-2.1.2.tar.gz
4c30d733de720f9ed05e4ae588e644bf OCSNG_UNIX_SERVER-2.1.2.tar.gz
root@debian:/home/chunli# tar xf OCSNG_UNIX_SERVER-2.1.2.tar.gz
root@debian:/home/chunli# cd OCSNG_UNIX_SERVER-2.1.2
一路按回车,注意这个地方
Where to copy Administration Server static files for PHP Web Console
[/usr/share/ocsinventory-reports] ?/var/www/
root@debian:/home/chunli/OCSNG_UNIX_SERVER-2.1.2# ./setup.sh
+----------------------------------------------------------+
| |
| Welcome to OCS Inventory NG Management server setup ! |
| |
+----------------------------------------------------------+
Trying to determine whitch OS or Linux distribution you use
+----------------------------------------------------------+
| Checking for Apache web server binaries ! |
+----------------------------------------------------------+
CAUTION: If upgrading Communication server from OCS Inventory NG 1.0 RC2 and
previous, please remove any Apache configuration for Communication Server!
Do you wish to continue ([y]/n)?
Assuming Communication server 1.0 RC2 or previous is not installed
on this computer.
Starting OCS Inventory NG Management server setup from folder /home/chunli/OCSNG_UNIX_SERVER-2.1.2
Storing log in file /home/chunli/OCSNG_UNIX_SERVER-2.1.2/ocs_server_setup.log
+----------------------------------------------------------+
| Checking for database server properties... |
+----------------------------------------------------------+
Your MySQL client seems to be part of MySQL version 5.5.
Your computer seems to be running MySQL 4.1 or higher, good ;-)
Which host is running database server [localhost] ?
OK, database server is running on host localhost ;-)
On which port is running database server [3306] ?
OK, database server is running on port 3306 ;-)
+----------------------------------------------------------+
| Checking for Apache web server daemon... |
+----------------------------------------------------------+
Where is Apache daemon binary [/usr/sbin/apache2] ?
OK, using Apache daemon /usr/sbin/apache2 ;-)
+----------------------------------------------------------+
| Checking for Apache main configuration file... |
+----------------------------------------------------------+
Where is Apache main configuration file [/etc/apache2/apache2.conf] ?
OK, using Apache main configuration file /etc/apache2/apache2.conf ;-)
+----------------------------------------------------------+
| Checking for Apache user account... |
+----------------------------------------------------------+
Which user account is running Apache web server [www-data] ?
OK, Apache is running under user account www-data ;-)
+----------------------------------------------------------+
| Checking for Apache group... |
+----------------------------------------------------------+
Which user group is running Apache web server [www-data] ?
OK, Apache is running under users group www-data ;-)
+----------------------------------------------------------+
| Checking for Apache Include configuration directory... |
+----------------------------------------------------------+
Setup found Apache Include configuration directory in
/etc/apache2/conf.d/.
Setup will put OCS Inventory NG Apache configuration in this directory.
Where is Apache Include configuration directory [/etc/apache2/conf.d/] ?
OK, Apache Include configuration directory /etc/apache2/conf.d/ found ;-)
+----------------------------------------------------------+
| Checking for PERL Interpreter... |
+----------------------------------------------------------+
Found PERL Intrepreter at </usr/bin/perl> ;-)
Where is PERL Intrepreter binary [/usr/bin/perl] ?
OK, using PERL Intrepreter /usr/bin/perl ;-)
Do you wish to setup Communication server on this computer ([y]/n)?
+----------------------------------------------------------+
| Checking for Make utility... |
+----------------------------------------------------------+
OK, Make utility found at </usr/bin/make> ;-)
+----------------------------------------------------------+
| Checking for Apache mod_perl version... |
+----------------------------------------------------------+
Checking for Apache mod_perl version 1.99_22 or higher
Found that mod_perl version 1.99_22 or higher is available.
OK, Apache is using mod_perl version 1.99_22 or higher ;-)
+----------------------------------------------------------+
| Checking for Communication server log directory... |
+----------------------------------------------------------+
Communication server can create detailled logs. This logs can be enabled
by setting interger value of LOGLEVEL to 1 in Administration console
menu Configuration.
Where to put Communication server log directory [/var/log/ocsinventory-server] ?
OK, Communication server will put logs into directory /var/log/ocsinventory-server ;-)
+----------------------------------------------------------------------------+
| Checking for Communication server plugins configuration directory... |
+----------------------------------------------------------------------------+
Communication server need a directory for plugins configuration files.
Where to put Communication server plugins configuration files [/etc/ocsinventory-server/plugins] ?
OK, Communication server will put plugins configuration files into directory /etc/ocsinventory-server/plugins ;-)
+-------------------------------------------------------------------+
| Checking for Communication server plugins perl directory... |
+-------------------------------------------------------------------+
Communication server need a directory for plugins Perl modules files.
Where to put Communication server plugins Perl modules files [/etc/ocsinventory-server/perl] ?
OK, Communication server will put plugins Perl modules files into directory /etc/ocsinventory-server/perl ;-)
+----------------------------------------------------------+
| Checking for required Perl Modules... |
+----------------------------------------------------------+
Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for Apache::DBI PERL module...
Found that PERL module Apache::DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for Compress::Zlib PERL module...
Found that PERL module Compress::Zlib is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
+----------------------------------------------------------+
| Checking for optional Perl Modules... |
+----------------------------------------------------------+
Checking for SOAP::Lite PERL module...
Found that PERL module SOAP::Lite is available.
Checking for Apache2::SOAP PERL module...
*** Warning: PERL module Apache2::SOAP is not installed !
This module is only required by OCS Inventory NG SOAP Web Service.
Do you wish to continue ([y]/n] ?
Checking for XML::Entities PERL module...
Found that PERL module XML::Entities is available.
+----------------------------------------------------------+
| OK, looks good ;-) |
| |
| Configuring Communication server Perl modules... |
+----------------------------------------------------------+
Checking if your kit is complete...
Looks good
Writing Makefile for Apache::Ocsinventory
Writing MYMETA.yml
+----------------------------------------------------------+
| OK, looks good ;-) |
| |
| Preparing Communication server Perl modules... |
+----------------------------------------------------------+
+----------------------------------------------------------+
| OK, prepare finshed ;-) |
| |
| Installing Communication server Perl modules... |
+----------------------------------------------------------+
+----------------------------------------------------------+
| OK, Communication server Perl modules install finished;-)|
| |
| Creating Communication server log directory... |
+----------------------------------------------------------+
Creating Communication server log directory /var/log/ocsinventory-server.
Fixing Communication server log directory files permissions.
Configuring logrotate for Communication server.
Removing old communication server logrotate file /etc/logrotate.d/ocsinventory-NG
Writing communication server logrotate to file /etc/logrotate.d/ocsinventory-server
+-----------------------------------------------------------------------------+
| OK, Communication server log directory created ;-) |
| |
| Creating Communication server plugins configuration directory... |
+-----------------------------------------------------------------------------+
Creating Communication server plugins configuration directory /etc/ocsinventory-server/plugins.
+-----------------------------------------------------------------------------+
| OK, Communication server plugins configuration directory created ;-) |
| |
| Creating Communication server plugins Perl directory... |
+-----------------------------------------------------------------------------+
Creating Communication server plugins Perl directory /etc/ocsinventory-server/perl.
+-------------------------------------------------------------------+
| OK, Communication server plugins Perl directory created ;-) |
| |
| Now configuring Apache web server... |
+-------------------------------------------------------------------+
To ensure Apache loads mod_perl before OCS Inventory NG Communication Server,
Setup can name Communication Server Apache configuration file
'z-ocsinventory-server.conf' instead of 'ocsinventory-server.conf'.
Do you allow Setup renaming Communication Server Apache configuration file
to 'z-ocsinventory-server.conf' ([y]/n) ?
OK, using 'z-ocsinventory-server.conf' as Communication Server Apache configuration file
Removing old communication server configuration to file /etc/apache2/conf.d//ocsinventory.conf
Writing communication server configuration to file /etc/apache2/conf.d//z-ocsinventory-server.conf
+----------------------------------------------------------+
| OK, Communication server setup sucessfully finished ;-) |
| |
| Please, review /etc/apache2/conf.d//z-ocsinventory-server.conf
| to ensure all is good. Then restart Apache daemon. |
+----------------------------------------------------------+
Do you wish to setup Administration Server (Web Administration Console)
on this computer ([y]/n)?
+----------------------------------------------------------+
| Checking for Administration Server directories... |
+----------------------------------------------------------+
CAUTION: Setup now install files in accordance with Filesystem Hierarchy
Standard. So, no file is installed under Apache root document directory
(Refer to Apache configuration files to locate it).
If you're upgrading from OCS Inventory NG Server 1.01 and previous, YOU
MUST REMOVE (or move) directories 'ocsreports' and 'download' from Apache
root document directory.
If you choose to move directory, YOU MUST MOVE 'download' directory to
Administration Server writable/cache directory (by default
/var/lib/ocsinventory-reports), especialy if you use deployement feature.
Do you wish to continue ([y]/n)?
Assuming directories 'ocsreports' and 'download' removed from
Apache root document directory.
Where to copy Administration Server static files for PHP Web Console
[/usr/share/ocsinventory-reports] ?/var/www/
OK, using directory /var/www/ to install static files ;-)
Where to create writable/cache directories for deployement packages,
administration console logs, IPDiscover and SNMP [/var/lib/ocsinventory-reports] ?
OK, writable/cache directory is /var/lib/ocsinventory-reports ;-)
+----------------------------------------------------------+
| Checking for required Perl Modules... |
+----------------------------------------------------------+
Checking for DBI PERL module...
Found that PERL module DBI is available.
Checking for DBD::mysql PERL module...
Found that PERL module DBD::mysql is available.
Checking for XML::Simple PERL module...
Found that PERL module XML::Simple is available.
Checking for Net::IP PERL module...
Found that PERL module Net::IP is available.
+----------------------------------------------------------+
| Installing files for Administration server... |
+----------------------------------------------------------+
Creating PHP directory /var/www//ocsreports.
Copying PHP files to /var/www//ocsreports.
Fixing permissions on directory /var/www//ocsreports.
Creating database configuration file /var/www//ocsreports/dbconfig.inc.php.
Creating IPDiscover directory /var/lib/ocsinventory-reports/ipd.
Fixing permissions on directory /var/lib/ocsinventory-reports/ipd.
Creating packages directory /var/lib/ocsinventory-reports/download.
Fixing permissions on directory /var/lib/ocsinventory-reports/download.
Creating snmp mibs directory /var/lib/ocsinventory-reports/snmp.
Fixing permissions on directory /var/lib/ocsinventory-reports/snmp.
Creating Administration server log files directory /var/lib/ocsinventory-reports/logs.
Fixing permissions on directory /var/lib/ocsinventory-reports/logs.
Creating Administration server scripts log files directory /var/lib/ocsinventory-reports/scripts.
Fixing permissions on directory /var/lib/ocsinventory-reports/scripts.
Configuring IPDISCOVER-UTIL Perl script.
Installing IPDISCOVER-UTIL Perl script.
Fixing permissions on IPDISCOVER-UTIL Perl script.
Writing Administration server configuration to file /etc/apache2/conf.d//ocsinventory-reports.conf
+----------------------------------------------------------+
| OK, Administration server installation finished ;-) |
| |
| Please, review /etc/apache2/conf.d//ocsinventory-reports.conf
| to ensure all is good and restart Apache daemon. |
| |
| Then, point your browser to http://server//ocsreports
| to configure database server and create/update schema. |
+----------------------------------------------------------+
Setup has created a log file /home/chunli/OCSNG_UNIX_SERVER-2.1.2/ocs_server_setup.log. Please, save this file.
If you encounter error while running OCS Inventory NG Management server,
we can ask you to show us his content !
DON'T FORGET TO RESTART APACHE DAEMON !
Enjoy OCS Inventory NG ;-)
root@debian:/home/chunli/OCSNG_UNIX_SERVER-2.1.2#
|
OCS服务端初始化安装http://192.168.79.129/ocsreports/
连接MySQL
登录ocs服务端
首页红色提示警告!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| 解决第一个警告
root@debian:~# cd /var/www/ocsreports/
root@debian:/var/www/ocsreports# mv install.php install.php.201601062159.bak
解决第二个警告
root@debian:/var/www/ocsreports# mysql -hlocalhost -uroot -p
Enter password:sa
mysql> use mysql;
mysql> UPDATE user SET password = PASSWORD('ocs_sa') WHERE user = 'ocs';
mysql> FLUSH PRIVILEGES;
mysql> \q
root@debian:/var/www/ocsreports# vim /var/www/ocsreports/dbconfig.inc.php
<?php
define("DB_NAME", "ocsweb");
define("SERVER_READ","localhost");
define("SERVER_WRITE","localhost");
define("COMPTE_BASE","ocs");
define("PSWD_BASE","ocs_sa");
?>
|
解决第三个警告
Apache与MySQL配置
服务端通过apache2接收客户端的数据,并存到MySQL中,修改访问MySQL的用户与密码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| root@debian:/home/chunli# vim /etc/apache2/conf.d/z-ocsinventory-server.conf
# Master Database settings
# Replace localhost by hostname or ip of MySQL server for WRITE
PerlSetEnv OCS_DB_HOST localhost
# Replace 3306 by port where running MySQL server, generally 3306
PerlSetEnv OCS_DB_PORT 3306
# Name of database
PerlSetEnv OCS_DB_NAME ocsweb
PerlSetEnv OCS_DB_LOCAL ocsweb
# User allowed to connect to database
PerlSetEnv OCS_DB_USER root
# Password for user
PerlSetVar OCS_DB_PWD sa
|
改好了,保存!
重启apache
1
| root@debian:/home/chunli#service apache2 restart
|
linux平台安装客户端:
安装前提:
apt-get 源已经配置好。
Debian7.9 演示安装,成功
Debian8.2 演示安装,成功
1
2
3
4
5
6
7
8
9
|
root@debian:~# tar xf ocs_agent20160106.2143.tar.gz
root@debian:~# cd ocs_agent20160106.2143/linux平台安装一键脚本/
root@debian:~/ocs_agent20160106.2143/linux平台安装一键脚本# ./install.sh
请输入设备的资产编号 :12345
设置信息反馈时间间隔 [1-23]/ [2]?:5
本机的资产编号:12345
debug 模式: debug=0
成功地安装了ocsinventory客户端
|
到服务端可以看到提交的信息
附脚本:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
| root@debian:~/ocs_agent20160106.2143/linux平台安装一键脚本# cat install.sh
#!/bin/bash
# cacert.pem
# deb.txt
# yum packages
# Ocsinventory-agent
# fix cron time
# fix sync time
# if test ok,modify debug=0
# 2015.08.14 fix redhat linux yum depend problems
# 2015.08.14 fix seting cron time
# 2015.08.17 grep Successful or break
# 2015 09 17 fix apt-get
# 2015 10 08 Judge DNS
export PATH=$PATH:.
ocsng_server=192.168.79.129
root_id=`id -u`
if [ $root_id -ne 0 ] ; then
{
echo -e "\033[40;37m权限不够! \n\n请切换到root用户,sudo su \n\n \033[0m"
exit 1
}
fi
echo "检查DNS";
ping -c 4 $ocsng_server || {
echo "请检查您的DNS!"
exit 2
}
rm -rf /etc/ocsinventory* #rm old agent conf
#判断操作系统类别 ************************************
if [ -f /etc/redhat-release ]
then
OS=1
elif [ -f /etc/debian_version ]
then
OS=2
else
echo "无法判断您的操作系统类型!"
exit 3
fi
# Debian ********************************
if [ $OS -eq 2 ] ;then
echo -e "\033[40;37m欢迎使用Debian类操作系统\033[0m"
sleep 5
mkdir /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
apt-get install -y aptitude
aptitude install -y ntpdate bc dmidecode libxml-simple-perl libnet-ip-perl libwww-perl perl libnet-ssleay-perl libcrypt-ssleay-perl libnet-snmp-perl libproc-pid-file-perl libproc-daemon-perl net-tools libsys-syslog-perl pciutils smartmontools read-edid nmap make
stat=`echo $?`
fi
# RedHat OS ********************************
if [ $OS -eq 1 ] ;then
echo "Redhat Linux "
sleep 1
mkdir -p /etc/ocsinventory-agent
cp -f ./cacert.pem /etc/ocsinventory-agent/
yum -y --nogpgcheck localinstall ./packages/*.rpm
stat=`echo $?`
fi
# sync time ****************************************
echo "与cn.pool.ntp.org时间同步!"
ntpdate cn.pool.ntp.org
# make && make install *******************************
if [ $stat -eq 0 ] ;then
while [ 1 ]
do
echo -en "\033[47;34;7m请输入设备的资产编号 :\033[0m"
read tag
leng1=`echo ${tag} | wc -L|bc`
if [ $leng1 -lt 5 ]
then
echo -e "\033[40;36;7m资产编号长度不应少于5位:\033[0m"
else
break
fi
done
# read input time for cron
while [ 1 ]
do
echo -en "\033[47;34;7m设置信息反馈时间间隔\033[0m [1-23]/ [2]?:"
read time1
if [ -z "$time1" ];then
time1=2
fi
time2=`echo ${time1} |bc`
if [ $time2 -ge 1 -a $time2 -le 23 ]
then
time3=$time2
break
else
echo "输入错误,请重试!"
fi
done
cd Ocsinventory-Unix-Agent-2.1.1
make clean
env PERL_AUTOINSTALL=1 perl Makefile.PL && make && make install && perl postinst.pl --nowizard --remove-old-linux-agent --server=http://$ocsng_server/ocsinventory --crontab --tag=$tag --debug --logfile=/etc/ocsinventory-agent/log --ca=/etc/ocsinventory-agent/cacert.pem --snmp --now
tail /etc/ocsinventory-agent/log |grep "error"
stat2=`echo $?`
else
ls -1
echo "apt-get 或yum 源有问题!"
exit 5
fi
if [ $stat2 -ne 0 ] ;then
echo -e "\n\n\n";
date
echo "成功安装ocsinventory客户端"
sleep 2
sed -i "s#debug=1#debug=0#g" /etc/ocsinventory-agent/ocsinventory-agent.cfg
a=`date +%M`
b=`echo "$a"|bc`
sed -i '2d' /etc/cron.d/ocsinventory-agent
echo "$b */$time3 * * * root /usr/local/bin/ocsinventory-agent --lazy > /dev/null 2>&1" >> /etc/cron.d/ocsinventory-agent
stat3=`echo $?`
if [ $stat3 -eq 0 ] ;then
if [ $OS -eq 2 ] ;then #debian
/etc/init.d/cron restart
stat4=`echo $?`
fi
if [ $OS -eq 1 ] ;then #redHat
service crond reload
stat4=`echo $?`
fi
fi
else
date
echo '安装出错,请检查日志 tail /etc/ocsinventory-agent/log'
echo "证书问题:Cannot establish communication : 500 Can't connect to 192.168.79.129:443";
echo "服务端访问MySQL问题:Cannot establish communication : 500 Internal Server Error";
echo '检查服务器端MySQL账号 密码 debian:/etc/apache2/conf.d/z-ocsinventory-server.conf';
exit 6
fi
if [ $stat4 -eq 0 ] ;then
echo "本机的资产编号:$tag"
echo -e "debug 模式:"
grep debug=0 /etc/ocsinventory-agent/ocsinventory-agent.cfg
echo -en "成功地安装了ocsinventory客户端\n\n当前小时的时间为: "
tail -n 1 /etc/cron.d/ocsinventory-agent | cut -d " " -f1
else
echo "设置计划任务出错! "
exit 7
fi
root@debian:~/ocs_agent20160106.2143/linux平台安装一键脚本#
|
|
|