diff --git a/README.md b/README.md index d841f18..27bb090 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # mongodb +MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. +MongoDB obviates the need for an Object Relational Mapping (ORM) to facilitate development. +MongoDB stores documents in collections. Collections are analogous to tables in relational databases. +Unlike a table, however, a collection does not require its documents to have the same schema. +In MongoDB, documents stored in a collection must have a unique _id field that acts as a primary key. + diff --git a/mongod.conf b/mongod.conf new file mode 100644 index 0000000..c6066cd --- /dev/null +++ b/mongod.conf @@ -0,0 +1,61 @@ +# for documentation of all options, see: +# https://docs.mongodb.org/manual/reference/configuration-options/ + +# Where to write logging data +systemLog: + # The default log message verbosity level for components (0-5) + verbosity: 0 + + destination: file + path: /var/log/mongodb/mongod.log + + logAppend: true + logRotate: reopen + +# Where and how to store data +storage: + # Directory for datafiles (defaults to /data/db/) + dbPath: /var/lib/mongodb + + journal: + # Enable/Disable journaling + enabled: true + + # The storage engine for the mongod database (mmapv1|wiredTiger) + # (wiredTiger by default - works for 64 bit only) + engine: mmapv1 + + # mmapv1: + + # wiredTiger: + +# How the process runs +processManagement: + fork: true # fork and run in background + pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile + +# network interfaces +net: + port: 27017 + # Listen to local interface only, comment to listen on all interfaces + bindIp: 127.0.0.1,::1 + ipv6: true + + unixDomainSocket: + # Enable/disable listening on the UNIX domain socket + enabled: true + # Alternative directory for UNIX domain sockets (defaults to /tmp) + pathPrefix: /var/run/mongodb + +#security: + # Private key for cluster authentication + #keyFile: + + # Run with/without security (enabled|disabled, disabled by default) + #authorization + +#operationProfiling: + +#replication: + +#sharding: diff --git a/mongod.service b/mongod.service new file mode 100644 index 0000000..c5d6cc6 --- /dev/null +++ b/mongod.service @@ -0,0 +1,15 @@ +[Unit] +Description=High-performance, schema-free document-oriented database +After=syslog.target network.target + +[Service] +Type=forking +User=mongodb +EnvironmentFile=/etc/sysconfig/mongod +ExecStart=/usr/bin/mongod $OPTIONS run +PrivateTmp=true +LimitNOFILE=64000 +TimeoutStartSec=180 + +[Install] +WantedBy=multi-user.target diff --git a/mongod.sysconf b/mongod.sysconf new file mode 100644 index 0000000..e8f9cb6 --- /dev/null +++ b/mongod.sysconf @@ -0,0 +1 @@ +OPTIONS="-f /etc/mongod.conf" diff --git a/mongodb.logrotate b/mongodb.logrotate new file mode 100644 index 0000000..384f406 --- /dev/null +++ b/mongodb.logrotate @@ -0,0 +1,12 @@ +/var/log/mongodb/*.log { + weekly + rotate 4 + copytruncate + delaycompress + compress + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/mongodb/mongod.pid 2>/dev/null` 2>/dev/null || true + endscript +} diff --git a/mongodb.spec b/mongodb.spec new file mode 100644 index 0000000..8ea1fb7 --- /dev/null +++ b/mongodb.spec @@ -0,0 +1,179 @@ +%global mongodb_gid 65059 +%global mongodb_group mongodb + +%global mongodb_uid 65059 +%global mongodb_user mongodb + +Name: mongodb +Version: 3.2.3 +Release: 2mamba +Summary: A cross-platform, high-performance, schema-free document-oriented database +Group: Applications/Databases +Vendor: openmamba +Distribution: openmamba +Packager: Davide Madrisan +URL: https://www.mongodb.org/ +Source: http://fastdl.mongodb.org/src/mongodb-src-r%{version}.tar.gz +Source1: mongod.service +Source2: mongod.conf +Source3: mongod.sysconf +Source4: mongos.service +Source5: mongos.conf +Source6: mongos.sysconf +Source7: %{name}.logrotate +License: Affero GNU Public License, Apache License 2.0 +## AUTOBUILDREQ-BEGIN +## note: run 'autospec -u -a6 mongodb' to get the list of build requirements. +## AUTOBUILDREQ-END +BuildRequires: glibc-devel +BuildRequires: libboost-devel +BuildRequires: libgcc +BuildRequires: libopenssl-devel +BuildRequires: libpcap-devel +BuildRequires: libpcre-devel +BuildRequires: libstdc++6-devel +BuildRequires: libyaml-cpp-devel +BuildRequires: libz-devel +## AUTOBUILDREQ-END +BuildRequires: scons +BuildRequires: gcc-c++ +BuildRequires: gcc-go +BuildRequires: libsnappy-devel +BuildRequires: valgrind-devel +%{?systemd_requires} +BuildRoot: %{_tmppath}/%{name}-%{version}-root + +%description +MongoDB is an open-source document database that provides high performance, high availability, and automatic scaling. +MongoDB obviates the need for an Object Relational Mapping (ORM) to facilitate development. +MongoDB stores documents in collections. Collections are analogous to tables in relational databases. +Unlike a table, however, a collection does not require its documents to have the same schema. +In MongoDB, documents stored in a collection must have a unique _id field that acts as a primary key. + +%package server +Group: Applications/Databases +Summary: MongoDB server +Requires: %{name} = %{?epoch:%epoch:}%{version}-%{release} + +%description server +This package provides the mongo server software, mongo sharding server software, default configuration files, and init scripts. + +%prep +%setup -q -n %{name}-src-r%{version} + +%build +# see: https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source +# note: MongoDB uses a customized built-in version of tcmalloc to achieve +# significant performance gains. Building with --use-system-tcmalloc +# produces binaries that lack these performance gains. +# note: WiredTiger is not supported on 32-bit platforms +# Re-run scons with --wiredtiger=off to build on 32-bit platforms +scons all \ +%ifnarch x86_64 + --wiredtiger=off \ +%endif + %{?_smp_mflags} \ + --use-system-pcre \ + --use-system-boost \ + --use-system-valgrind \ + --use-system-zlib \ + --use-system-yaml \ + --ssl \ + --disable-warnings-as-errors + +# --use-system-snappy +# --use-system-stemmer + +%install +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" +scons install \ +%ifnarch x86_64 + --wiredtiger=off \ +%endif + %{?_smp_mflags} \ + --use-system-pcre \ + --use-system-boost \ + --use-system-valgrind \ + --use-system-zlib \ + --use-system-yaml \ + --ssl \ + --disable-warnings-as-errors \ + --prefix=%{buildroot}%{_prefix} + +install -p -D -m 644 "%{SOURCE1}" %{buildroot}%{_unitdir}/mongod.service +install -p -D -m 644 "%{SOURCE2}" %{buildroot}%{_sysconfdir}/mongod.conf +install -p -D -m 644 "%{SOURCE3}" %{buildroot}%{_sysconfdir}/sysconfig/mongod + +install -p -D -m 644 "%{SOURCE4}" %{buildroot}%{_unitdir}/mongos.service +install -p -D -m 644 "%{SOURCE5}" %{buildroot}%{_sysconfdir}/mongos.conf +install -p -D -m 644 "%{SOURCE6}" %{buildroot}%{_sysconfdir}/sysconfig/mongos + +install -p -D -m 644 "%{SOURCE7}" %{buildroot}%{_sysconfdir}/logrotate.d/%{name} + +install -d %{buildroot}%{_localstatedir}/lib/%{name} +install -d %{buildroot}%{_localstatedir}/log/%{name} +install -d %{buildroot}%{_localstatedir}/run/%{name} + +install -d -m 755 %{buildroot}%{_mandir}/man1 +install -p -m 644 debian/mongo{,perf,sniff,d,s}.1 \ + %{buildroot}%{_mandir}/man1/ + +%clean +[ "%{buildroot}" != / ] && rm -rf "%{buildroot}" + +%pre server +getent group %{mongodb_group} >/dev/null || groupadd -g %{mongodb_gid} %{mongodb_group} +getent passwd %{mongodb_user} >/dev/null || useradd -g %{mongodb_gid} -u %{mongodb_uid} \ + -d %{_localstatedir}/lib/%{name} -s /sbin/nologin \ + -c "MongoDB Database Server" %{mongodb_user} +exit 0 + +%post server +%systemd_post mongod.service +%systemd_post mongos.service +exit 0 + +%preun server +%systemd_preun mongod.service +%systemd_preun mongos.service +if [ $1 -eq 0 ]; then + userdel %{mongodb_user} 2>/dev/null + groupdel %{mongodb_group} 2>/dev/null +fi +exit 0 + +%postun server +%systemd_postun_with_restart mongod.service +%systemd_postun_with_restart mongos.service +exit 0 + +%files +%defattr(-,root,root) +%{_bindir}/mongo +%{_bindir}/mongoperf +%{_bindir}/mongosniff +%{_mandir}/man1/mongo.1* +%{_mandir}/man1/mongoperf.1* +%{_mandir}/man1/mongosniff.1* + +%files server +%defattr(-,root,root) +%{_bindir}/mongod +%{_bindir}/mongos +%{_unitdir}/*.service +%config(noreplace) %{_sysconfdir}/*.conf +%config(noreplace) %{_sysconfdir}/sysconfig/mongo* +%config(noreplace) %{_sysconfdir}/logrotate.d/%{name} +%dir %attr(0755, %{mongodb_user}, root) %{_localstatedir}/lib/%{name} +%dir %attr(0755, %{mongodb_user}, root) %{_localstatedir}/log/%{name} +%dir %attr(0755, %{mongodb_user}, root) %{_localstatedir}/run/%{name} +%{_mandir}/man1/mongod.1* +%{_mandir}/man1/mongos.1* + +%changelog +* Sat Feb 27 2016 Davide Madrisan 3.2.3-2mamba +- update the installation scripts and systemd configuration files + +%changelog +* Fri Feb 26 2016 Davide Madrisan 3.2.3-1mamba +- package created using the webbuild interface diff --git a/mongos.conf b/mongos.conf new file mode 100644 index 0000000..c6066cd --- /dev/null +++ b/mongos.conf @@ -0,0 +1,61 @@ +# for documentation of all options, see: +# https://docs.mongodb.org/manual/reference/configuration-options/ + +# Where to write logging data +systemLog: + # The default log message verbosity level for components (0-5) + verbosity: 0 + + destination: file + path: /var/log/mongodb/mongod.log + + logAppend: true + logRotate: reopen + +# Where and how to store data +storage: + # Directory for datafiles (defaults to /data/db/) + dbPath: /var/lib/mongodb + + journal: + # Enable/Disable journaling + enabled: true + + # The storage engine for the mongod database (mmapv1|wiredTiger) + # (wiredTiger by default - works for 64 bit only) + engine: mmapv1 + + # mmapv1: + + # wiredTiger: + +# How the process runs +processManagement: + fork: true # fork and run in background + pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile + +# network interfaces +net: + port: 27017 + # Listen to local interface only, comment to listen on all interfaces + bindIp: 127.0.0.1,::1 + ipv6: true + + unixDomainSocket: + # Enable/disable listening on the UNIX domain socket + enabled: true + # Alternative directory for UNIX domain sockets (defaults to /tmp) + pathPrefix: /var/run/mongodb + +#security: + # Private key for cluster authentication + #keyFile: + + # Run with/without security (enabled|disabled, disabled by default) + #authorization + +#operationProfiling: + +#replication: + +#sharding: diff --git a/mongos.service b/mongos.service new file mode 100644 index 0000000..b34c799 --- /dev/null +++ b/mongos.service @@ -0,0 +1,15 @@ +[Unit] +Description=High-performance, schema-free document-oriented database +After=syslog.target network.target + +[Service] +Type=forking +User=mongodb +EnvironmentFile=/etc/sysconfig/mongos +ExecStart=/usr/bin/mongos $OPTIONS +PrivateTmp=true +LimitNOFILE=64000 +TimeoutStartSec=180 + +[Install] +WantedBy=multi-user.target diff --git a/mongos.sysconf b/mongos.sysconf new file mode 100644 index 0000000..11a1ead --- /dev/null +++ b/mongos.sysconf @@ -0,0 +1 @@ +OPTIONS="-f /etc/mongos.conf"